Skip to content

Commit ef20480

Browse files
committed
refactor: 투두 박스 컴포넌트 코드 개선
1 parent ff9cf4e commit ef20480

File tree

4 files changed

+18
-11
lines changed

4 files changed

+18
-11
lines changed

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
"@tanstack/react-query": "^5.81.5",
2424
"@vanilla-extract/recipes": "^0.5.7",
2525
"axios": "^1.10.0",
26+
"clsx": "^2.1.1",
2627
"openapi-typescript": "^7.8.0",
2728
"react": "^19.1.0",
2829
"react-dom": "^19.1.0",

pnpm-lock.yaml

Lines changed: 9 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

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

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -43,10 +43,8 @@ export const todoItemContainer = styleVariants({
4343

4444
export const todoText = styleVariants({
4545
recommend: {
46-
display: '-webkit-box',
4746
width: '33.3rem',
48-
WebkitBoxOrient: 'vertical',
49-
WebkitLineClamp: 1,
47+
whiteSpace: 'nowrap',
5048
overflow: 'hidden',
5149
textOverflow: 'ellipsis',
5250
color: colors.white01,
@@ -65,7 +63,6 @@ export const checkboxButton = style({
6563
justifyContent: 'center',
6664
width: '2.4rem',
6765
height: '2.4rem',
68-
aspectRatio: '1/1',
6966
background: 'none',
7067
border: 'none',
7168
padding: 0,
@@ -75,5 +72,4 @@ export const checkboxButton = style({
7572
export const checkboxIcon = style({
7673
width: '2.4rem',
7774
height: '2.4rem',
78-
aspectRatio: '1/1',
7975
});

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

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import clsx from 'clsx';
2+
13
import {
24
todoBoxContainer,
35
todoItemContainer,
@@ -22,7 +24,7 @@ interface TodoItemProps {
2224
}
2325

2426
const TodoBox = ({ type, items, onItemClick, className }: TodoBoxProps) => (
25-
<div className={`${todoBoxContainer[type]}${className ? ` ${className}` : ''}`}>
27+
<div className={clsx(todoBoxContainer[type], className)}>
2628
{items.map((item) => (
2729
<TodoItem key={item.id} item={item} type={type} onItemClick={onItemClick} />
2830
))}
@@ -49,11 +51,10 @@ const TodoItem = ({
4951
onClick={handleClick}
5052
aria-label={item.completed ? '완료 취소하기' : '완료하기'}
5153
>
52-
{item.completed ? (
53-
<IcCheckboxChecked className={checkboxIcon} />
54-
) : (
55-
<IcCheckboxDefault className={checkboxIcon} />
56-
)}
54+
{(() => {
55+
const CheckIcon = item.completed ? IcCheckboxChecked : IcCheckboxDefault;
56+
return <CheckIcon className={checkboxIcon} />;
57+
})()}
5758
</button>
5859
</div>
5960
);

0 commit comments

Comments
 (0)