Skip to content

Commit bbcd45b

Browse files
committed
feat(components): apply the new alpha source size style to related components
1 parent e3df4e0 commit bbcd45b

File tree

8 files changed

+23
-57
lines changed

8 files changed

+23
-57
lines changed

packages/bezier-react/src/components/AlphaAvatar/Avatar.module.scss

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
@use '../../styles/mixins/dimension';
22

3-
$avatar-sizes: 16, 20, 24, 30, 36, 42, 48, 72, 90, 120;
4-
53
.Avatar {
64
position: relative;
75
display: block;
@@ -10,12 +8,6 @@ $avatar-sizes: 16, 20, 24, 30, 36, 42, 48, 72, 90, 120;
108
pointer-events: none;
119
opacity: var(--alpha-opacity-disabled);
1210
}
13-
14-
@each $size in $avatar-sizes {
15-
&:where(.size-#{$size}) {
16-
@include dimension.square(#{$size}px);
17-
}
18-
}
1911
}
2012

2113
.AvatarImage {

packages/bezier-react/src/components/AlphaAvatar/Avatar.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { forwardRef, isValidElement, useMemo } from 'react'
44

55
import classNames from 'classnames'
66

7+
import { getSourceSizeClassName } from '~/src/types/alpha-props-helpers'
78
import { isEmpty } from '~/src/utils/type'
89

910
import { useAvatarContext } from '~/src/components/AlphaAvatar/AvatarSizeContext'
@@ -127,11 +128,13 @@ export const Avatar = forwardRef<HTMLDivElement, AvatarProps>(function Avatar(
127128
)
128129
}, [status, size, children])
129130

131+
console.log(getSourceSizeClassName(size))
132+
130133
return (
131134
<div
132135
className={classNames(
133136
styles.Avatar,
134-
styles[`size-${size}`],
137+
getSourceSizeClassName(size),
135138
disabled && styles.disabled,
136139
className
137140
)}

packages/bezier-react/src/components/AlphaAvatar/Avatar.types.ts

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { type SourceSize } from '~/src/types/alpha-tokens'
12
import {
23
type BezierComponentProps,
34
type ChildrenProps,
@@ -8,17 +9,7 @@ import {
89
// TODO: Replace this with AlphaStatusBadgeType
910
import { type StatusType } from '~/src/components/Status'
1011

11-
export type AvatarSize =
12-
| '16'
13-
| '20'
14-
| '24'
15-
| '30'
16-
| '36'
17-
| '42'
18-
| '48'
19-
| '72'
20-
| '90'
21-
| '120'
12+
export type AvatarSize = SourceSize
2213

2314
interface AvatarOwnProps {
2415
/**

packages/bezier-react/src/components/AlphaAvatarGroup/AvatarGroup.module.scss

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,10 @@
1-
@use '../AlphaAvatar/Avatar.module';
2-
31
.AvatarGroup {
42
--b-avatar-group-spacing: 0;
5-
--b-avatar-group-size: 0;
63

74
position: relative;
85
z-index: var(--z-index-base);
96
display: flex;
107

11-
@each $size in Avatar.$avatar-sizes {
12-
&:where(.size-#{$size}) {
13-
--b-avatar-group-size: #{$size}px;
14-
}
15-
}
16-
178
& > * + * {
189
margin-left: var(--b-avatar-group-spacing);
1910
}
@@ -49,5 +40,5 @@
4940
position: relative;
5041
display: flex;
5142
align-items: center;
52-
height: var(--b-avatar-group-size);
43+
height: 100%;
5344
}

packages/bezier-react/src/components/AlphaAvatarGroup/AvatarGroup.tsx

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -37,13 +37,16 @@ function getRestAvatarListCountText(count: number, max: number) {
3737
function getProperIconSize(size: AlphaAvatarSize) {
3838
return (
3939
{
40+
10: 'xxs',
41+
12: 'xxs',
4042
16: 'xxs',
4143
20: 'xxs',
4244
24: 'xs',
4345
30: 's',
4446
36: 'm',
4547
42: 'm',
4648
48: 'l',
49+
60: 'l',
4750
72: 'l',
4851
90: 'l',
4952
120: 'l',
@@ -55,13 +58,16 @@ function getProperIconSize(size: AlphaAvatarSize) {
5558
function getProperTypoSize(size: AlphaAvatarSize) {
5659
return (
5760
{
61+
10: '12',
62+
12: '12',
5863
16: '12',
5964
20: '12',
6065
24: '13',
6166
30: '15',
6267
36: '16',
6368
42: '18',
6469
48: '24',
70+
60: '24',
6571
72: '24',
6672
90: '24',
6773
120: '24',
@@ -202,11 +208,7 @@ export const AvatarGroup = forwardRef<HTMLDivElement, AvatarGroupProps>(
202208
<div
203209
role="group"
204210
ref={forwardedRef}
205-
className={classNames(
206-
styles.AvatarGroup,
207-
styles[`size-${size}`],
208-
className
209-
)}
211+
className={classNames(styles.AvatarGroup, className)}
210212
style={
211213
{
212214
'--b-avatar-group-spacing': px(spacing),
Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,7 @@
1-
@use '../../styles/mixins/dimension';
2-
3-
$size-map: (
4-
xxxs: 10,
5-
xxs: 12,
6-
xs: 16,
7-
s: 20,
8-
m: 24,
9-
l: 36,
10-
xl: 44,
11-
);
12-
131
.Icon {
142
--b-icon-color: initial;
153

164
flex: 0 0 auto;
175
color: var(--b-icon-color);
186
transition: color var(--transition-s);
19-
20-
@each $size, $value in $size-map {
21-
&:where(.size-#{$size}) {
22-
@include dimension.square(#{$value}px);
23-
}
24-
}
257
}

packages/bezier-react/src/components/AlphaIcon/Icon.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import * as React from 'react'
55

66
import classNames from 'classnames'
77

8+
import { getSourceSizeClassName } from '~/src/types/alpha-props-helpers'
89
import { getMarginStyles, splitByMarginProps } from '~/src/types/props-helpers'
910
import { alphaColorTokenCssVar } from '~/src/utils/style'
1011

@@ -21,7 +22,7 @@ export const Icon = memo(
2122

2223
const {
2324
className,
24-
size = 'm',
25+
size = '24',
2526
color,
2627
source: SourceElement,
2728
style,
@@ -40,7 +41,7 @@ export const Icon = memo(
4041
}
4142
className={classNames(
4243
styles.Icon,
43-
styles[`size-${size}`],
44+
getSourceSizeClassName(size),
4445
marginStyles.className,
4546
className
4647
)}

packages/bezier-react/src/components/AlphaIcon/Icon.types.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,17 @@
11
import { type BezierIcon } from '@channel.io/bezier-icons'
22

3-
import type { FunctionalColor, SemanticColor } from '~/src/types/alpha-tokens'
3+
import type {
4+
FunctionalColor,
5+
SemanticColor,
6+
SourceSize,
7+
} from '~/src/types/alpha-tokens'
48
import {
59
type BezierComponentProps,
610
type MarginProps,
711
type SizeProps,
812
} from '~/src/types/props'
913

10-
export type IconSize = 'xs' | 's' | 'm' | 'l' | 'xl'
14+
export type IconSize = SourceSize
1115

1216
interface IconOwnProps {
1317
/**

0 commit comments

Comments
 (0)