Skip to content

Commit 6db377e

Browse files
committed
feat/course-button
1 parent 193cbc6 commit 6db377e

File tree

2 files changed

+82
-0
lines changed

2 files changed

+82
-0
lines changed

src/pages/map/index.tsx

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
import CummonButton from '@/shared/components/button/CommonButton';
2+
import { useState } from 'react';
3+
4+
export default function CourseSettingPreview() {
5+
const [active, setActive] = useState<string | null>(null);
6+
7+
const buttons = [
8+
{ id: 'family', label: '가족여행' },
9+
{ id: 'friends', label: '우정여행' },
10+
{ id: 'date', label: '데이트' },
11+
{ id: 'solo', label: '당일치기' },
12+
{ id: 'oneNight', label: '1박2일' },
13+
{ id: 'twoNight', label: '2박3일' },
14+
{ id: 'walk', label: '도보' },
15+
{ id: 'transit', label: '대중교통' },
16+
{ id: 'car', label: '자가차' },
17+
];
18+
19+
return (
20+
// 스타일은 다 수정할 거에요 버튼만 봐주세요~ // CommonButton.tsx 저것만 확인해주세요
21+
<div className="flex flex-col items-center gap-6 py-10">
22+
<h1 className="text-title-lg text-gray-700 mb-4">코스 버튼 임시 화면</h1>
23+
<div className="flex flex-wrap justify-center gap-4 max-w-[400px]">
24+
{buttons.map(({ id, label }) => (
25+
<CummonButton
26+
key={id}
27+
label={label}
28+
variant={active === id ? 'active' : 'default'}
29+
onClick={() => setActive(active === id ? null : id)}
30+
/>
31+
))}
32+
</div>
33+
</div>
34+
);
35+
}
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
import { cva, type VariantProps } from 'class-variance-authority';
2+
import { cn } from '@/shared/lib';
3+
4+
interface CummonButtonProps
5+
extends React.ButtonHTMLAttributes<HTMLButtonElement>,
6+
VariantProps<typeof buttonStyle> {
7+
label: string;
8+
}
9+
10+
const buttonStyle = cva(
11+
`
12+
text-center rounded-[2rem] text-title-md tracking-[0.015em]
13+
py-[1rem] w-[11.3rem] border border-[1px]
14+
transition-colors duration-150 flex justify-center items-center
15+
select-none focus:outline-none focus:ring-0 active:outline-none
16+
`,
17+
{
18+
variants: {
19+
variant: {
20+
default: 'bg-gray-100 border-gray-200 text-gray-400',
21+
active: 'bg-mint-100 border-mint-200 text-mint-700',
22+
},
23+
},
24+
defaultVariants: {
25+
variant: 'default',
26+
},
27+
}
28+
);
29+
30+
const CummonButton = ({
31+
label,
32+
variant,
33+
className,
34+
...props
35+
}: CummonButtonProps) => {
36+
return (
37+
<button
38+
type="button"
39+
className={cn(buttonStyle({ variant }), className)}
40+
{...props}
41+
>
42+
{label}
43+
</button>
44+
);
45+
};
46+
47+
export default CummonButton;

0 commit comments

Comments
 (0)