Skip to content

Commit b863417

Browse files
committed
refactor: simplify section and div elements in carousel component
1 parent 7d44b3c commit b863417

2 files changed

Lines changed: 7 additions & 21 deletions

File tree

src/components/home/carousel-mock.tsx

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,19 +16,15 @@ const mockCards = [
1616
},
1717
{
1818
title: "WiFiLinux",
19-
caption:
20-
"Scarica ed esegui lo script Python per attivare la connessione permanente al WiFi Polimi.",
21-
19+
caption: "Scarica ed esegui lo script Python per attivare la connessione permanente al WiFi Polimi.",
2220
},
2321
{
2422
title: "The TOL Project",
25-
caption:
26-
"Un simulatore gratuito del test di ammissione per le aspiranti matricole di Ingegneria del PoliMi.",
27-
23+
caption: "Un simulatore gratuito del test di ammissione per le aspiranti matricole di Ingegneria del PoliMi.",
2824
},
2925
] as const
3026

31-
// TODO: delete this when merging
27+
// TODO: delete this when merging
3228
export function CarouselMock() {
3329
return (
3430
<section className="mx-auto flex min-h-screen w-full max-w-4xl flex-col items-center justify-center gap-16 px-7.5">

src/components/ui/carousel.tsx

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -121,12 +121,7 @@ function Carousel({
121121
scrollSnaps,
122122
}}
123123
>
124-
<section
125-
onKeyDownCapture={handleKeyDown}
126-
className={cn("relative", className)}
127-
data-slot="carousel"
128-
{...props}
129-
>
124+
<section onKeyDownCapture={handleKeyDown} className={cn("relative", className)} data-slot="carousel" {...props}>
130125
{children}
131126
</section>
132127
</CarouselContext.Provider>
@@ -162,11 +157,7 @@ function CarouselDots({ className, ...props }: React.ComponentProps<"div">) {
162157
if (scrollSnaps.length <= 1) return null
163158

164159
return (
165-
<div
166-
data-slot="carousel-dots"
167-
className={cn("flex items-center justify-center gap-3", className)}
168-
{...props}
169-
>
160+
<div data-slot="carousel-dots" className={cn("flex items-center justify-center gap-3", className)} {...props}>
170161
{scrollSnaps.map((scrollSnap, index) => (
171162
<Button
172163
key={scrollSnap}
@@ -186,9 +177,8 @@ function CarouselDots({ className, ...props }: React.ComponentProps<"div">) {
186177
/>
187178
<span className="sr-only">{`Slide ${index + 1}`}</span>
188179
</Button>
189-
))
190-
}
191-
</div >
180+
))}
181+
</div>
192182
)
193183
}
194184

0 commit comments

Comments
 (0)