-
Notifications
You must be signed in to change notification settings - Fork 4
🚸 Add nav arrows in carousel modal #655
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -59,7 +59,7 @@ | |
| <UModal | ||
| v-model:open="isModalOpen" | ||
| :ui="{ | ||
| content: 'max-w-4xl bg-black', | ||
| content: 'relative max-w-4xl bg-black', | ||
| }" | ||
| :close="{ color: 'neutral', variant: 'ghost', class: 'text-white' }" | ||
| > | ||
|
|
@@ -91,6 +91,25 @@ | |
| playsinline | ||
| class="w-full max-h-[80vh]" | ||
| /> | ||
|
|
||
| <template v-if="carouselItems.length > 1"> | ||
| <UButton | ||
| icon="i-material-symbols-chevron-left" | ||
| color="neutral" | ||
| variant="ghost" | ||
| aria-label="Previous" | ||
| class="absolute left-2 top-1/2 -translate-y-1/2 rounded-full bg-black/50 text-white hover:bg-black/70 cursor-pointer" | ||
| @click="navigateModal(-1)" | ||
| /> | ||
| <UButton | ||
| icon="i-material-symbols-chevron-right" | ||
| color="neutral" | ||
| variant="ghost" | ||
| aria-label="Next" | ||
| class="absolute right-2 top-1/2 -translate-y-1/2 rounded-full bg-black/50 text-white hover:bg-black/70 cursor-pointer" | ||
| @click="navigateModal(1)" | ||
| /> | ||
| </template> | ||
| </template> | ||
| </UModal> | ||
| </div> | ||
|
|
@@ -141,13 +160,20 @@ const props = defineProps({ | |
| }) | ||
|
|
||
| const isModalOpen = ref(false) | ||
| const modalItem = ref<CarouselItem | null>(null) | ||
| const modalItemIndex = ref(0) | ||
| const modalItem = computed(() => carouselItems.value[modalItemIndex.value] || null) | ||
|
|
||
| function openModal(item: CarouselItem) { | ||
| modalItem.value = item | ||
| const index = carouselItems.value.indexOf(item) | ||
| modalItemIndex.value = index >= 0 ? index : 0 | ||
| isModalOpen.value = true | ||
| } | ||
|
|
||
| function navigateModal(direction: number) { | ||
| const len = carouselItems.value.length | ||
| modalItemIndex.value = (modalItemIndex.value + direction + len) % len | ||
| } | ||
|
Comment on lines
+172
to
+175
|
||
|
|
||
| const carouselItems = computed<CarouselItem[]>(() => { | ||
| const items: CarouselItem[] = [] | ||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The cursor-pointer class is redundant for UButton components as buttons already have pointer cursor by default. This is a minor styling nit and doesn't affect functionality.