Skip to content

Commit dd15434

Browse files
committed
refactor: 주기 칩 컴포넌트 코드 개선
1 parent 3fc04a1 commit dd15434

4 files changed

Lines changed: 11 additions & 15 deletions

File tree

src/page/todo/myTodo/component/CycleChip/CycleChip.css.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import { fonts } from '@/style/token/typography.css';
66
export const chipBase = style({
77
display: 'flex',
88
alignItems: 'center',
9+
justifyContent: 'center',
910
borderRadius: '8px',
1011
textAlign: 'center',
1112
...fonts.subtitle02,
@@ -18,15 +19,13 @@ export const selectorChip = styleVariants({
1819
padding: '1.4rem 2rem',
1920
background: colors.gradient04,
2021
color: colors.grey11,
21-
justifyContent: 'center',
2222
},
2323
deselected: {
2424
width: '17rem',
2525
height: '5.6rem',
2626
padding: '1.4rem 2rem',
2727
background: colors.grey3,
2828
color: colors.grey8,
29-
justifyContent: 'center',
3029
selectors: {
3130
'&:hover': {
3231
background: colors.grey2,
@@ -41,6 +40,4 @@ export const displayChip = style({
4140
padding: '1.4rem 2rem',
4241
background: colors.grey4,
4342
color: colors.grey10,
44-
textAlign: 'center',
45-
justifyContent: 'center',
4643
});

src/page/todo/myTodo/component/CycleChip/CycleChip.tsx

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,20 @@
11
import { chipBase, selectorChip, displayChip } from './CycleChip.css';
2-
import type { CycleChipProps } from './CycleChip.types';
2+
3+
export type CycleType = '매일' | '매주' | '한번';
4+
5+
export interface CycleChipProps {
6+
type: 'selector' | 'display';
7+
value: CycleType;
8+
selected?: boolean;
9+
onClick?: (cycle: CycleType) => void;
10+
}
311

412
const CycleChip = ({ type, value, selected, onClick }: CycleChipProps) => {
513
return type === 'selector' ? (
614
<button
715
type="button"
816
className={`${chipBase} ${selected ? selectorChip.selected : selectorChip.deselected}`}
917
onClick={() => onClick?.(value)}
10-
tabIndex={0}
1118
>
1219
{value}
1320
</button>

src/page/todo/myTodo/component/CycleChip/CycleChip.types.ts

Lines changed: 0 additions & 8 deletions
This file was deleted.
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
export { default as CycleChip } from './CycleChip';
2-
export * from './CycleChip.types';
2+
export type { CycleType, CycleChipProps } from './CycleChip';

0 commit comments

Comments
 (0)