Skip to content

Commit f8870bd

Browse files
committed
✨ feat(stories): add link to story route
1 parent 7039cb5 commit f8870bd

File tree

2 files changed

+76
-22
lines changed

2 files changed

+76
-22
lines changed

src/widgets/stories/ui/StoriesCarousel.tsx

Lines changed: 55 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -7,25 +7,64 @@ import {
77
} from '@/shared/ui/carousel'
88

99
export function StoriesCarousel() {
10+
const stories = [
11+
{
12+
id: '1',
13+
profileName: 'test',
14+
storyId: '1',
15+
},
16+
{
17+
id: '2',
18+
profileName: 'test',
19+
storyId: '2',
20+
},
21+
{
22+
id: '3',
23+
profileName: 'test',
24+
storyId: '3',
25+
},
26+
{
27+
id: '4',
28+
profileName: 'test',
29+
storyId: '4',
30+
},
31+
{
32+
id: '5',
33+
profileName: 'test',
34+
storyId: '5',
35+
},
36+
{
37+
id: '6',
38+
profileName: 'test',
39+
storyId: '6',
40+
},
41+
{
42+
id: '7',
43+
profileName: 'test',
44+
storyId: '7',
45+
},
46+
{
47+
id: '8',
48+
profileName: 'test',
49+
storyId: '8',
50+
},
51+
{
52+
id: '9',
53+
profileName: 'test',
54+
storyId: '9',
55+
},
56+
{
57+
id: '10',
58+
profileName: 'test',
59+
storyId: '10',
60+
},
61+
]
1062
return (
1163
<Carousel className="h-fit w-full" opts={{ slidesToScroll: 4 }}>
1264
<CarouselContent>
13-
<StoryItem />
14-
<StoryItem />
15-
<StoryItem />
16-
<StoryItem />
17-
<StoryItem />
18-
<StoryItem />
19-
<StoryItem />
20-
<StoryItem />
21-
<StoryItem />
22-
<StoryItem />
23-
<StoryItem />
24-
<StoryItem />
25-
<StoryItem />
26-
<StoryItem />
27-
<StoryItem />
28-
<StoryItem />
65+
{stories.map((story) => (
66+
<StoryItem key={story.id} {...story} />
67+
))}
2968
</CarouselContent>
3069
<CarouselNext className="top-1/2 right-0 translate-y-[-50%]" />
3170
<CarouselPrevious className="top-1/2 left-0 translate-y-[-50%]" />

src/widgets/stories/ui/StoryItem.tsx

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,31 @@
1+
import { Link } from '@tanstack/react-router'
12
import { ImageFallback } from '@/shared/ui/image-fallback'
23
import { CarouselItem } from '@/shared/ui/carousel'
34

4-
export function StoryItem() {
5+
interface StoryItemProps {
6+
profileName: string
7+
storyId: string
8+
}
9+
10+
export function StoryItem({ profileName, storyId }: StoryItemProps) {
511
return (
612
<CarouselItem className="flex basis-1/8 flex-col items-center gap-1">
7-
<div className="flex size-20 items-center justify-center rounded-full bg-linear-to-tr from-pink-500 via-red-500 to-yellow-400 p-1">
8-
<div className="flex size-full items-center justify-center rounded-full bg-white p-1">
9-
<div className="flex size-full items-center justify-center overflow-hidden rounded-full bg-gray-200">
10-
<ImageFallback />
13+
<Link
14+
to="/stories/$profile_name/$story_id"
15+
params={{
16+
profile_name: profileName,
17+
story_id: storyId,
18+
}}
19+
className="group focus:outline-none"
20+
>
21+
<div className="flex size-20 items-center justify-center rounded-full bg-linear-to-tr from-pink-500 via-red-500 to-yellow-400 p-1 transition group-hover:brightness-110">
22+
<div className="flex size-full items-center justify-center rounded-full bg-white p-1">
23+
<div className="flex size-full items-center justify-center overflow-hidden rounded-full bg-gray-200">
24+
<ImageFallback />
25+
</div>
1126
</div>
1227
</div>
13-
</div>
28+
</Link>
1429

1530
<span className="text-xs">닉네임</span>
1631
</CarouselItem>

0 commit comments

Comments
 (0)