@@ -3,60 +3,69 @@ import { ref } from 'vue'
33import { FormKitMessages } from ' @formkit/vue'
44
55const form = ref (null )
6+ const showToast = ref (false )
67
78async function submitHandler (_data , node ) {
9+ showToast .value = false
810 await new Promise ((resolve ) => setTimeout (resolve, 1000 ))
911 node .setErrors ([
1012 ' Gambling is illegal.' ,
1113 ' Your crime has been reported to the authorities.' ,
1214 ])
15+ showToast .value = true
1316}
1417 </script >
1518
1619<template >
17- <FormKit type="form" @submit =" submitHandler " ref="form">
18- <FormKit
19- type="checkbox"
20- label="Soccer nations"
21- validation-label="countries"
22- :options =" [
23- ' 🇧🇷 Brazil' ,
24- ' 🇩🇪 Germany' ,
25- ' 🇮🇹 Italy' ,
26- ' 🇦🇷 Argentina' ,
27- ' 🇺🇾 Uruguay' ,
28- ' 🇫🇷 France' ,
29- ' 🏴 England' ,
30- ' 🇪🇸 Spain' ,
31- ] "
32- help="Which 4 countries will be in the semi finals of the next world cup?"
33- validation="required|*min:2 "
34- />
35- <FormKit
36- type="mask"
37- label="Bet amount"
38- :show-mask =" false "
39- mask="{#,##|repeat}{#.##}"
40- prefix="$"
41- reverse
42- unmask-value
43- allow-incomplete
44- validation="required|length:4 "
45- :validation-messages =" {
46- length: ' Minimum bet is $10.00' ,
47- } "
48- help="How much do you want to bet?"
49- />
50- </FormKit >
20+ <div class =" toast-demo" >
21+ <FormKit type="form" @submit =" submitHandler " ref="form">
22+ <FormKit
23+ type="checkbox"
24+ label="Soccer nations"
25+ validation-label="countries"
26+ :options =" [
27+ ' 🇧🇷 Brazil' ,
28+ ' 🇩🇪 Germany' ,
29+ ' 🇮🇹 Italy' ,
30+ ' 🇦🇷 Argentina' ,
31+ ' 🇺🇾 Uruguay' ,
32+ ' 🇫🇷 France' ,
33+ ' 🏴 England' ,
34+ ' 🇪🇸 Spain' ,
35+ ] "
36+ help="Which 4 countries will be in the semi finals of the next world cup?"
37+ validation="required|*min:2 "
38+ />
39+ <FormKit
40+ type="mask"
41+ label="Bet amount"
42+ :show-mask =" false "
43+ mask="{#,##|repeat}{#.##}"
44+ prefix="$"
45+ reverse
46+ unmask-value
47+ allow-incomplete
48+ validation="required|length:4 "
49+ :validation-messages =" {
50+ length: ' Minimum bet is $10.00' ,
51+ } "
52+ help="How much do you want to bet?"
53+ />
54+ </FormKit >
5155
52- <div class =" toast" >
53- <FormKitMessages :node =" form ?.node " />
56+ <div v-if =" showToast" class =" toast" >
57+ <FormKitMessages :node =" form ?.node " />
58+ </div >
5459 </div >
5560</template >
5661
5762<style scoped>
63+ .toast-demo {
64+ position : relative ;
65+ }
66+
5867.toast {
59- position : fixed ;
68+ position : absolute ;
6069 top : 0 ;
6170 right : 0 ;
6271 width : 300px ;
0 commit comments