Skip to content
This repository was archived by the owner on Apr 9, 2025. It is now read-only.

Commit 7369507

Browse files
authored
Merge pull request #43 from dbssman/feautre/42-docs-examples-2nd-batch
📄 Docs - Examples: 2nd batch #42
2 parents 4f29257 + 7bda1a9 commit 7369507

33 files changed

+5094
-20
lines changed

.vscode/extensions.json

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
11
{
2-
"recommendations": ["Vue.volar"]
3-
}
2+
"recommendations": [
3+
"Vue.volar",
4+
"Vue.vscode-typescript-vue-plugin"
5+
]
6+
}

docs/.vitepress/config.cts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,9 +51,6 @@ export default defineConfig({
5151
{ text: 'Async validations', link: '/examples/async-validations' },
5252
{ text: 'Basic', link: '/examples/basic' },
5353
{ text: 'Dependent fields', link: '/examples/dependent-fields' },
54-
{ text: 'Interceptor', link: '/examples/interceptor' },
55-
{ text: 'More examples', link: '/examples/more-examples' },
56-
{ text: 'Typescript', link: '/examples/typescript' },
5754
]
5855
},
5956
{

docs/components/SandboxEmbedder.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<template>
22
<iframe
33
:src="`https://codesandbox.io/embed/github/dbssman/vue-form-handler/tree/master/examples/${example}?fontsize=12&hidenavigation=1&theme=dark`"
4-
style="border:0;borderRadius:4;overflow:hidden" :style="styleObject"
4+
style="border:0;borderRadius:4;overflow:hidden;max-height:100vh" :style="styleObject"
55
:title="`dbssman/vue-form-handler: ${example}`"
66
allow="accelerometer; ambient-light-sensor; camera; encrypted-media; geolocation; gyroscope; hid; microphone; midi; payment; usb; vr; xr-spatial-tracking"
77
sandbox="allow-forms allow-modals allow-popups allow-presentation allow-same-origin allow-scripts"></iframe>

docs/examples/basic.md

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,8 @@
1-
# Basic Example
1+
---
2+
description: This example shows how use the handler in it's most basic way
3+
---
4+
# Basic
5+
6+
This example shows how use the handler in it's most basic way
7+
8+
<CodeExample example="basic"></CodeExample>

docs/examples/dependent-fields.md

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,8 @@
1-
# Dependent fields
1+
---
2+
description: This example shows set and reset values of fields based on the current value of other fields with the form handler
3+
---
4+
# Dependent fields
5+
6+
This example shows set and reset values of fields based on the current value of other fields with the form handler
7+
8+
<CodeExample example="dependent-fields"></CodeExample>

docs/examples/interceptor.md

Lines changed: 0 additions & 1 deletion
This file was deleted.

docs/examples/more-examples.md

Lines changed: 0 additions & 1 deletion
This file was deleted.

docs/examples/typescript.md

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

docs/get-started/quick-start.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ Welcome to the VueFormHandler tutorial. This will teach you everything you need
66

77
### What are we building?
88

9-
In this tutorial, we'll build a sign up form with Vue and VueFormHandler [Link here](somelink.com). If the code looks strange or you don't fully understand something, don't worry we'll go over this tutorial to help you understand how the handler works.
9+
In this tutorial, we'll build a sign up form with Vue and VueFormHandler [Link here](https://codesandbox.io/embed/github/dbssman/vue-form-handler/tree/master/examples/tutorial?fontsize=12&hidenavigation=0&theme=dark). If the code looks strange or you don't fully understand something, don't worry we'll go over this tutorial to help you understand how the handler works.
1010

1111
### Prerequisites
1212

examples/basic/App.vue

Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
<template>
2+
<section>
3+
<form @submit.prevent="handleSubmit(successFn)">
4+
<label>Email:
5+
<input type="email" v-bind="register('email')" />
6+
</label>
7+
<label> Password:
8+
<input type="password" v-bind="register('password')" />
9+
</label>
10+
<label> Confirm Password:
11+
<input type="password" v-bind="register('confirmPassword')" />
12+
</label>
13+
<button>Submit</button>
14+
</form>
15+
</section>
16+
</template>
17+
<script lang="ts" >
18+
import { useFormHandler } from 'vue-form-handler';
19+
20+
export default {
21+
setup: () => {
22+
const { register, handleSubmit } = useFormHandler({ validationMode: 'always' });
23+
const successFn = (form: Record<string, any>) => {
24+
console.log('Form correctly submitted:', form)
25+
}
26+
27+
return {
28+
register,
29+
handleSubmit,
30+
successFn,
31+
}
32+
}
33+
}
34+
35+
</script>
36+
37+
<style>
38+
* {
39+
box-sizing: border-box;
40+
margin: 0;
41+
padding: 0;
42+
text-align: center;
43+
}
44+
45+
body {
46+
display: flex;
47+
align-items: center;
48+
justify-content: center;
49+
background-color: #242424;
50+
font-family: 'Open Sans', sans-serif;
51+
font-size: 16px;
52+
color: #42B883;
53+
min-height: 100vh;
54+
}
55+
56+
label {
57+
display: block;
58+
}
59+
60+
form {
61+
display: flex;
62+
flex-direction: column;
63+
align-items: flex-end;
64+
gap: 1rem
65+
}
66+
67+
68+
69+
input,
70+
select,
71+
textarea,
72+
button {
73+
border: none;
74+
border-radius: 5px;
75+
width: 300px;
76+
min-height: 40px;
77+
background-color: #35495E;
78+
color: #42B883;
79+
}
80+
81+
button {
82+
background-color: #42B883;
83+
color: #35495E;
84+
cursor: pointer;
85+
text-transform: uppercase;
86+
font-weight: bold;
87+
}
88+
</style>

0 commit comments

Comments
 (0)