Skip to content

Commit d41399f

Browse files
committed
docs: completely rewrite docs to mention the new features
1 parent a3f57b1 commit d41399f

File tree

24 files changed

+486
-266
lines changed

24 files changed

+486
-266
lines changed

docs/app/components/AppHeader.vue

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,12 @@ const { header } = useAppConfig()
4040
>
4141
<NuxtLink
4242
:to="header?.to || '/'"
43-
class="font-bold text-xl"
43+
class="font-bold text-xl inline-flex items-center gap-2"
4444
>
4545
Nuxt Auto Form
46+
<UBadge variant="subtle" color="warning" size="sm">
47+
WIP
48+
</UBadge>
4649
</NuxtLink>
4750
</template>
4851

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
<script setup lang="ts">
2+
import { codeToHtml } from 'shiki'
3+
import { ref } from 'vue'
4+
5+
const props = defineProps<{ name: string }>()
6+
7+
const highlightedCode = ref('')
8+
9+
const modules = import.meta.glob('../components/examples/*.vue', { eager: true })
10+
const componentModule = modules[`./examples/${props.name}.vue`] as any
11+
12+
const rawModules = import.meta.glob('../components/examples/*.vue', {
13+
eager: true,
14+
as: 'raw',
15+
})
16+
const sourceCode = rawModules[`./examples/${props.name}.vue`]
17+
18+
highlightedCode.value = await codeToHtml(sourceCode!, { lang: 'vue', theme: 'material-theme-palenight' })
19+
</script>
20+
21+
<template>
22+
<div class="flex flex-col md:flex-row p-4 rounded-lg shadow-lg">
23+
<ProseCode class="leading-3 p-5">
24+
<code class="[&>pre]:bg-transparent!" v-html="highlightedCode" />
25+
</ProseCode>
26+
<div class="flex-1 p-4 bg-muted">
27+
<component :is="componentModule?.default" />
28+
</div>
29+
</div>
30+
</template>

docs/app/components/FormPreview.vue

Lines changed: 0 additions & 58 deletions
This file was deleted.

docs/app/components/Hero.vue

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
<template>
2+
<UPageHero orientation="horizontal" :ui="{ container: 'lg:py-30' }">
3+
<template #title>
4+
Nuxt Auto Form
5+
</template>
6+
<template #description>
7+
Build forms faster with tools you already know and love.
8+
Generate fully customizable Nuxt UI forms straight from your Zod schemas.
9+
</template>
10+
<template #links>
11+
<UButton size="xl" to="/getting-started" trailing-icon="i-lucide-arrow-right">
12+
Get started
13+
</UButton>
14+
<UButton size="xl" to="https://github.com/Norbiros/nuxt-auto-form" variant="subtle" trailing-icon="i-simple-icons-github" target="_blank" color="neutral">
15+
View source code
16+
</UButton>
17+
</template>
18+
19+
<ComponentPreview name="LandingSimple" class="leading-0" />
20+
</UPageHero>
21+
</template>
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
<script setup lang="ts">
2+
import * as z from 'zod'
3+
4+
const schema = z.object({
5+
form_field: z.string()
6+
.nonempty()
7+
.meta({
8+
title: 'Title',
9+
required: true,
10+
description: 'Description',
11+
hint: 'Hint',
12+
help: 'Help',
13+
}),
14+
input: z.number().meta({ input: {
15+
props: {
16+
placeholder: '69420',
17+
},
18+
} }),
19+
style: z.boolean()
20+
.meta({ autoForm: { floatRight: true } }),
21+
})
22+
</script>
23+
24+
<template>
25+
<AutoForm :schema="schema" />
26+
</template>
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<script setup lang="ts">
2+
import * as z from 'zod'
3+
4+
const schema = z.object({
5+
text: z.string().nonempty(),
6+
enum: z.enum(['1', '2', '3'])
7+
.meta({
8+
description: 'With description',
9+
}),
10+
custom_bool: z.boolean()
11+
.meta({ title: 'Title' }),
12+
})
13+
</script>
14+
15+
<template>
16+
<AutoForm :schema="schema" />
17+
</template>
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
<script setup lang="ts">
2+
import * as z from 'zod'
3+
4+
const schema = z.object({
5+
boolean: z.boolean(),
6+
})
7+
</script>
8+
9+
<template>
10+
<AutoForm :schema="schema">
11+
<template #boolean="{ field, state: stateValue }">
12+
<USelect
13+
v-model="stateValue[field]"
14+
:items="[
15+
{
16+
label: 'False Value',
17+
value: false,
18+
},
19+
{
20+
label: 'True Value',
21+
value: true,
22+
},
23+
]"
24+
/>
25+
</template>
26+
</AutoForm>
27+
</template>
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
<script setup lang="ts">
2+
import * as z from 'zod'
3+
4+
const schema = z.object({
5+
text: z.string()
6+
.nonempty()
7+
.meta({
8+
title: 'Text Input',
9+
required: true,
10+
input: {
11+
props: {
12+
placeholder: 'Placeholder',
13+
},
14+
},
15+
}),
16+
enum: z.enum(['1', '2', '3'])
17+
.meta({
18+
title: 'Enum Input',
19+
}),
20+
custom_bool: z.boolean()
21+
.meta({ title: 'Input with custom slot' }),
22+
})
23+
</script>
24+
25+
<template>
26+
<AutoForm :schema="schema" />
27+
</template>
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
<script setup lang="ts">
2+
import * as z from 'zod'
3+
4+
const schema = z.object({
5+
username: z.string().nonempty().meta({ title: 'Username' }),
6+
favoriteLanguage: z
7+
.enum(['JavaScript', 'TypeScript', 'Java', 'CoffeeScript'])
8+
.meta({
9+
title: 'Favorite Language',
10+
description: 'Choose wisely',
11+
}),
12+
yearsOfExperience: z.number().min(0).max(100),
13+
deployedOnFriday: z.boolean().default(true),
14+
text_description: z.string(),
15+
})
16+
</script>
17+
18+
<template>
19+
<AutoForm :schema="schema" />
20+
</template>

docs/app/pages/lol.vue

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<template>
2+
<div class="p-4">
3+
<ComponentPreview name="Test" />
4+
</div>
5+
</template>

0 commit comments

Comments
 (0)