add checkboxgroup and rename radio to radiogroup

This commit is contained in:
Keegan
2016-02-14 15:22:36 -08:00
parent 9c929a2e43
commit 1180bf2abc
12 changed files with 235 additions and 47 deletions
+12
View File
@@ -0,0 +1,12 @@
'use strict';
module.exports = {
name: 'checkboxgroup',
template: require('../../templates/components/checkboxgroup.tpl'),
style: require('../../styles/clay/components/checkboxgroup.scss'),
manipulator: 'checkboxgroup',
defaults: {
label: '',
options: []
}
};
+2 -1
View File
@@ -9,5 +9,6 @@ module.exports = {
submit: require('./submit'),
text: require('./text'),
toggle: require('./toggle'),
radio: require('./radio')
radiogroup: require('./radiogroup'),
checkboxgroup: require('./checkboxgroup')
};
-12
View File
@@ -1,12 +0,0 @@
'use strict';
module.exports = {
name: 'radio',
template: require('../../templates/components/radio.tpl'),
style: require('../../styles/clay/components/radio.scss'),
manipulator: 'radio',
defaults: {
label: '',
options: []
}
};
+12
View File
@@ -0,0 +1,12 @@
'use strict';
module.exports = {
name: 'radiogroup',
template: require('../../templates/components/radiogroup.tpl'),
style: require('../../styles/clay/components/radiogroup.scss'),
manipulator: 'radiogroup',
defaults: {
label: '',
options: []
}
};
+23 -1
View File
@@ -48,7 +48,7 @@ module.exports = {
disable: disable,
enable: enable
},
radio: {
radiogroup: {
get: function() {
return this.$element.select('input:checked').get('value');
},
@@ -61,6 +61,28 @@ module.exports = {
disable: disable,
enable: enable
},
checkboxgroup: {
get: function() {
var result = [];
this.$element.select('input:checked').each(function(item) {
result.push(item.value);
});
return result;
},
set: function(values) {
var self = this;
self.$element.select('input').set('checked', false);
values = values || [];
values.map(function(value) {
self.$element
.select('input[value="' + value.replace('"', '\\"') + '"]')
.set('checked', true);
});
return self.trigger('change');
},
disable: disable,
enable: enable
},
color: {
get: function() {
return parseInt(this.$manipulatorTarget.get('value'), 16);
@@ -0,0 +1,63 @@
@import "bourbon";
@import "clay";
.component-checkbox {
@include tap-highlight(rgba(0,0,0,0));
display: block;
> .label {
display: block;
padding-bottom: $item-spacing-v / 2;
}
.checkbox-group {
label {
padding: $item-spacing-v / 2 0;
@include tap-highlight();
}
.label {
font-size: 0.9em;
padding: 0 $item-spacing-h / 2;
}
input {
display: none;
}
i {
display: block;
position: relative;
border-radius: $border-radius;
width: $base-height;
height: $base-height;
border: rem(2px) solid $color-gray-7;
flex-shrink: 0;
}
input:checked ~ i {
border-color: $color-orange;
background: $color-orange;
&:after {
content: '';
box-sizing: border-box;
transform: rotate(45deg);
position: absolute;
left: 0.35rem;
top: -0.05rem;
display: block;
width: 0.5rem;
height: 1rem;
border: 0 solid $color-white;
border-right-width: rem(2px);
border-bottom-width: rem(2px);
}
}
}
}
+17
View File
@@ -0,0 +1,17 @@
<div class="component component-checkbox">
<span class="label">{{{label}}}</span>
<div class="checkbox-group">
{{each options}}
<label>
<span class="label">{{{this.label}}}</span>
<input
type="checkbox"
value="{{this.value}}"
name="clay-{{clayId}}"
data-manipulator-target
/>
<i></i>
</label>
{{/each}}
</div>
</div>