Skip to content

Commit 489916c

Browse files
committed
feat: CycleChip 컴포넌트 구현
1 parent 70a418e commit 489916c

4 files changed

Lines changed: 75 additions & 0 deletions

File tree

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
import { style, styleVariants } from '@vanilla-extract/css';
2+
3+
import { colors } from '@/style/token/color.css';
4+
import { fonts } from '@/style/token/typography.css';
5+
6+
export const chipBase = style({
7+
display: 'flex',
8+
alignItems: 'center',
9+
borderRadius: '8px',
10+
textAlign: 'center',
11+
...fonts.subtitle02,
12+
});
13+
14+
export const selectorChip = styleVariants({
15+
selected: {
16+
width: '17rem',
17+
height: '5.6rem',
18+
padding: '1.4rem 2rem',
19+
background: colors.gradient04,
20+
color: colors.grey11,
21+
justifyContent: 'center',
22+
},
23+
deselected: {
24+
width: '17rem',
25+
height: '5.6rem',
26+
padding: '1.4rem 2rem',
27+
background: colors.grey3,
28+
color: colors.grey8,
29+
justifyContent: 'center',
30+
selectors: {
31+
'&:hover': {
32+
background: colors.grey2,
33+
color: colors.grey8,
34+
},
35+
},
36+
},
37+
});
38+
39+
export const displayChip = style({
40+
width: '10.6rem',
41+
padding: '1.4rem 2rem',
42+
background: colors.grey4,
43+
color: colors.grey10,
44+
textAlign: 'center',
45+
justifyContent: 'center',
46+
});
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import { chipBase, selectorChip, displayChip } from './CycleChip.css';
2+
import type { CycleChipProps } from './CycleChip.types';
3+
4+
const CycleChip = ({ type, value, selected, onClick }: CycleChipProps) => {
5+
return type === 'selector' ? (
6+
<button
7+
type="button"
8+
className={`${chipBase} ${selected ? selectorChip.selected : selectorChip.deselected}`}
9+
onClick={() => onClick?.(value)}
10+
tabIndex={0}
11+
>
12+
{value}
13+
</button>
14+
) : (
15+
<span className={`${chipBase} ${displayChip}`}>{value}</span>
16+
);
17+
};
18+
19+
export default CycleChip;
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
export type CycleType = '매일' | '매주' | '한번';
2+
3+
export interface CycleChipProps {
4+
type: 'selector' | 'display';
5+
value: CycleType;
6+
selected?: boolean;
7+
onClick?: (cycle: CycleType) => void;
8+
}
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
export { default as CycleChip } from './CycleChip';
2+
export * from './CycleChip.types';

0 commit comments

Comments
 (0)