Skip to content

Commit d0997b0

Browse files
author
Kristiyan Ivanov
authored
RI-7224 - in messages - ACK / CLAIM buttons need space between (#4769)
1 parent 7d34422 commit d0997b0

File tree

7 files changed

+104
-16
lines changed

7 files changed

+104
-16
lines changed
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
import React from 'react'
2+
import { render } from 'uiSrc/utils/test-utils'
3+
import { HorizontalSpacer } from './horizontal-spacer'
4+
5+
describe('HorizontalSpacer', () => {
6+
it('should render with different sizes correctly', () => {
7+
const sizes = ['xs', 's', 'm', 'l', 'xl', 'xxl'] as const
8+
9+
sizes.forEach(size => {
10+
const { container } = render(<HorizontalSpacer size={size} />)
11+
const spacer = container.querySelector('.RI-horizontal-spacer') as HTMLElement
12+
13+
if (size === 'xl') {
14+
expect(spacer).toHaveStyle('width: calc(var(--base) * 2.25)')
15+
} else {
16+
expect(spacer).toHaveStyle(`width: var(--size-${size})`)
17+
}
18+
})
19+
})
20+
21+
it('should render children when provided', () => {
22+
const { getByText } = render(
23+
<HorizontalSpacer size="s">
24+
<span>Test content</span>
25+
</HorizontalSpacer>
26+
)
27+
const content = getByText('Test content')
28+
expect(content).toBeInTheDocument()
29+
expect(content.parentElement).toHaveStyle('width: var(--size-s)')
30+
})
31+
32+
it('should apply custom className', () => {
33+
const { container } = render(<HorizontalSpacer className="custom-class" />)
34+
const spacer = container.querySelector('.RI-horizontal-spacer') as HTMLElement
35+
36+
expect(spacer).toHaveClass('RI-horizontal-spacer')
37+
expect(spacer).toHaveClass('custom-class')
38+
})
39+
40+
it('should pass through custom props', () => {
41+
const { container } = render(
42+
<HorizontalSpacer data-testid="my-spacer" id="spacer-id" />
43+
)
44+
const spacer = container.querySelector('.RI-horizontal-spacer') as HTMLElement
45+
46+
expect(spacer).toHaveAttribute('data-testid', 'my-spacer')
47+
expect(spacer).toHaveAttribute('id', 'spacer-id')
48+
})
49+
})
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
import { HTMLAttributes, ReactNode } from 'react'
2+
import styled from 'styled-components'
3+
import { CommonProps } from 'uiSrc/components/base/theme/types'
4+
5+
export const HorizontalSpacerSizes = ['xs', 's', 'm', 'l', 'xl', 'xxl'] as const
6+
export type HorizontalSpacerSize = (typeof HorizontalSpacerSizes)[number]
7+
export type HorizontalSpacerProps = CommonProps &
8+
HTMLAttributes<HTMLDivElement> & {
9+
children?: ReactNode
10+
size?: HorizontalSpacerSize
11+
}
12+
13+
export const horizontalSpacerStyles = {
14+
xs: 'var(--size-xs)',
15+
s: 'var(--size-s)',
16+
m: 'var(--size-m)',
17+
l: 'var(--size-l)',
18+
xl: 'calc(var(--base) * 2.25)',
19+
xxl: 'var(--size-xxl)',
20+
}
21+
22+
export const StyledHorizontalSpacer = styled.div<HorizontalSpacerProps>`
23+
flex-shrink: 0;
24+
width: ${({ size = 'l' }) => horizontalSpacerStyles[size]};
25+
display: inline-block;
26+
`
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import React from 'react'
2+
import cx from 'classnames'
3+
import {
4+
HorizontalSpacerProps,
5+
StyledHorizontalSpacer,
6+
} from './horizontal-spacer.styles'
7+
8+
export const HorizontalSpacer = ({ className, children, ...rest }: HorizontalSpacerProps) => (
9+
<StyledHorizontalSpacer {...rest} className={cx('RI-horizontal-spacer', className)}>
10+
{children}
11+
</StyledHorizontalSpacer>
12+
)
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
export { HorizontalSpacer } from './horizontal-spacer'
2+
export type { HorizontalSpacerSize, HorizontalSpacerProps } from './horizontal-spacer.styles'

redisinsight/ui/src/components/base/layout/index.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ import ResizablePanelHandle from './resize/handle/ResizablePanelHandle'
66

77

88
export * from './card'
9+
export * from './horizontal-spacer'
10+
export * from './spacer'
911
export {
1012
HorizontalRule,
1113
LoadingContent,

redisinsight/ui/src/pages/browser/modules/key-details/components/stream-details/messages-view/MessageAckPopover/MessageAckPopover.tsx

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import {
66
SecondaryButton,
77
} from 'uiSrc/components/base/forms/buttons'
88
import { RiPopover } from 'uiSrc/components/base'
9+
import { HorizontalSpacer } from 'uiSrc/components/base/layout'
910
import styles from './styles.module.scss'
1011

1112
export interface Props {
@@ -35,15 +36,18 @@ const AckPopover = (props: Props) => {
3536
anchorClassName="ackMessagePopover"
3637
panelClassName={styles.popoverWrapper}
3738
button={
38-
<SecondaryButton
39-
size="s"
40-
aria-label="Acknowledge pending message"
41-
onClick={showPopover}
42-
className={styles.ackBtn}
43-
data-testid="acknowledge-btn"
44-
>
45-
ACK
46-
</SecondaryButton>
39+
<>
40+
<SecondaryButton
41+
size="s"
42+
aria-label="Acknowledge pending message"
43+
onClick={showPopover}
44+
className={styles.ackBtn}
45+
data-testid="acknowledge-btn"
46+
>
47+
ACK
48+
</SecondaryButton>
49+
<HorizontalSpacer size="s" />
50+
</>
4751
}
4852
>
4953
<div className={styles.popover}>

redisinsight/ui/src/pages/browser/modules/key-details/components/stream-details/messages-view/MessageAckPopover/styles.module.scss

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,4 @@
2626
margin-top: 12px;
2727
}
2828

29-
.ackBtn:global(.euiButton.euiButton--secondary) {
30-
min-width: initial !important;
31-
color: var(--textColorShade) !important;
32-
}
3329

34-
.ackBtn :global(.euiButtonContent .euiButton__text) {
35-
font: normal normal normal 12px/18px Graphik, sans-serif !important;
36-
}

0 commit comments

Comments
 (0)