Skip to content

Commit 35b4582

Browse files
authored
Merge pull request #453 from rackerlabs/surf-1453-refactor-hx-checkbox
[^459] refactor(hx-checkbox): forms epic refactor hx-checkox and simplify
2 parents 99d2fe8 + ee3b3e2 commit 35b4582

File tree

13 files changed

+1812
-211
lines changed

13 files changed

+1812
-211
lines changed

docs/components/checkboxes/checkbox-demo.js

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -4,26 +4,28 @@ if (document.getElementById('vue-checkboxDemo')) {
44
new Vue({
55
el: '#vue-checkboxDemo',
66
data: {
7-
isChecked: true,
7+
isChecked: false,
88
isDisabled: false,
99
isIndeterminate: false,
10-
isInvalid: false,
11-
},
12-
methods: {
13-
onChange: function (evt) {
14-
this.isChecked = evt.currentTarget.checked;
15-
},
10+
isRequired: false,
11+
label: 'Check me out',
1612
},
1713
computed: {
1814
snippet: function () {
1915
return Util.snippet(`
20-
<hx-checkbox
21-
${this.isChecked ? 'checked' : ''}
22-
${this.isDisabled ? 'disabled' : ''}
23-
${this.isIndeterminate ? 'indeterminate' : ''}
24-
${this.isInvalid ? 'invalid' : ''}
25-
>
26-
</hx-checkbox>
16+
<hx-checkbox-control>
17+
<input
18+
type="checkbox"
19+
id="chkDemo"
20+
${this.isChecked ? 'checked' : ''}
21+
${this.isDisabled ? 'disabled' : ''}
22+
${this.isRequired ? 'required' : ''}
23+
/>
24+
<label for="chkDemo">
25+
<hx-checkbox></hx-checkbox>
26+
${this.label}
27+
</label>
28+
</hx-checkbox-control>
2729
`);
2830
},
2931
},

docs/components/checkboxes/index.html

Lines changed: 51 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -12,38 +12,66 @@ <h2 id="basic-checkbox">Basic Checkbox</h2>
1212
<div class="example" id="vue-checkboxDemo" v-cloak>
1313
<header>
1414
<form class="beta-hxForm">
15+
<p>
16+
<label for="txtLabel">Label</label>
17+
<input id="txtLabel" class="hxTextCtrl" v-model="label" />
18+
</p>
1519
<fieldset>
1620
<legend class="beta-hxFieldName">Options</legend>
17-
<div>
21+
<hx-checkbox-control>
1822
<input id="chkIsChecked" type="checkbox" v-model="isChecked" />
19-
<label for="chkIsChecked">Checked</label>
20-
</div>
21-
<div>
23+
<label for="chkIsChecked">
24+
<hx-checkbox></hx-checkbox>
25+
Checked
26+
</label>
27+
</hx-checkbox-control>
28+
<hx-checkbox-control>
2229
<input id="chkIsDisabled" type="checkbox" v-model="isDisabled" />
23-
<label for="chkIsDisabled">Disabled</label>
24-
</div>
25-
<div>
26-
<input id="chkIsIndeterminate" type="checkbox" v-model="isIndeterminate" />
27-
<label for="chkIsIndeterminate">Indeterminate</label>
28-
</div>
29-
<div>
30-
<input id="chkIsInvalid" type="checkbox" v-model="isInvalid" />
31-
<label for="chkIsInvalid">Invalid</label>
32-
</div>
30+
<label for="chkIsDisabled">
31+
<hx-checkbox></hx-checkbox>
32+
Disabled
33+
</label>
34+
</hx-checkbox-control>
35+
<hx-checkbox-control>
36+
<input id="chkIndeterminate" type="checkbox" v-model="isIndeterminate" />
37+
<label for="chkIndeterminate">
38+
<hx-checkbox></hx-checkbox>
39+
Indeterminate
40+
</label>
41+
{% raw %}
42+
<p>
43+
<code>
44+
(el.indeterminate = {{ isIndeterminate }})
45+
</code>
46+
</p>
47+
{% endraw %}
48+
</hx-checkbox-control>
49+
<hx-checkbox-control>
50+
<input id="chkRequired" type="checkbox" v-model="isRequired" />
51+
<label for="chkRequired">
52+
<hx-checkbox></hx-checkbox>
53+
Required
54+
</label>
55+
</hx-checkbox-control>
3356
</fieldset>
3457
</form>
3558
</header>
36-
3759
<div>
38-
<hx-checkbox
39-
:checked="isChecked"
40-
:disabled="isDisabled"
41-
:indeterminate="isIndeterminate"
42-
:invalid="isInvalid"
43-
@change="onChange"
44-
></hx-checkbox>
60+
<hx-checkbox-control>
61+
<input
62+
type="checkbox"
63+
id="chkDemo"
64+
:checked="isChecked"
65+
:disabled="isDisabled"
66+
:indeterminate.prop="isIndeterminate"
67+
:required="isRequired"
68+
/>
69+
<label for="chkDemo">
70+
<hx-checkbox></hx-checkbox>
71+
{% raw %}{{label}}{% endraw %}
72+
</label>
73+
</hx-checkbox-control>
4574
</div>
46-
4775
<footer>
4876
<pre><code v-text="snippet"></code></pre>
4977
</footer>

0 commit comments

Comments
 (0)