Skip to content

Commit 3f3ef73

Browse files
committed
feat(icon-button): use AlphaIcon instead of Icon
1 parent 9cfbee0 commit 3f3ef73

File tree

2 files changed

+23
-28
lines changed

2 files changed

+23
-28
lines changed

packages/bezier-react/src/components/AlphaIconButton/IconButton.module.scss

Lines changed: 13 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,43 +1,39 @@
11
@use '../../styles/mixins/dimension';
22

3-
@use '../Icon/Icon.module';
4-
53
$chromatic-colors: 'blue', 'red', 'green', 'cobalt', 'orange', 'pink', 'purple';
64

75
.IconButton {
6+
--b-icon-button-padding: initial;
7+
88
position: relative;
99
box-sizing: border-box;
10+
padding: var(--b-icon-button-padding);
1011
transition: background-color var(--transition-s);
1112

1213
/* dimension */
1314
&:where(.size-xs) {
15+
--b-icon-button-padding: 2px;
1416
@include dimension.square(20px);
15-
16-
padding: 2px;
1717
}
1818

1919
&:where(.size-s) {
20+
--b-icon-button-padding: 4px;
2021
@include dimension.square(24px);
21-
22-
padding: 4px;
2322
}
2423

2524
&:where(.size-m) {
25+
--b-icon-button-padding: 8px;
2626
@include dimension.square(36px);
27-
28-
padding: 8px;
2927
}
3028

3129
&:where(.size-l) {
30+
--b-icon-button-padding: 12px;
3231
@include dimension.square(44px);
33-
34-
padding: 12px;
3532
}
3633

3734
&:where(.size-xl) {
35+
--b-icon-button-padding: 15px;
3836
@include dimension.square(54px);
39-
40-
padding: 15px;
4137
}
4238

4339
/* background-color */
@@ -265,18 +261,16 @@ $chromatic-colors: 'blue', 'red', 'green', 'cobalt', 'orange', 'pink', 'purple';
265261

266262
& :where(.ButtonLoader) {
267263
position: absolute;
268-
inset: 0;
264+
top: var(--b-icon-button-padding);
265+
left: var(--b-icon-button-padding);
269266

270267
display: flex;
271268
align-items: center;
272269
justify-content: center;
273270

274-
@each $size, $value in Icon.$size-map {
275-
&:where(.size-#{$size}) {
276-
& :is(.Loader) {
277-
@include dimension.square(#{$value}px);
278-
}
279-
}
271+
& :is(.Loader) {
272+
width: inherit;
273+
height: inherit;
280274
}
281275
}
282276
}

packages/bezier-react/src/components/AlphaIconButton/IconButton.tsx

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,22 +5,24 @@ import { forwardRef } from 'react'
55
import { isBezierIcon } from '@channel.io/bezier-icons'
66
import classNames from 'classnames'
77

8+
import { getSourceSizeClassName } from '~/src/types/alpha-props-helpers'
9+
10+
import { AlphaIcon } from '~/src/components/AlphaIcon'
811
import { type AlphaIconButtonProps } from '~/src/components/AlphaIconButton'
912
import { AlphaLoader } from '~/src/components/AlphaLoader'
1013
import { BaseButton } from '~/src/components/BaseButton'
1114
import { type ButtonSize } from '~/src/components/Button'
12-
import { Icon } from '~/src/components/Icon'
1315

1416
import styles from './IconButton.module.scss'
1517

1618
function getIconSize(size: ButtonSize) {
1719
return (
1820
{
19-
xs: 'xs',
20-
s: 'xs',
21-
m: 's',
22-
l: 's',
23-
xl: 'm',
21+
xs: '16',
22+
s: '16',
23+
m: '20',
24+
l: '20',
25+
xl: '24',
2426
} as const
2527
)[size]
2628
}
@@ -68,7 +70,7 @@ export const IconButton = forwardRef<HTMLButtonElement, AlphaIconButtonProps>(
6870
)}
6971
>
7072
{isBezierIcon(content) ? (
71-
<Icon
73+
<AlphaIcon
7274
size={getIconSize(size)}
7375
source={content}
7476
className={styles.ButtonIcon}
@@ -82,8 +84,7 @@ export const IconButton = forwardRef<HTMLButtonElement, AlphaIconButtonProps>(
8284
<div
8385
className={classNames(
8486
styles.ButtonLoader,
85-
// NOTE: Loader size is the same as icon size
86-
styles[`size-${getIconSize(size)}`]
87+
getSourceSizeClassName(getIconSize(size))
8788
)}
8889
>
8990
<AlphaLoader

0 commit comments

Comments
 (0)