fix: prevent page zoom while tapping carousel buttons (#274)
* fix: prevent page zoom while tapping carousel buttons choose shadcn-ui icons and sizes for buttons * docs: fix carousel page responsive issues and ordering docs as shadcn-ui
This commit is contained in:
parent
72857b6a56
commit
c33acba4ff
|
|
@ -52,7 +52,7 @@ const { style } = useConfigStore()
|
|||
</div>
|
||||
</div>
|
||||
<div
|
||||
:class="cn('preview flex min-h-[350px] w-full justify-center p-6 lg:p-10', {
|
||||
:class="cn('preview flex min-h-[350px] w-full justify-center p-10 items-center', {
|
||||
'items-center': align === 'center',
|
||||
'items-start': align === 'start',
|
||||
'items-end': align === 'end',
|
||||
|
|
|
|||
|
|
@ -48,18 +48,6 @@ import {
|
|||
|
||||
## Examples
|
||||
|
||||
### Orientation
|
||||
|
||||
Use the `orientation` prop to set the orientation of the carousel.
|
||||
|
||||
<ComponentPreview name="CarouselOrientation" />
|
||||
|
||||
```vue
|
||||
<Carousel orientation="vertical | horizontal">
|
||||
...
|
||||
</Carousel>
|
||||
```
|
||||
|
||||
### Sizes
|
||||
|
||||
To set the size of the items, you can use the `basis` utility class on the `<CarouselItem />`.
|
||||
|
|
@ -151,6 +139,17 @@ Responsive
|
|||
</template>
|
||||
```
|
||||
|
||||
### Orientation
|
||||
|
||||
Use the `orientation` prop to set the orientation of the carousel.
|
||||
|
||||
<ComponentPreview name="CarouselOrientation" />
|
||||
|
||||
```vue
|
||||
<Carousel orientation="vertical | horizontal">
|
||||
...
|
||||
</Carousel>
|
||||
```
|
||||
|
||||
## Options
|
||||
|
||||
|
|
|
|||
|
|
@ -27,8 +27,8 @@ watchOnce(api, (api) => {
|
|||
</script>
|
||||
|
||||
<template>
|
||||
<div class="flex flex-col items-center space-x-2">
|
||||
<Carousel class="w-full max-w-xs" @init-api="setApi">
|
||||
<div class="w-full sm:w-auto">
|
||||
<Carousel class="relative w-full max-w-xs" @init-api="setApi">
|
||||
<CarouselContent>
|
||||
<CarouselItem v-for="(_, index) in 5" :key="index">
|
||||
<div class="p-1">
|
||||
|
|
|
|||
|
|
@ -4,8 +4,7 @@ import { Card, CardContent } from '@/lib/registry/default/ui/card'
|
|||
</script>
|
||||
|
||||
<template>
|
||||
<div class="flex items-center space-x-2">
|
||||
<Carousel class="w-full max-w-xs">
|
||||
<Carousel class="relative w-full max-w-xs">
|
||||
<CarouselContent>
|
||||
<CarouselItem v-for="(_, index) in 5" :key="index">
|
||||
<div class="p-1">
|
||||
|
|
@ -20,5 +19,4 @@ import { Card, CardContent } from '@/lib/registry/default/ui/card'
|
|||
<CarouselPrevious />
|
||||
<CarouselNext />
|
||||
</Carousel>
|
||||
</div>
|
||||
</template>
|
||||
|
|
|
|||
|
|
@ -4,10 +4,9 @@ import { Card, CardContent } from '@/lib/registry/default/ui/card'
|
|||
</script>
|
||||
|
||||
<template>
|
||||
<div class="w-1/2">
|
||||
<Carousel
|
||||
orientation="vertical"
|
||||
class="w-full max-w-xs"
|
||||
class="relative w-full max-w-xsw-full max-w-xs"
|
||||
:opts="{
|
||||
align: 'start',
|
||||
}"
|
||||
|
|
@ -26,5 +25,4 @@ import { Card, CardContent } from '@/lib/registry/default/ui/card'
|
|||
<CarouselPrevious />
|
||||
<CarouselNext />
|
||||
</Carousel>
|
||||
</div>
|
||||
</template>
|
||||
|
|
|
|||
|
|
@ -11,9 +11,8 @@ const plugin = Autoplay({
|
|||
</script>
|
||||
|
||||
<template>
|
||||
<div class="flex items-center space-x-2">
|
||||
<Carousel
|
||||
class="w-full max-w-xs"
|
||||
class="relative w-full max-w-xs"
|
||||
:plugins="[plugin]"
|
||||
@mouseenter="plugin.stop"
|
||||
@mouseleave="[plugin.reset(), plugin.play(), console.log('Runing')];"
|
||||
|
|
@ -32,5 +31,4 @@ const plugin = Autoplay({
|
|||
<CarouselPrevious />
|
||||
<CarouselNext />
|
||||
</Carousel>
|
||||
</div>
|
||||
</template>
|
||||
|
|
|
|||
|
|
@ -4,9 +4,8 @@ import { Card, CardContent } from '@/lib/registry/default/ui/card'
|
|||
</script>
|
||||
|
||||
<template>
|
||||
<div class="flex items-center space-x-2">
|
||||
<Carousel
|
||||
class="w-full max-w-xs"
|
||||
class="relative w-full max-w-sm"
|
||||
:opts="{
|
||||
align: 'start',
|
||||
}"
|
||||
|
|
@ -25,5 +24,4 @@ import { Card, CardContent } from '@/lib/registry/default/ui/card'
|
|||
<CarouselPrevious />
|
||||
<CarouselNext />
|
||||
</Carousel>
|
||||
</div>
|
||||
</template>
|
||||
|
|
|
|||
|
|
@ -4,9 +4,8 @@ import { Card, CardContent } from '@/lib/registry/default/ui/card'
|
|||
</script>
|
||||
|
||||
<template>
|
||||
<div class="flex items-center space-x-2">
|
||||
<Carousel
|
||||
class="w-full max-w-sm"
|
||||
class="relative w-full max-w-sm"
|
||||
:opts="{
|
||||
align: 'start',
|
||||
}"
|
||||
|
|
@ -25,5 +24,4 @@ import { Card, CardContent } from '@/lib/registry/default/ui/card'
|
|||
<CarouselPrevious />
|
||||
<CarouselNext />
|
||||
</Carousel>
|
||||
</div>
|
||||
</template>
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
<script setup lang="ts">
|
||||
import { ChevronRight } from 'lucide-vue-next'
|
||||
import { ArrowRight } from 'lucide-vue-next'
|
||||
import { useCarousel } from './useCarousel'
|
||||
import type { WithClassAsProps } from './interface'
|
||||
import { cn } from '@/lib/utils'
|
||||
|
|
@ -14,7 +14,7 @@ const { orientation, canScrollNext, scrollNext } = useCarousel()
|
|||
<Button
|
||||
:disabled="!canScrollNext"
|
||||
:class="cn(
|
||||
'absolute h-10 w-10 rounded-full p-0',
|
||||
'touch-manipulation absolute h-8 w-8 rounded-full p-0',
|
||||
orientation === 'horizontal'
|
||||
? '-right-12 top-1/2 -translate-y-1/2'
|
||||
: '-bottom-12 left-1/2 -translate-x-1/2 rotate-90',
|
||||
|
|
@ -24,7 +24,7 @@ const { orientation, canScrollNext, scrollNext } = useCarousel()
|
|||
@click="scrollNext"
|
||||
>
|
||||
<slot>
|
||||
<ChevronRight class="h-4 w-4 text-current" />
|
||||
<ArrowRight class="h-4 w-4 text-current" />
|
||||
</slot>
|
||||
</Button>
|
||||
</template>
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
<script setup lang="ts">
|
||||
import { ChevronLeft } from 'lucide-vue-next'
|
||||
import { ArrowLeft } from 'lucide-vue-next'
|
||||
import { useCarousel } from './useCarousel'
|
||||
import type { WithClassAsProps } from './interface'
|
||||
import { cn } from '@/lib/utils'
|
||||
|
|
@ -14,7 +14,7 @@ const { orientation, canScrollPrev, scrollPrev } = useCarousel()
|
|||
<Button
|
||||
:disabled="!canScrollPrev"
|
||||
:class="cn(
|
||||
'absolute h-10 w-10 rounded-full p-0',
|
||||
'touch-manipulation absolute h-8 w-8 rounded-full p-0',
|
||||
orientation === 'horizontal'
|
||||
? '-left-12 top-1/2 -translate-y-1/2'
|
||||
: '-top-12 left-1/2 -translate-x-1/2 rotate-90',
|
||||
|
|
@ -24,7 +24,7 @@ const { orientation, canScrollPrev, scrollPrev } = useCarousel()
|
|||
@click="scrollPrev"
|
||||
>
|
||||
<slot>
|
||||
<ChevronLeft class="h-4 w-4 text-current" />
|
||||
<ArrowLeft class="h-4 w-4 text-current" />
|
||||
</slot>
|
||||
</Button>
|
||||
</template>
|
||||
|
|
|
|||
|
|
@ -27,8 +27,8 @@ watchOnce(api, (api) => {
|
|||
</script>
|
||||
|
||||
<template>
|
||||
<div class="flex flex-col items-center space-x-2">
|
||||
<Carousel class="w-full max-w-xs" @init-api="setApi">
|
||||
<div class="w-full sm:w-auto">
|
||||
<Carousel class="relative w-full max-w-xs" @init-api="setApi">
|
||||
<CarouselContent>
|
||||
<CarouselItem v-for="(_, index) in 5" :key="index">
|
||||
<div class="p-1">
|
||||
|
|
|
|||
|
|
@ -4,8 +4,7 @@ import { Card, CardContent } from '@/lib/registry/new-york/ui/card'
|
|||
</script>
|
||||
|
||||
<template>
|
||||
<div class="flex items-center space-x-2">
|
||||
<Carousel class="w-full max-w-xs">
|
||||
<Carousel class="relative w-full max-w-xs">
|
||||
<CarouselContent>
|
||||
<CarouselItem v-for="(_, index) in 5" :key="index">
|
||||
<div class="p-1">
|
||||
|
|
@ -20,5 +19,4 @@ import { Card, CardContent } from '@/lib/registry/new-york/ui/card'
|
|||
<CarouselPrevious />
|
||||
<CarouselNext />
|
||||
</Carousel>
|
||||
</div>
|
||||
</template>
|
||||
|
|
|
|||
|
|
@ -4,10 +4,9 @@ import { Card, CardContent } from '@/lib/registry/new-york/ui/card'
|
|||
</script>
|
||||
|
||||
<template>
|
||||
<div class="w-1/2">
|
||||
<Carousel
|
||||
orientation="vertical"
|
||||
class="w-full max-w-xs"
|
||||
class="relative w-full max-w-xs"
|
||||
:opts="{
|
||||
align: 'start',
|
||||
}"
|
||||
|
|
@ -26,5 +25,4 @@ import { Card, CardContent } from '@/lib/registry/new-york/ui/card'
|
|||
<CarouselPrevious />
|
||||
<CarouselNext />
|
||||
</Carousel>
|
||||
</div>
|
||||
</template>
|
||||
|
|
|
|||
|
|
@ -11,9 +11,8 @@ const plugin = Autoplay({
|
|||
</script>
|
||||
|
||||
<template>
|
||||
<div class="flex items-center space-x-2">
|
||||
<Carousel
|
||||
class="w-full max-w-xs"
|
||||
class="relative w-full max-w-xs"
|
||||
:plugins="[plugin]"
|
||||
@mouseenter="plugin.stop"
|
||||
@mouseleave="[plugin.reset(), plugin.play(), console.log('Runing')];"
|
||||
|
|
@ -32,5 +31,4 @@ const plugin = Autoplay({
|
|||
<CarouselPrevious />
|
||||
<CarouselNext />
|
||||
</Carousel>
|
||||
</div>
|
||||
</template>
|
||||
|
|
|
|||
|
|
@ -4,9 +4,8 @@ import { Card, CardContent } from '@/lib/registry/new-york/ui/card'
|
|||
</script>
|
||||
|
||||
<template>
|
||||
<div class="flex items-center space-x-2">
|
||||
<Carousel
|
||||
class="w-full max-w-xs"
|
||||
class="relative w-full max-w-xs"
|
||||
:opts="{
|
||||
align: 'start',
|
||||
}"
|
||||
|
|
@ -25,5 +24,4 @@ import { Card, CardContent } from '@/lib/registry/new-york/ui/card'
|
|||
<CarouselPrevious />
|
||||
<CarouselNext />
|
||||
</Carousel>
|
||||
</div>
|
||||
</template>
|
||||
|
|
|
|||
|
|
@ -4,7 +4,6 @@ import { Card, CardContent } from '@/lib/registry/new-york/ui/card'
|
|||
</script>
|
||||
|
||||
<template>
|
||||
<div class="flex items-center space-x-2">
|
||||
<Carousel
|
||||
class="w-full max-w-sm"
|
||||
:opts="{
|
||||
|
|
@ -25,5 +24,4 @@ import { Card, CardContent } from '@/lib/registry/new-york/ui/card'
|
|||
<CarouselPrevious />
|
||||
<CarouselNext />
|
||||
</Carousel>
|
||||
</div>
|
||||
</template>
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
<script setup lang="ts">
|
||||
import { ChevronRightIcon } from '@radix-icons/vue'
|
||||
import { ArrowRightIcon } from '@radix-icons/vue'
|
||||
import { useCarousel } from './useCarousel'
|
||||
import type { WithClassAsProps } from './interface'
|
||||
import { cn } from '@/lib/utils'
|
||||
|
|
@ -14,7 +14,7 @@ const { orientation, canScrollNext, scrollNext } = useCarousel()
|
|||
<Button
|
||||
:disabled="!canScrollNext"
|
||||
:class="cn(
|
||||
'absolute h-10 w-10 rounded-full p-0',
|
||||
'touch-manipulation absolute h-8 w-8 rounded-full p-0',
|
||||
orientation === 'horizontal'
|
||||
? '-right-12 top-1/2 -translate-y-1/2'
|
||||
: '-bottom-12 left-1/2 -translate-x-1/2 rotate-90',
|
||||
|
|
@ -24,7 +24,7 @@ const { orientation, canScrollNext, scrollNext } = useCarousel()
|
|||
@click="scrollNext"
|
||||
>
|
||||
<slot>
|
||||
<ChevronRightIcon class="h-4 w-4 text-current" />
|
||||
<ArrowRightIcon class="h-4 w-4 text-current" />
|
||||
</slot>
|
||||
</Button>
|
||||
</template>
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
<script setup lang="ts">
|
||||
import { ChevronLeftIcon } from '@radix-icons/vue'
|
||||
import { ArrowLeftIcon } from '@radix-icons/vue'
|
||||
import { useCarousel } from './useCarousel'
|
||||
import type { WithClassAsProps } from './interface'
|
||||
import { cn } from '@/lib/utils'
|
||||
|
|
@ -14,7 +14,7 @@ const { orientation, canScrollPrev, scrollPrev } = useCarousel()
|
|||
<Button
|
||||
:disabled="!canScrollPrev"
|
||||
:class="cn(
|
||||
'absolute h-10 w-10 rounded-full p-0',
|
||||
'touch-manipulation absolute h-8 w-8 rounded-full p-0',
|
||||
orientation === 'horizontal'
|
||||
? '-left-12 top-1/2 -translate-y-1/2'
|
||||
: '-top-12 left-1/2 -translate-x-1/2 rotate-90',
|
||||
|
|
@ -24,7 +24,7 @@ const { orientation, canScrollPrev, scrollPrev } = useCarousel()
|
|||
@click="scrollPrev"
|
||||
>
|
||||
<slot>
|
||||
<ChevronLeftIcon class="h-4 w-4 text-current" />
|
||||
<ArrowLeftIcon class="h-4 w-4 text-current" />
|
||||
</slot>
|
||||
</Button>
|
||||
</template>
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user