Skip to content

Commit ad794d6

Browse files
committed
refactor: HelpButton - optimize icon rotation handling, IconBase - proper rotate class assignment
1 parent 2fba511 commit ad794d6

File tree

2 files changed

+4
-8
lines changed

2 files changed

+4
-8
lines changed

src/Shared/Components/Header/HelpButton.tsx

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -127,12 +127,7 @@ export const HelpButton = ({ serverInfo, fetchingServerInfo, onClick }: HelpButt
127127
>
128128
<Icon name="ic-help-outline" color="N900" size={20} />
129129
<span>Help</span>
130-
<span
131-
className="flex rotate"
132-
style={{ ['--rotateBy' as string]: isActionMenuOpen ? '180deg' : '0deg' }}
133-
>
134-
<Icon name="ic-caret-down-small" color={null} />
135-
</span>
130+
<Icon name="ic-caret-down-small" color={null} rotateBy={isActionMenuOpen ? 180 : 0} />
136131
</button>
137132
</ActionMenu>
138133
{isEnterprise && (

src/Shared/Components/Icon/IconBase.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616

1717
import { ConditionalWrap } from '@Common/Helper'
1818
import { Tooltip } from '@Common/Tooltip'
19+
import { isNullOrUndefined } from '@Shared/Helpers'
1920

2021
import { ICON_STROKE_WIDTH_MAP } from './constants'
2122
import { IconBaseProps } from './types'
@@ -48,13 +49,13 @@ export const IconBase = ({
4849
<ConditionalWrap condition={!!tooltipProps?.content} wrap={conditionalWrap(tooltipProps)}>
4950
<IconComponent
5051
data-testid={dataTestId}
51-
className={`${size ? `icon-dim-${size}` : ''} ${color ? 'icon-component-color' : ''} ${ICON_STROKE_WIDTH_MAP[size] ? 'icon-component-stroke-width' : ''} ${rotateBy ? 'rotate' : ''} ${fillSpace ? 'dc__fill-available-space' : ''} dc__no-shrink`}
52+
className={`${size ? `icon-dim-${size}` : ''} ${color ? 'icon-component-color' : ''} ${ICON_STROKE_WIDTH_MAP[size] ? 'icon-component-stroke-width' : ''} ${!isNullOrUndefined(rotateBy) ? 'rotate' : ''} ${fillSpace ? 'dc__fill-available-space' : ''} dc__no-shrink`}
5253
style={{
5354
...(color ? { ['--iconColor' as string]: `var(--${color})` } : {}),
5455
...(ICON_STROKE_WIDTH_MAP[size]
5556
? { ['--strokeWidth' as string]: ICON_STROKE_WIDTH_MAP[size] }
5657
: {}),
57-
...(rotateBy ? { ['--rotateBy' as string]: `${rotateBy}deg` } : {}),
58+
...(!isNullOrUndefined(rotateBy) ? { ['--rotateBy' as string]: `${rotateBy}deg` } : {}),
5859
}}
5960
/>
6061
</ConditionalWrap>

0 commit comments

Comments
 (0)