Skip to content

Commit 63f1d9b

Browse files
committed
refactor(ui): extract group header button styles to styled component
- Create Group.styles.ts with GroupHeaderButton styled component - Replace className-based styles with styled component in Group and DeleteTutorialButton - Use theme-based colors instead of CSS variables - Apply import pattern rule (import * as S) for styled components
1 parent 28801ea commit 63f1d9b

File tree

4 files changed

+31
-26
lines changed

4 files changed

+31
-26
lines changed

redisinsight/ui/src/components/side-panels/panels/enablement-area/EnablementArea/components/DeleteTutorialButton/DeleteTutorialButton.tsx

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ import { DeleteIcon } from 'uiSrc/components/base/icons'
77
import { Text } from 'uiSrc/components/base/text'
88
import { RiIcon } from 'uiSrc/components/base/icons/RiIcon'
99
import { RiPopover } from 'uiSrc/components/base'
10+
11+
import * as S from '../Group/Group.styles'
1012
import styles from './styles.module.scss'
1113

1214
export interface Props {
@@ -32,14 +34,13 @@ const DeleteTutorialButton = (props: Props) => {
3234
closePopover={() => setIsPopoverDeleteOpen(false)}
3335
panelPaddingSize="l"
3436
button={
35-
<div
36-
className="group-header__btn"
37+
<S.GroupHeaderButton
3738
role="presentation"
3839
onClick={handleClickDelete}
3940
data-testid={`delete-tutorial-icon-${id}`}
4041
>
4142
<RiIcon size="m" type="DeleteIcon" />
42-
</div>
43+
</S.GroupHeaderButton>
4344
}
4445
onClick={(e) => e.stopPropagation()}
4546
data-testid={`delete-tutorial-popover-${id}`}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
import React from 'react'
2+
import styled from 'styled-components'
3+
import { Theme } from '@redis-ui/styles'
4+
5+
export const GroupHeaderButton = styled.div<
6+
React.HTMLAttributes<HTMLDivElement>
7+
>`
8+
display: flex;
9+
align-items: center;
10+
justify-content: center;
11+
12+
width: 24px;
13+
height: 24px;
14+
border-radius: ${({ theme }: { theme: Theme }) => theme.core.space.space050};
15+
cursor: pointer;
16+
17+
&:hover {
18+
color: ${({ theme }: { theme: Theme }) =>
19+
theme.semantic.color.text.neutral100};
20+
background-color: ${({ theme }: { theme: Theme }) =>
21+
theme.semantic.color.background.neutral200};
22+
}
23+
`

redisinsight/ui/src/components/side-panels/panels/enablement-area/EnablementArea/components/Group/Group.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import { RiIcon } from 'uiSrc/components/base/icons/RiIcon'
2020

2121
import DeleteTutorialButton from '../DeleteTutorialButton'
2222

23+
import * as S from './Group.styles'
2324
import './styles.scss'
2425

2526
export interface Props {
@@ -98,15 +99,14 @@ const Group = (props: Props) => {
9899
panelClassName={cx({ hide: isPageOpened })}
99100
preventPropagation
100101
>
101-
<RiTooltip content="Upload Tutorial">
102-
<div
103-
className="group-header__btn"
102+
<RiTooltip content="Upload tutorial">
103+
<S.GroupHeaderButton
104104
role="presentation"
105105
onClick={handleCreate}
106106
data-testid="open-upload-tutorial-btn"
107107
>
108108
<RiIcon type="PlusSlimIcon" size="m" />
109-
</div>
109+
</S.GroupHeaderButton>
110110
</RiTooltip>
111111
</OnboardingTour>
112112
)}

redisinsight/ui/src/components/side-panels/panels/enablement-area/EnablementArea/components/Group/styles.scss

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -25,25 +25,6 @@
2525
white-space: nowrap;
2626
text-overflow: ellipsis;
2727

28-
&__btn {
29-
display: flex;
30-
align-items: center;
31-
justify-content: center;
32-
33-
width: 24px;
34-
height: 24px;
35-
border-radius: 4px;
36-
cursor: pointer;
37-
38-
&:hover {
39-
color: var(--euiColorPrimaryText);
40-
background-color: var(--euiColorSecondary);
41-
}
42-
}
43-
44-
.euiIcon {
45-
margin-right: 4px;
46-
}
4728
}
4829

4930
.divider {

0 commit comments

Comments
 (0)