11< div >
2- < div id ="boolean-toggles-id ">
3- < h2 > Checkbox</ h2 >
4- < input type ="checkbox " unicorn:model ="is_checked " id ="check ">
5- {% if is_checked %}Yes! 🦄{% else %}Nope 🙁{% endif %}
6- </ div >
7-
8- < div unicorn:key ="boolean-toggles-key ">
9- < h2 > Boolean Toggles</ h2 >
10- {% if another_check %}Checked ✅{% else %}Not checked ❎{% endif %}
11- < br />
12- < button unicorn:click ="$toggle('is_checked', 'another_check') "> Toggle booleans (normal)</ button > < br />
13- < button unicorn:click ="$toggle('is_checked', 'another_check') " u:partial.key ="boolean-toggles-key "> Toggle booleans (partial.key)</ button >
14- < button unicorn:click ="$toggle('is_checked', 'another_check') " u:partial.id ="boolean-toggles-id "> Toggle booleans (partial.id)</ button > < br />
15- < button unicorn:click ="$toggle('is_checked', 'another_check') " u:partial.id ="boolean-toggles-id " u:partial.key ="boolean-toggles-key "> Toggle booleans (multiple partials)</ button > < br />
16- < button unicorn:click ="$toggle('is_checked', 'another_check') " u:partial ="boolean-toggles-id "> Toggle booleans (partial boolean-toggles-id)</ button >
17- < button unicorn:click ="$toggle('is_checked', 'another_check') " u:partial ="boolean-toggles-key "> Toggle booleans (partial boolean-toggles-key)</ button >
18- </ div >
19-
20- < div >
21- < h2 > Select</ h2 >
22- < select unicorn:model ="thing " id ="select ">
23- < option > 🐶</ option >
24- < option > 🐙</ option >
25- < option > 👾</ option >
26- </ select >
27-
28- < p >
29- Hi {{ thing }}
30- </ p >
31- </ div >
32-
33- < div >
34- < h2 > Multiple select</ h2 >
35- < select unicorn:model ="things " id ="select-multiple " multiple >
36- < option value ="doggo "> 🐶</ option >
37- < option value ="octopus "> 🐙</ option >
38- < option value ="alien "> 👾</ option >
39- </ select >
40-
41- < p >
42- Howdy {{ things|join:", " }}
43- </ p >
44- </ div >
45-
46- < div >
47- < h2 > Radio buttons</ h2 >
48- < input type ="radio " unicorn:model ="pie " name ="pie " value ="blueberry "> Blueberry</ input > < br />
49- < input type ="radio " unicorn:model ="pie " name ="pie " value ="apple "> Apple</ input > < br />
50- < input type ="radio " unicorn:model ="pie " name ="pie " value ="cherry "> Cherry</ input >
51-
52- < p >
53- Delicious {{ pie|upper }} pie
54- </ p >
55- </ div >
56-
57- < div >
58- < h2 > Textarea</ h2 >
59- < textarea unicorn:model ="paragraph " id ="textarea "> </ textarea >
60-
61- < p >
62- Number of characters: {{ paragraph|length }}
63-
64- < button unicorn:click ="paragraph='' "> Clear textarea</ button >
65- </ p >
66- </ div >
67-
68- < div >
69- < h2 > Typeahead</ h2 >
70- < input type ="text " unicorn:model ="state " placeholder ="State name " id ="typeahead "> </ input >
71-
72- < p >
73- Matching states:
74-
75- {% if states %}
76- < ul >
77- {% for s in states %}
78- < li > {{ s }}</ li >
79- {% endfor %}
80- </ ul >
81-
82- < button unicorn:click ="clear_states "> Clear States</ button >
83- {% endif %}
84- </ p >
85- </ div >
86- </ div >
2+ < div id ="boolean-toggles-id ">
3+ < h2 > Checkbox</ h2 >
4+ < input type ="checkbox " unicorn:model ="is_checked " id ="check ">
5+ {% if is_checked %}Yes! 🦄{% else %}Nope 🙁{% endif %}
6+ </ div >
7+
8+ < div unicorn:key ="boolean-toggles-key ">
9+ < h2 > Boolean Toggles</ h2 >
10+ {% if another_check %}Checked ✅{% else %}Not checked ❎{% endif %}
11+ < br />
12+ < button unicorn:click ="$toggle('is_checked', 'another_check') "> Toggle booleans (normal)</ button > < br />
13+ < button unicorn:click ="$toggle('is_checked', 'another_check') " u:partial.key ="boolean-toggles-key "> Toggle booleans
14+ (partial.key)</ button >
15+ < button unicorn:click ="$toggle('is_checked', 'another_check') " u:partial.id ="boolean-toggles-id "> Toggle booleans
16+ (partial.id)</ button > < br />
17+ < button unicorn:click ="$toggle('is_checked', 'another_check') " u:partial.id ="boolean-toggles-id "
18+ u:partial.key ="boolean-toggles-key "> Toggle booleans (multiple partials)</ button > < br />
19+ < button unicorn:click ="$toggle('is_checked', 'another_check') " u:partial ="boolean-toggles-id "> Toggle booleans
20+ (partial boolean-toggles-id)</ button >
21+ < button unicorn:click ="$toggle('is_checked', 'another_check') " u:partial ="boolean-toggles-key "> Toggle booleans
22+ (partial boolean-toggles-key)</ button >
23+ </ div >
24+
25+ < div >
26+ < h2 > Select</ h2 >
27+ < select unicorn:model ="thing " id ="select ">
28+ < option > 🐶</ option >
29+ < option > 🐙</ option >
30+ < option > 👾</ option >
31+ </ select >
32+
33+ < p >
34+ Hi {{ thing }}
35+ </ p >
36+ </ div >
37+
38+ < div >
39+ < h2 > Default Select</ h2 >
40+ < select unicorn:model ="flavor " id ="select-default ">
41+ < option value ="cool "> cool</ option >
42+ < option value =""> -- select --</ option >
43+ {% for flavor in flavors %}
44+ < option value ="{{ flavor }} "> {{ flavor }}</ option >
45+ {% endfor %}
46+ </ select >
47+
48+ < p >
49+ Hi {{ flavor }}
50+ </ p >
51+ </ div >
52+
53+ < div >
54+ < h2 > Multiple select</ h2 >
55+ < select unicorn:model ="things " id ="select-multiple " multiple >
56+ < option value ="doggo "> 🐶</ option >
57+ < option value ="octopus "> 🐙</ option >
58+ < option value ="alien "> 👾</ option >
59+ </ select >
60+
61+ < p >
62+ Howdy {{ things|join:", " }}
63+ </ p >
64+ </ div >
65+
66+ < div >
67+ < h2 > Radio buttons</ h2 >
68+ < input type ="radio " unicorn:model ="pie " name ="pie " value ="blueberry "> Blueberry</ input > < br />
69+ < input type ="radio " unicorn:model ="pie " name ="pie " value ="apple "> Apple</ input > < br />
70+ < input type ="radio " unicorn:model ="pie " name ="pie " value ="cherry "> Cherry</ input >
71+
72+ < p >
73+ Delicious {{ pie|upper }} pie
74+ </ p >
75+ </ div >
76+
77+ < div >
78+ < h2 > Textarea</ h2 >
79+ < textarea unicorn:model ="paragraph " id ="textarea "> </ textarea >
80+
81+ < p >
82+ Number of characters: {{ paragraph|length }}
83+
84+ < button unicorn:click ="paragraph='' "> Clear textarea</ button >
85+ </ p >
86+ </ div >
87+
88+ < div >
89+ < h2 > Typeahead</ h2 >
90+ < input type ="text " unicorn:model ="state " placeholder ="State name " id ="typeahead "> </ input >
91+
92+ < p >
93+ Matching states:
94+
95+ {% if states %}
96+ < ul >
97+ {% for s in states %}
98+ < li > {{ s }}</ li >
99+ {% endfor %}
100+ </ ul >
101+
102+ < button unicorn:click ="clear_states "> Clear States</ button >
103+ {% endif %}
104+ </ p >
105+ </ div >
106+ </ div >
0 commit comments