Skip to content

Commit 6a19b13

Browse files
committed
feat: add QR code modal example
1 parent 3efc959 commit 6a19b13

File tree

3 files changed

+44
-1
lines changed

3 files changed

+44
-1
lines changed

docs/app/components/ComponentPreview.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ highlightedCode.value = await codeToHtml(sourceCode!, { lang: 'vue', theme: 'mat
2020

2121
<template>
2222
<div class="flex flex-col md:flex-row p-4 rounded-lg shadow-lg">
23-
<ProseCode class="p-5">
23+
<ProseCode class="w-3/5 overflow-auto">
2424
<div class="[&>pre]:bg-transparent! [&_.line]:inline-block!" v-html="highlightedCode" />
2525
</ProseCode>
2626
<div class="flex-1 p-4 bg-muted">
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
<script setup lang="ts">
2+
import * as z from 'zod'
3+
4+
const schema = z.object({
5+
code: z.array(z.string({ error: 'Kod do rejestracji jest wymagany' })).length(6, 'Kod do rejestracji musi mieć 6 znaków'),
6+
})
7+
8+
const open = defineModel<boolean>()
9+
const formRef = useTemplateRef('form')
10+
11+
async function onSubmit(event: z.infer<typeof schema>) {
12+
useToast().add({ title: 'Code', description: event.code.join(''), color: 'success' })
13+
open.value = false
14+
}
15+
</script>
16+
17+
<template>
18+
<UModal v-model:open="open" title="QR code" :ui="{ footer: 'justify-end' }">
19+
<UButton label="Open" color="neutral" variant="subtle" />
20+
21+
<template #body>
22+
<AutoForm ref="form" :schema="schema" :config="{ submit: false }" @submit="onSubmit">
23+
<template #code="{ field, state: stateValue }">
24+
<div class="flex items-center space-x-2">
25+
<UPinInput v-model="stateValue[field]" class="mr-5" :length="6" />
26+
<UButton icon="lucide:qr-code" @click="stateValue[field] = '123123'.split('')" />
27+
</div>
28+
</template>
29+
</AutoForm>
30+
</template>
31+
32+
<template #footer>
33+
<UButton label="Close" color="neutral" variant="outline" @click="open = false" />
34+
<UButton label="Send" @click="formRef?.submit()" />
35+
</template>
36+
</UModal>
37+
</template>

docs/content/3.components/1.form.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,4 +113,10 @@ See [Slots](/customization/slots) for details
113113
For real world use cases, checkout out the [Hack4KrakSite](https://github.com/search?q=repo%3AHack4Krak%2FHack4KrakSite%20AutoForm&type=code) project.
114114
::
115115

116+
### Complex real world example
117+
116118
::component-preview{name="RealWorld"}
119+
120+
### Custom slots & modals
121+
122+
::component-preview{name="Qr"}

0 commit comments

Comments
 (0)