Skip to content

Commit 058867d

Browse files
committed
Add ratings to each crafting station. Tags on <CraftStationLink> polished with left and right gradient fade out
1 parent 8c363b2 commit 058867d

File tree

2 files changed

+50
-30
lines changed

2 files changed

+50
-30
lines changed

app/craft/components/craft-station-link.tsx

Lines changed: 21 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { motion } from 'motion/react';
44
import Link from 'next/link';
55

66
import type { CraftStation } from '@/app/craft/types';
7+
import { ScrollArea, ScrollBar } from '@/components/ui/scroll-area';
78
import { cn } from '@/lib/utils';
89

910
type CraftStationLinkProps = {
@@ -16,27 +17,34 @@ export function CraftStationLink(props: CraftStationLinkProps) {
1617
<motion.div
1718
layoutId={`craft_station.container.${props.station.id}`}
1819
className={cn(
19-
'group bg-background flex h-20 w-full flex-col justify-center overflow-hidden rounded-lg border p-4 text-left',
20+
'group bg-background flex h-20 w-full flex-col justify-center overflow-hidden rounded-lg border py-4 text-left',
2021
'transition-shadow duration-300 hover:shadow-md'
2122
)}
2223
>
2324
<motion.div
2425
layoutId={`craft_station.title.${props.station.id}`}
25-
className='shrink-0 truncate text-sm font-semibold'
26+
className='shrink-0 truncate px-4 text-sm font-semibold'
2627
>
2728
{props.station.title}
2829
</motion.div>
29-
<div className='text-muted-foreground mt-2 flex shrink-0 items-center gap-x-2 text-xs'>
30-
{props.station.tags.map((tag) => (
31-
<motion.span
32-
layoutId={`craft_station.tag.${props.station.id}.${tag}`}
33-
className='bg-muted rounded-md border px-2.5 py-1'
34-
key={tag}
35-
>
36-
{tag}
37-
</motion.span>
38-
))}
39-
</div>
30+
<ScrollArea className='relative w-full'>
31+
<div className='text-muted-foreground mt-2 flex shrink-0 items-center gap-x-2 px-4 text-xs'>
32+
{props.station.tags.map((tag) => (
33+
<motion.span
34+
layoutId={`craft_station.tag.${props.station.id}.${tag}`}
35+
className='bg-muted rounded-md border px-2.5 py-1'
36+
key={tag}
37+
>
38+
{tag}
39+
</motion.span>
40+
))}
41+
</div>
42+
<ScrollBar orientation='horizontal' className='sr-only' />
43+
{/* left gradient blur */}
44+
<div className='from-background absolute top-0 left-0 h-full w-6 bg-gradient-to-r to-transparent' />
45+
{/* right gradient blur */}
46+
<div className='from-background absolute top-0 right-0 h-full w-6 bg-gradient-to-l to-transparent' />
47+
</ScrollArea>
4048
</motion.div>
4149
</Link>
4250
);

app/craft/components/craft-station-modal-content.tsx

Lines changed: 29 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import { motion } from 'motion/react';
44

55
import type { CraftStation } from '@/app/craft/types';
6+
import { Ratings } from '@/components/ui/ratings';
67

78
import { Sandbox } from './sandbox';
89

@@ -19,27 +20,38 @@ export function CraftStationModalContent(props: CraftStationModalContentProps) {
1920
>
2021
{props.station.title}
2122
</motion.div>
22-
<motion.p
23-
className='text-muted-foreground'
24-
initial={{ opacity: 0 }}
25-
animate={{ opacity: 1 }}
26-
exit={{ opacity: 0 }}
27-
>
28-
{props.station.description}
29-
</motion.p>
30-
<div className='flex gap-2'>
31-
{props.station.tags.map((tag) => (
32-
<motion.span
33-
layoutId={`craft_station.tag.${props.station.id}.${tag}`}
34-
key={tag}
35-
className='bg-muted text-muted-foreground rounded-md px-2.5 py-1 text-sm'
23+
<div className='flex flex-col items-stretch gap-x-4 sm:flex-row sm:items-center'>
24+
<div className='flex grow flex-col gap-y-2'>
25+
<motion.p
26+
className='text-muted-foreground flex-1'
27+
initial={{ opacity: 0 }}
28+
animate={{ opacity: 1 }}
29+
exit={{ opacity: 0 }}
3630
>
37-
{tag}
38-
</motion.span>
39-
))}
31+
{props.station.description}
32+
</motion.p>
33+
<div className='flex gap-2'>
34+
{props.station.tags.map((tag) => (
35+
<motion.span
36+
layoutId={`craft_station.tag.${props.station.id}.${tag}`}
37+
key={tag}
38+
className='bg-muted text-muted-foreground rounded-md px-2.5 py-1 text-sm'
39+
>
40+
{tag}
41+
</motion.span>
42+
))}
43+
</div>
44+
</div>
45+
<div className='hidden shrink-0 grow md:block'>
46+
<Ratings id={`craft_station.${props.station.id}`} />
47+
</div>
4048
</div>
4149
{/* Code */}
4250
<Sandbox code={props.station.code} />
51+
{/* Display ratings on smaller screens */}
52+
<div className='block md:hidden'>
53+
<Ratings id={`craft_station.${props.station.id}`} />
54+
</div>
4355
</motion.div>
4456
);
4557
}

0 commit comments

Comments
 (0)