fix: dot buttons work with orientation
This commit is contained in:
parent
6afa061aa3
commit
78a32f03e6
|
|
@ -281,6 +281,3 @@ import Autoplay from 'embla-carousel-autoplay'
|
|||
<ComponentPreview name="CarouselPlugin" />
|
||||
|
||||
See the [Embla Carousel docs](https://www.embla-carousel.com/api/plugins/) for more information on using plugins.
|
||||
```
|
||||
|
||||
##
|
||||
|
|
|
|||
|
|
@ -1,18 +1,18 @@
|
|||
<script setup lang="ts">
|
||||
import { Carousel, CarouselContent, CarouselItem, CarouselNext, CarouselPrevious } from '@/lib/registry/default/ui/carousel'
|
||||
import { Carousel, CarouselContent, CarouselDotButtons, CarouselItem, CarouselNext, CarouselPrevious } from '@/lib/registry/default/ui/carousel'
|
||||
import { Card, CardContent } from '@/lib/registry/default/ui/card'
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<Carousel
|
||||
orientation="vertical"
|
||||
class="relative w-full max-w-xsw-full max-w-xs"
|
||||
class="relative w-full max-w-xsw-full max-w-xs h-[90px] mb-20"
|
||||
:opts="{
|
||||
align: 'start',
|
||||
}"
|
||||
>
|
||||
<CarouselContent class="-mt-1 h-[200px]">
|
||||
<CarouselItem v-for="(_, index) in 5" :key="index" class="p-1 md:basis-1/2">
|
||||
<CarouselContent class="-mt-1 h-[100px]">
|
||||
<CarouselItem v-for="(_, index) in 5" :key="index" class="p-1">
|
||||
<div class="p-1">
|
||||
<Card>
|
||||
<CardContent class="flex items-center justify-center p-6">
|
||||
|
|
@ -24,5 +24,6 @@ import { Card, CardContent } from '@/lib/registry/default/ui/card'
|
|||
</CarouselContent>
|
||||
<CarouselPrevious />
|
||||
<CarouselNext />
|
||||
<CarouselDotButtons class="mt-4" />
|
||||
</Carousel>
|
||||
</template>
|
||||
|
|
|
|||
|
|
@ -4,15 +4,15 @@ import type { WithClassAsProps } from './interface'
|
|||
import { cn } from '@/lib/utils'
|
||||
|
||||
const props = defineProps<WithClassAsProps>()
|
||||
const { scrollTo, selectedIndex, scrollSnaps } = useCarousel()
|
||||
const { scrollTo, selectedIndex, scrollSnaps, orientation } = useCarousel()
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="flex gap-2 justify-center">
|
||||
<div
|
||||
v-for="(_, index) in scrollSnaps"
|
||||
:key="index"
|
||||
class="border-1 w-2 h-2 rounded-full"
|
||||
:class="cn('flex gap-2 justify-center relative -translate-x-1/2 left-1/2', { 'top-10': orientation === 'vertical' }, props.class)"
|
||||
>
|
||||
<div
|
||||
v-for="(_, index) in scrollSnaps" :key="index" class="border-1 w-4 h-4 rounded-full"
|
||||
:class="cn(index === selectedIndex ? 'border-transparent bg-primary' : 'bg-border', props.class)"
|
||||
@click="scrollTo(index)"
|
||||
/>
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user