Skip to content

Commit

Permalink
feat(components): apply the new alpha source size style to related co…
Browse files Browse the repository at this point in the history
…mponents
  • Loading branch information
sungik-choi committed Dec 17, 2024
1 parent e3df4e0 commit bbcd45b
Show file tree
Hide file tree
Showing 8 changed files with 23 additions and 57 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
@use '../../styles/mixins/dimension';

$avatar-sizes: 16, 20, 24, 30, 36, 42, 48, 72, 90, 120;

.Avatar {
position: relative;
display: block;
Expand All @@ -10,12 +8,6 @@ $avatar-sizes: 16, 20, 24, 30, 36, 42, 48, 72, 90, 120;
pointer-events: none;
opacity: var(--alpha-opacity-disabled);
}

@each $size in $avatar-sizes {
&:where(.size-#{$size}) {
@include dimension.square(#{$size}px);
}
}
}

.AvatarImage {
Expand Down
5 changes: 4 additions & 1 deletion packages/bezier-react/src/components/AlphaAvatar/Avatar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { forwardRef, isValidElement, useMemo } from 'react'

import classNames from 'classnames'

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

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

console.log(getSourceSizeClassName(size))

return (
<div
className={classNames(
styles.Avatar,
styles[`size-${size}`],
getSourceSizeClassName(size),
disabled && styles.disabled,
className
)}
Expand Down
13 changes: 2 additions & 11 deletions packages/bezier-react/src/components/AlphaAvatar/Avatar.types.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { type SourceSize } from '~/src/types/alpha-tokens'
import {
type BezierComponentProps,
type ChildrenProps,
Expand All @@ -8,17 +9,7 @@ import {
// TODO: Replace this with AlphaStatusBadgeType
import { type StatusType } from '~/src/components/Status'

export type AvatarSize =
| '16'
| '20'
| '24'
| '30'
| '36'
| '42'
| '48'
| '72'
| '90'
| '120'
export type AvatarSize = SourceSize

interface AvatarOwnProps {
/**
Expand Down
Original file line number Diff line number Diff line change
@@ -1,19 +1,10 @@
@use '../AlphaAvatar/Avatar.module';

.AvatarGroup {
--b-avatar-group-spacing: 0;
--b-avatar-group-size: 0;

position: relative;
z-index: var(--z-index-base);
display: flex;

@each $size in Avatar.$avatar-sizes {
&:where(.size-#{$size}) {
--b-avatar-group-size: #{$size}px;
}
}

& > * + * {
margin-left: var(--b-avatar-group-spacing);
}
Expand Down Expand Up @@ -49,5 +40,5 @@
position: relative;
display: flex;
align-items: center;
height: var(--b-avatar-group-size);
height: 100%;
}
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,16 @@ function getRestAvatarListCountText(count: number, max: number) {
function getProperIconSize(size: AlphaAvatarSize) {
return (
{
10: 'xxs',
12: 'xxs',
16: 'xxs',
20: 'xxs',
24: 'xs',
30: 's',
36: 'm',
42: 'm',
48: 'l',
60: 'l',
72: 'l',
90: 'l',
120: 'l',
Expand All @@ -55,13 +58,16 @@ function getProperIconSize(size: AlphaAvatarSize) {
function getProperTypoSize(size: AlphaAvatarSize) {
return (
{
10: '12',
12: '12',
16: '12',
20: '12',
24: '13',
30: '15',
36: '16',
42: '18',
48: '24',
60: '24',
72: '24',
90: '24',
120: '24',
Expand Down Expand Up @@ -202,11 +208,7 @@ export const AvatarGroup = forwardRef<HTMLDivElement, AvatarGroupProps>(
<div
role="group"
ref={forwardedRef}
className={classNames(
styles.AvatarGroup,
styles[`size-${size}`],
className
)}
className={classNames(styles.AvatarGroup, className)}
style={
{
'--b-avatar-group-spacing': px(spacing),
Expand Down
18 changes: 0 additions & 18 deletions packages/bezier-react/src/components/AlphaIcon/Icon.module.scss
Original file line number Diff line number Diff line change
@@ -1,25 +1,7 @@
@use '../../styles/mixins/dimension';

$size-map: (
xxxs: 10,
xxs: 12,
xs: 16,
s: 20,
m: 24,
l: 36,
xl: 44,
);

.Icon {
--b-icon-color: initial;

flex: 0 0 auto;
color: var(--b-icon-color);
transition: color var(--transition-s);

@each $size, $value in $size-map {
&:where(.size-#{$size}) {
@include dimension.square(#{$value}px);
}
}
}
5 changes: 3 additions & 2 deletions packages/bezier-react/src/components/AlphaIcon/Icon.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import * as React from 'react'

import classNames from 'classnames'

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

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

const {
className,
size = 'm',
size = '24',
color,
source: SourceElement,
style,
Expand All @@ -40,7 +41,7 @@ export const Icon = memo(
}
className={classNames(
styles.Icon,
styles[`size-${size}`],
getSourceSizeClassName(size),
marginStyles.className,
className
)}
Expand Down
8 changes: 6 additions & 2 deletions packages/bezier-react/src/components/AlphaIcon/Icon.types.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,17 @@
import { type BezierIcon } from '@channel.io/bezier-icons'

import type { FunctionalColor, SemanticColor } from '~/src/types/alpha-tokens'
import type {
FunctionalColor,
SemanticColor,
SourceSize,
} from '~/src/types/alpha-tokens'
import {
type BezierComponentProps,
type MarginProps,
type SizeProps,
} from '~/src/types/props'

export type IconSize = 'xs' | 's' | 'm' | 'l' | 'xl'
export type IconSize = SourceSize

interface IconOwnProps {
/**
Expand Down

0 comments on commit bbcd45b

Please sign in to comment.