Skip to content

Commit

Permalink
chore: add gallery modal example
Browse files Browse the repository at this point in the history
  • Loading branch information
serkodev committed Apr 9, 2024
1 parent 2966192 commit c6871a4
Show file tree
Hide file tree
Showing 7 changed files with 93 additions and 0 deletions.
3 changes: 3 additions & 0 deletions examples/modal-gallery/app.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<template>
<ModalPage />
</template>
4 changes: 4 additions & 0 deletions examples/modal-gallery/nuxt.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
// https://nuxt.com/docs/api/configuration/nuxt-config
export default defineNuxtConfig({
extends: '../base',
})
14 changes: 14 additions & 0 deletions examples/modal-gallery/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"private": true,
"type": "module",
"scripts": {
"build": "nuxt build",
"dev": "nuxt dev",
"generate": "nuxt generate",
"preview": "nuxt preview",
"postinstall": "nuxt prepare"
},
"dependencies": {
"nuxt": "^3.11.2"
}
}
23 changes: 23 additions & 0 deletions examples/modal-gallery/pages/gallery/[id].vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<script setup lang="ts">
const page = ref(Number.parseInt(useParentRoute().params.id as string) || 1)
const items = ref(Array(9))
watch(page, (page) => {
useModalRouter().push(`/gallery/${page}`)
})
</script>

<template>
<div>
<TheBoundary label="$__PAGES_PATH__" class="p-10 flex flex-col gap-8 justify-center items-center h-screen">
<div>This is the full detail page.</div>
<div class="flex size-64 items-center justify-center text-[88px] bg-green-400 text-black rounded-2xl">
{{ useParentRoute().params.id }}
</div>
<UPagination v-model="page" :page-count="1" :total="items.length" />
<NuxtLink to="/">
<UButton>Back index</UButton>
</NuxtLink>
</TheBoundary>
</div>
</template>
19 changes: 19 additions & 0 deletions examples/modal-gallery/pages/gallery/[id]@modal.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<script setup lang="ts">
const page = ref(Number.parseInt(useParentRoute().params.id as string) || 1)
const items = ref(Array(9))
watch(page, (page) => {
useModalRouter().push(`/gallery/${page}`)
})
</script>

<template>
<div>
<TheBoundary label="$__PAGES_PATH__" class="p-10 flex flex-col gap-8 justify-center items-center">
<div class="flex size-64 items-center justify-center text-[88px] bg-green-400 text-black rounded-2xl">
{{ useParentRoute().params.id }}
</div>
<UPagination v-model="page" :page-count="1" :total="items.length" />
</TheBoundary>
</div>
</template>
26 changes: 26 additions & 0 deletions examples/modal-gallery/pages/index.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<script setup lang="ts">
const { isOpen, open, close } = useNuxtApp().$modalRouter
</script>

<template>
<TheBoundary label="$__PAGES_PATH__" class="h-screen flex items-center justify-center">
<div class="grid grid-cols-3 gap-6">
<button v-for="i in 9" :key="i" class="size-32 items-center justify-center text-4xl bg-green-400 text-black rounded-xl" @click="open(`/gallery/${i}`)">
{{ i }}
</button>
</div>

<Teleport v-if="isOpen" to="body">
<div class="fixed top-0 left-0 w-full h-full bg-black/30 flex items-center justify-center">
<div class="border border-gray-800 p-6 rounded-lg space-y-3 backdrop-blur dark:bg-black/75 bg-white/75">
<div>After you refresh this page, the contacts id page will show up in full page.</div>
<div>You can use browser's back / next to navigate too.</div>
<ParallelPage name="modal" />
<UButton @click="close">
Close
</UButton>
</div>
</div>
</Teleport>
</TheBoundary>
</template>
4 changes: 4 additions & 0 deletions examples/modal-gallery/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
// https://nuxt.com/docs/guide/concepts/typescript
"extends": "./.nuxt/tsconfig.json"
}

0 comments on commit c6871a4

Please sign in to comment.