Created
May 7, 2020 14:12
-
-
Save mimonelu/e23293d9d7e7966e8fc410e697daa211 to your computer and use it in GitHub Desktop.
vue-formulate-test
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<template> | |
<div id="app"> | |
<div class="column"> | |
<FormulateInput | |
type="checkbox" | |
label="I accept the terms of service?" | |
name="terms" | |
validation="accepted" | |
/> | |
<FormulateInput | |
type="date" | |
label="Select a time after the new year." | |
name="date" | |
validation="after:01/01/2021" | |
/> | |
<FormulateInput | |
type="text" | |
label="Enter your desired username" | |
name="username" | |
validation="alpha:latin" | |
/> | |
<FormulateInput | |
type="text" | |
label="Enter your desired username" | |
name="username" | |
validation="alphanumeric" | |
/> | |
<FormulateInput | |
type="date" | |
label="Select a time before the new year." | |
name="date" | |
validation="before:01/01/2021" | |
/> | |
<FormulateInput | |
type="range" | |
min="5" | |
max="35" | |
name="Age" | |
label="How old are you?" | |
validation="between:10,18" | |
error-behavior="live" | |
v-model="age" | |
/> | |
{{ age }} | |
<FormulateInput | |
label="New password" | |
type="password" | |
name="password" | |
validation="required" | |
/> | |
<FormulateInput | |
label="Confirm password" | |
type="password" | |
name="password_confirm" | |
validation="required|confirm" | |
validation-name="Password confirmation" | |
/> | |
<FormulateInput | |
type="text" | |
name="date" | |
label="Enter your birthday" | |
validation="date:MM/DD/YYYY" | |
/> | |
<FormulateInput | |
type="email" | |
name="email" | |
label="Enter your email address" | |
validation="email" | |
/> | |
<FormulateInput | |
type="text" | |
name="rhymes" | |
label="What rhymes with toad?" | |
validation="ends_with:oad,ode" | |
/> | |
<FormulateInput | |
type="select" | |
:options="{chocolate: 'Chocolate', vanilla: 'Vanilla', strawberry: 'Strawberry'}" | |
name="flavor" | |
label="Favorite ice cream flavor?" | |
placeholder="Select a flavor" | |
validation="in:chocolate,vanilla" | |
error-behavior="live" | |
/> | |
<FormulateInput | |
type="text" | |
name="color" | |
placeholder="#00ff00" | |
label="Enter a hexidecimal color value" | |
:validation="[['matches', /^#[a-fA-F0-9]{6}$/]]" | |
error-behavior="live" | |
v-model="color" | |
/> | |
<FormulateInput | |
type="color" | |
label="Or pick one" | |
v-model="color" | |
/> | |
</div> | |
<div class="column"> | |
<FormulateInput | |
type="text" | |
name="language" | |
placeholder="node, php, java..." | |
label="What is your favorite server side language?" | |
validation="matches:node,php,java" | |
error-behavior="live" | |
v-model="language" | |
/> | |
<FormulateInput | |
type="text" | |
name="coupon" | |
label="Enter a coupon code" | |
validation="max:5,length" | |
error-behavior="live" | |
/> | |
<FormulateInput | |
type="checkbox" | |
name="toppings" | |
:options="{ | |
pepperoni: 'Pepperoni', | |
sausage: 'Sausage', | |
olives: 'Olives', | |
feta: 'Feta', | |
mushrooms: 'Mushrooms', | |
}" | |
label="Select up to 3 pizza toppings" | |
validation="max:3" | |
error-behavior="live" | |
/> | |
<FormulateInput | |
type="file" | |
name="image" | |
label="Please select an image" | |
validation="mime:image/jpeg,image/png" | |
/> | |
<FormulateInput | |
type="text" | |
name="code" | |
label="Enter your SSN" | |
validation="min:9,length" | |
validation-name="Social security code" | |
error-behavior="live" | |
/> | |
<FormulateInput | |
type="text" | |
name="framework" | |
label="What is your favorite javascript framework?" | |
validation="not:jquery,ember,mootools" | |
error-behavior="live" | |
/> | |
<FormulateInput | |
type="text" | |
name="age" | |
label="How old are you?" | |
validation="number" | |
error-behavior="live" | |
/> | |
<FormulateInput | |
type="text" | |
name="city" | |
label="What city do you live in?" | |
validation="required" | |
error-behavior="live" | |
/> | |
<FormulateInput | |
type="text" | |
name="hashtag" | |
label="What's your favorite hashtag on Twitter?" | |
validation="starts_with:#" | |
/> | |
<FormulateInput | |
type="url" | |
name="url" | |
label="What is your website?" | |
validation="url" | |
error-behavior="live" | |
/> | |
</div> | |
</div> | |
</template> | |
<script> | |
import Vue from 'vue' | |
import VueFormulate from '@braid/vue-formulate' | |
import { ja } from '@braid/vue-formulate-i18n' | |
Vue.use(VueFormulate, { | |
plugins: [ | |
ja | |
], | |
locale: 'ja' | |
}) | |
export default { | |
name: 'App', | |
data () { | |
return { | |
age: 0, | |
color: '#ff0000', | |
language: 'ja' | |
} | |
} | |
} | |
</script> | |
<style> | |
@import '../node_modules/@braid/vue-formulate/dist/snow.min.css'; | |
* { | |
margin: 0; | |
padding: 0; | |
} | |
#app { | |
font-family: Avenir, Helvetica, Arial, sans-serif; | |
-webkit-font-smoothing: antialiased; | |
-moz-osx-font-smoothing: grayscale; | |
color: #2c3e50; | |
padding: 2rem; | |
display: flex; | |
} | |
.column { | |
flex-grow: 1; | |
} | |
.column:nth-child(2) { | |
margin-left: 2rem; | |
} | |
.formulate-input .formulate-input-element { | |
max-width: none; | |
} | |
</style> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thanks so much! This will help speed things up