Merge pull request #24 from pebble/#11/description-for-input-components

Add description field to all input type components.
This commit is contained in:
keegan-lillo
2016-03-03 10:54:45 +11:00
24 changed files with 160 additions and 134 deletions
+7 -1
View File
@@ -67,7 +67,7 @@ Your root element **must** be an array. This represents the entire page. Inside
## Components ## Components
![Example](src/images/example.png) <img src="src/images/example.png" width="360" title="Example">
### Section ### Section
@@ -178,6 +178,7 @@ Standard text input field.
| appKey | string (unique) | The AppMessage key matching the `appKey` item defined in your `appinfo.json`. Set this to a unique string to allow this item to be looked up using `Clay.getItemsByAppKey()` in your custom function. You must set this if you wish for the value of this item to be persisted after the user closes the config page. | | appKey | string (unique) | The AppMessage key matching the `appKey` item defined in your `appinfo.json`. Set this to a unique string to allow this item to be looked up using `Clay.getItemsByAppKey()` in your custom function. You must set this if you wish for the value of this item to be persisted after the user closes the config page. |
| label | string | The label that should appear next to this item. | | label | string | The label that should appear next to this item. |
| defaultValue | string | The default value of the input field. | | defaultValue | string | The default value of the input field. |
| description | string | Optional sub-text to include below the component |
| attributes | object | An object containing HTML attributes to set on the input field. You can add basic HTML5 validation this way by setting attributes such as `required` or `type`. | | attributes | object | An object containing HTML attributes to set on the input field. You can add basic HTML5 validation this way by setting attributes such as `required` or `type`. |
@@ -215,6 +216,7 @@ Switch for a single item.
| appKey | string (unique) | The AppMessage key matching the `appKey` item defined in your `appinfo.json`. Set this to a unique string to allow this item to be looked up using `Clay.getItemsByAppKey()` in your custom function. You must set this if you wish for the value of this item to be persisted after the user closes the config page. | | appKey | string (unique) | The AppMessage key matching the `appKey` item defined in your `appinfo.json`. Set this to a unique string to allow this item to be looked up using `Clay.getItemsByAppKey()` in your custom function. You must set this if you wish for the value of this item to be persisted after the user closes the config page. |
| label | string | The label that should appear next to this item. | | label | string | The label that should appear next to this item. |
| defaultValue | int\|boolean | The default value of the toggle. Defaults to `false` if not specified. | | defaultValue | int\|boolean | The default value of the toggle. Defaults to `false` if not specified. |
| description | string | Optional sub-text to include below the component |
| attributes | object | An object containing HTML attributes to set on the input field. You can add basic HTML5 validation this way by setting attribute such as `required`. | | attributes | object | An object containing HTML attributes to set on the input field. You can add basic HTML5 validation this way by setting attribute such as `required`. |
@@ -249,6 +251,7 @@ A dropdown menu containing multiple options.
| appKey | string (unique) | The AppMessage key matching the `appKey` item defined in your `appinfo.json`. Set this to a unique string to allow this item to be looked up using `Clay.getItemsByAppKey()` in your custom function. You must set this if you wish for the value of this item to be persisted after the user closes the config page. | | appKey | string (unique) | The AppMessage key matching the `appKey` item defined in your `appinfo.json`. Set this to a unique string to allow this item to be looked up using `Clay.getItemsByAppKey()` in your custom function. You must set this if you wish for the value of this item to be persisted after the user closes the config page. |
| label | string | The label that should appear next to this item. | | label | string | The label that should appear next to this item. |
| defaultValue | string | The default value of the dropdown menu. Must match a value in the `options` array. | | defaultValue | string | The default value of the dropdown menu. Must match a value in the `options` array. |
| description | string | Optional sub-text to include below the component |
| attributes | object | An object containing HTML attributes to set on the input field. You can add basic HTML5 validation this way by setting attribute such as `required`. | | attributes | object | An object containing HTML attributes to set on the input field. You can add basic HTML5 validation this way by setting attribute such as `required`. |
| options | array of objects | The options you want to appear in the dropdown menu. Each option is an object with a `label` and `value` property. | | options | array of objects | The options you want to appear in the dropdown menu. Each option is an object with a `label` and `value` property. |
@@ -301,6 +304,7 @@ A color picker containing the 64 supported colors on Basalt and Chalk.
| appKey | string (unique) | The AppMessage key matching the `appKey` item defined in your `appinfo.json`. Set this to a unique string to allow this item to be looked up using `Clay.getItemsByAppKey()` in your custom function. You must set this if you wish for the value of this item to be persisted after the user closes the config page. | | appKey | string (unique) | The AppMessage key matching the `appKey` item defined in your `appinfo.json`. Set this to a unique string to allow this item to be looked up using `Clay.getItemsByAppKey()` in your custom function. You must set this if you wish for the value of this item to be persisted after the user closes the config page. |
| label | string | The label that should appear next to this item. | | label | string | The label that should appear next to this item. |
| defaultValue | string OR int | The default color. Always use the uncorrected value even if `sunlight` is true. The component will do the conversion internally. | | defaultValue | string OR int | The default color. Always use the uncorrected value even if `sunlight` is true. The component will do the conversion internally. |
| description | string | Optional sub-text to include below the component |
| sunlight | boolean | Use the color-corrected sunlight color palette if `true`, else the uncorrected version. Defaults to `true` if not specified. | | sunlight | boolean | Use the color-corrected sunlight color palette if `true`, else the uncorrected version. Defaults to `true` if not specified. |
##### Example ##### Example
@@ -332,6 +336,7 @@ A list of options allowing the user can only choose one option to submit.
| appKey | string (unique) | The AppMessage key matching the `appKey` item defined in your `appinfo.json`. Set this to a unique string to allow this item to be looked up using `Clay.getItemsByAppKey()` in your custom function. You must set this if you wish for the value of this item to be persisted after the user closes the config page. | | appKey | string (unique) | The AppMessage key matching the `appKey` item defined in your `appinfo.json`. Set this to a unique string to allow this item to be looked up using `Clay.getItemsByAppKey()` in your custom function. You must set this if you wish for the value of this item to be persisted after the user closes the config page. |
| label | string | The label that should appear next to this item. | | label | string | The label that should appear next to this item. |
| defaultValue | string | The default selected item. Must match a value in the `options` array. | | defaultValue | string | The default selected item. Must match a value in the `options` array. |
| description | string | Optional sub-text to include below the component |
| attributes | object | An object containing HTML attributes to set on the input field. You can add basic HTML5 validation this way by setting attribute such as `required`. | | attributes | object | An object containing HTML attributes to set on the input field. You can add basic HTML5 validation this way by setting attribute such as `required`. |
| options | array of objects | The options you want to appear in the radio group. Each option is an object with a `label` and `value` property. | | options | array of objects | The options you want to appear in the radio group. Each option is an object with a `label` and `value` property. |
@@ -376,6 +381,7 @@ A list of options where a user may choose more than one option to submit.
| appKey | string (unique) | The AppMessage key matching the `appKey` item defined in your `appinfo.json`. Set this to a unique string to allow this item to be looked up using `Clay.getItemsByAppKey()` in your custom function. You must set this if you wish for the value of this item to be persisted after the user closes the config page. | | appKey | string (unique) | The AppMessage key matching the `appKey` item defined in your `appinfo.json`. Set this to a unique string to allow this item to be looked up using `Clay.getItemsByAppKey()` in your custom function. You must set this if you wish for the value of this item to be persisted after the user closes the config page. |
| label | string | The label that should appear next to this item. | | label | string | The label that should appear next to this item. |
| defaultValue | array of strings | The default selected items. Each value must match one in the `options` array. | | defaultValue | array of strings | The default selected items. Each value must match one in the `options` array. |
| description | string | Optional sub-text to include below the component |
| attributes | object | An object containing HTML attributes to set on the input field. You can add basic HTML5 validation this way by setting attribute such as `required`. | | attributes | object | An object containing HTML attributes to set on the input field. You can add basic HTML5 validation this way by setting attribute such as `required`. |
| options | array of objects | The options you want to appear in the checkbox group. Each option is an object with a `label` and `value` property. | | options | array of objects | The options you want to appear in the checkbox group. Each option is an object with a `label` and `value` property. |
+14 -28
View File
@@ -24,32 +24,31 @@ module.exports = [
"type": "input", "type": "input",
"appKey": "email", "appKey": "email",
"defaultValue": "", "defaultValue": "",
"label": "Email", "label": "Input Field",
"description": "This is a description for the input component. " +
"You can add <strong>html</strong> in here too.",
"attributes": { "attributes": {
"placeholder": "eg: name@domain.com", "placeholder": "Placeholder set with attributes"
"limit": 10,
"required": "required",
type: "email"
} }
}, },
{ {
"type": "toggle", "type": "toggle",
"appKey": "cool_stuff", "appKey": "cool_stuff",
"label": "Enable Cool Stuff", "label": "This is a Toggle",
"defaultValue": false "defaultValue": false
}, },
{ {
"type": "color", "type": "color",
"appKey": "colorTest", "appKey": "colorTest",
"defaultValue": "FF0000", "defaultValue": "FF0000",
"label": "Background Color", "label": "Standard Color Picker",
"sunlight": false "sunlight": false
}, },
{ {
"type": "color", "type": "color",
"appKey": "sunnyColorTest", "appKey": "sunnyColorTest",
"defaultValue": "00FF00", "defaultValue": "00FF00",
"label": "Sunny Color", "label": "Sunny Color Picker",
"sunlight": true "sunlight": true
} }
] ]
@@ -64,46 +63,33 @@ module.exports = [
{ {
"type": "radiogroup", "type": "radiogroup",
"appKey": "radiogroup-test", "appKey": "radiogroup-test",
"label": "Radio test", "label": "Radio Group",
"options": [ "options": [
{ "label": "Test thing one", "value": "one" }, { "label": "Test thing", "value": "one" },
{ "label": "Another thing", "value": "two" }, { "label": "Another thing", "value": "two" },
{ "label": "One really long thing that would not fit", "value": "three" }, { "label": "Final thing with <em>html</em>", "value": "three" }
{ "label": "Small", "value": "quote' \"test" },
{ "label": "Final thing", "value": "three" }
] ]
}, },
{ {
"type": "checkboxgroup", "type": "checkboxgroup",
"appKey": "checkboxgroup-test", "appKey": "checkboxgroup-test",
"defaultValue": ["quote' \"test", "two"], "defaultValue": ["quote' \"test", "two"],
"label": "Checkbox test", "label": "Checkbox Group",
"options": [ "options": [
{ "label": "Test <strong>thing</strong> one", "value": "one" }, { "label": "First thing", "value": "three" },
{ "label": "Another thing", "value": "two" }, { "label": "Another thing", "value": "two" },
{ "label": "One really long thing that would not fit", "value": "three" },
{ "label": "Small", "value": "quote' \"test" },
{ "label": "Final thing", "value": "three" } { "label": "Final thing", "value": "three" }
] ]
}, },
{
"type": "input",
"appKey": "date",
"defaultValue": "",
"label": "Range",
"attributes": {
type: "range"
}
},
{ {
"type": "select", "type": "select",
"appKey": "flavor", "appKey": "flavor",
"defaultValue": "grape", "defaultValue": "grape",
"label": "Favorite Flavor", "label": "Select Menu",
"options": [ "options": [
{ "label": "", "value": "" }, { "label": "", "value": "" },
{ "label": "Berry", "value": "berry" }, { "label": "Berry", "value": "berry" },
{ "label": "Grape", "value": "grape" }, { "label": "This Option is Selected", "value": "grape" },
{ "label": "Banana", "value": "banana" } { "label": "Banana", "value": "banana" }
], ],
"attributes": { "attributes": {
+3 -3
View File
File diff suppressed because one or more lines are too long
Binary file not shown.

Before

Width:  |  Height:  |  Size: 51 KiB

After

Width:  |  Height:  |  Size: 116 KiB

+1
View File
@@ -8,6 +8,7 @@ module.exports = {
defaults: { defaults: {
label: '', label: '',
options: [], options: [],
description: '',
attributes: {} attributes: {}
} }
}; };
+2 -1
View File
@@ -6,7 +6,8 @@ module.exports = {
style: require('../../styles/clay/components/color.scss'), style: require('../../styles/clay/components/color.scss'),
manipulator: 'color', manipulator: 'color',
defaults: { defaults: {
label: '' label: '',
description: ''
}, },
initialize: function(minified) { initialize: function(minified) {
var HTML = minified.HTML; var HTML = minified.HTML;
+1
View File
@@ -7,6 +7,7 @@ module.exports = {
manipulator: 'val', manipulator: 'val',
defaults: { defaults: {
label: '', label: '',
description: '',
attributes: {} attributes: {}
} }
}; };
+1
View File
@@ -8,6 +8,7 @@ module.exports = {
defaults: { defaults: {
label: '', label: '',
options: [], options: [],
description: '',
attributes: {} attributes: {}
} }
}; };
+1
View File
@@ -8,6 +8,7 @@ module.exports = {
defaults: { defaults: {
label: '', label: '',
options: [], options: [],
description: '',
attributes: {} attributes: {}
}, },
initialize: function() { initialize: function() {
+1
View File
@@ -7,6 +7,7 @@ module.exports = {
manipulator: 'checked', manipulator: 'checked',
defaults: { defaults: {
label: '', label: '',
description: '',
attributes: {} attributes: {}
} }
}; };
+25 -62
View File
@@ -20,6 +20,23 @@ body {
padding: 0 $item-spacing-h $item-spacing-v; padding: 0 $item-spacing-h $item-spacing-v;
} }
em {
font-style: italic;
}
strong {
@include font-pfdin(medium);
color: $color-orange;
}
a {
color: $color-gray-8;
&:hover {
color: inherit;
}
}
h1, h2, h3, h4 { h1, h2, h3, h4 {
text-transform: uppercase; text-transform: uppercase;
@include font-pfdin(medium); @include font-pfdin(medium);
@@ -50,23 +67,11 @@ h6 {
@include font-size(0.8); @include font-size(0.8);
} }
strong {
@include font-pfdin(medium);
color: $color-orange;
}
a {
color: $color-gray-8;
&:hover {
color: inherit;
}
}
label { label {
display: flex; display: flex;
justify-content: space-between; justify-content: space-between;
align-items: center; align-items: center;
padding: $item-spacing-v $item-spacing-h;
.input { .input {
white-space: nowrap; white-space: nowrap;
@@ -131,11 +136,6 @@ label {
margin-top: 0; margin-top: 0;
} }
&:last-child,
&:first-child {
padding-bottom: $item-spacing-v;
}
&:first-child:after { &:first-child:after {
display: none; display: none;
} }
@@ -179,52 +179,15 @@ label {
} }
.description {
padding: 0 $item-spacing-h $item-spacing-v ;
@include font-size(0.9);
color: $color-gray-9;
}
.inputs { .inputs {
display: block; display: block;
width:100%; width:100%;
border-collapse: collapse; border-collapse: collapse;
.section & .component {
display: table;
width:100%;
.label,
.input {
display: table-cell;
}
.input {
text-align: right;
}
&.invalid {
.input:after {
content: "!";
display: inline-block;
color: $color-white;
background: $color-orange;
border-radius: $border-radius;
width: 1.2em;
text-align: center;
height: 1.2em;
font-size: 1em;
vertical-align: middle;
line-height: 1.3em;
margin-left: -0.7em;
position:absolute;
@include font-pfdin(regular);
}
.input input {
color: $color-orange;
padding-right: 1em;
@include placeholder {
color: $color-orange;
}
}
}
}
} }
+11 -2
View File
@@ -5,6 +5,10 @@
display: block; display: block;
.section & {
padding-right: $item-spacing-h / 2;
}
> .label { > .label {
display: block; display: block;
padding-bottom: $item-spacing-v / 2; padding-bottom: $item-spacing-v / 2;
@@ -12,13 +16,14 @@
.checkbox-group { .checkbox-group {
padding-bottom: $item-spacing-v / 2;
label { label {
padding: $item-spacing-v / 2 0; padding: $item-spacing-v / 2 $item-spacing-h / 2;
} }
.label { .label {
font-size: 0.9em; font-size: 0.9em;
padding: 0 $item-spacing-h / 2;
} }
input { input {
@@ -56,6 +61,10 @@
} }
} }
}
.description {
padding-left: 0;
padding-right: 0;
} }
} }
+4
View File
@@ -2,6 +2,10 @@
.component-color { .component-color {
.section & {
padding: 0;
}
.value { .value {
width: $small-component-width; width: $small-component-width;
height: $base-height; height: $base-height;
+7 -1
View File
@@ -2,7 +2,13 @@
.component-input { .component-input {
display: block; .section & {
padding: 0;
}
label {
display: block;
}
.label { .label {
padding-bottom: $item-spacing-v; padding-bottom: $item-spacing-v;
+12 -2
View File
@@ -5,6 +5,10 @@
display: block; display: block;
.section & {
padding-right: $item-spacing-h / 2;
}
> .label { > .label {
display: block; display: block;
padding-bottom: $item-spacing-v / 2; padding-bottom: $item-spacing-v / 2;
@@ -12,13 +16,14 @@
.radio-group { .radio-group {
padding-bottom: $item-spacing-v / 2;
label { label {
padding: $item-spacing-v / 2 0; padding: $item-spacing-v / 2 $item-spacing-h / 2;
} }
.label { .label {
font-size: 0.9em; font-size: 0.9em;
padding: 0 $item-spacing-h / 2;
} }
input { input {
@@ -55,4 +60,9 @@
} }
} }
.description {
padding-left: 0;
padding-right: 0;
}
} }
+9 -2
View File
@@ -2,7 +2,14 @@
@import "clay"; @import "clay";
.component-select { .component-select {
position: relative;
.section & {
padding: 0;
}
label {
position: relative;
}
.value { .value {
$triangle-size: 0.85rem; $triangle-size: 0.85rem;
@@ -16,7 +23,7 @@
right: 0; right: 0;
top: 50%; top: 50%;
margin-top: -0.1rem; margin-top: -0.1rem;
@include triangle($triangle-size, $color-gray-10, down); @include triangle($triangle-size, $color-orange, down);
} }
} }
+4
View File
@@ -6,6 +6,10 @@
$slide-width: $small-component-width; $slide-width: $small-component-width;
$marker-diameter: $base-height; $marker-diameter: $base-height;
.section & {
padding: 0;
}
input { input {
display: none; // @todo make sure this doesn't mess up interactivity on iOS display: none; // @todo make sure this doesn't mess up interactivity on iOS
} }
@@ -15,4 +15,7 @@
</label> </label>
{{/each}} {{/each}}
</div> </div>
{{if description}}
<div class="description">{{{description}}}</div>
{{/if}}
</div> </div>
+5 -2
View File
@@ -1,5 +1,5 @@
<div class="component component-color tap-highlight"> <div class="component component-color">
<label> <label class="tap-highlight">
<input <input
data-manipulator-target data-manipulator-target
type="hidden" type="hidden"
@@ -7,6 +7,9 @@
<span class="label">{{{label}}}</span> <span class="label">{{{label}}}</span>
<span class="value"></span> <span class="value"></span>
</label> </label>
{{if description}}
<div class="description">{{{description}}}</div>
{{/if}}
<div class="picker-wrap"> <div class="picker-wrap">
<div class="picker"> <div class="picker">
<div class="color-box-wrap"> <div class="color-box-wrap">
+13 -7
View File
@@ -1,9 +1,15 @@
<label class="component component-input tap-highlight"> <div class="component component-input">
<span class="label">{{{label}}}</span> <label class="tap-highlight">
<span class="input"> <span class="label">{{{label}}}</span>
<input <span class="input">
<input
data-manipulator-target data-manipulator-target
{{each key: attributes}}{{key}}="{{this}}"{{/each}} {{each key: attributes}}{{key}}="{{this}}"{{/each}}
/> />
</span> </span>
</label> </label>
{{if description}}
<div class="description">{{{description}}}</div>
{{/if}}
</div>
+3
View File
@@ -15,4 +15,7 @@
</label> </label>
{{/each}} {{/each}}
</div> </div>
{{if description}}
<div class="description">{{{description}}}</div>
{{/if}}
</div> </div>
+14 -9
View File
@@ -1,9 +1,14 @@
<label class="component component-select tap-highlight"> <div class="component component-select">
<span class="label">{{{label}}}</span> <label class="tap-highlight">
<span class="value"></span> <span class="label">{{{label}}}</span>
<select data-manipulator-target {{each key: attributes}}{{key}}="{{this}}"{{/each}}> <span class="value"></span>
{{each options}} <select data-manipulator-target {{each key: attributes}}{{key}}="{{this}}"{{/each}}>
<option value="{{this.value}}" class="item-select-option">{{this.label}}</option> {{each options}}
{{/each}} <option value="{{this.value}}" class="item-select-option">{{this.label}}</option>
</select> {{/each}}
</label> </select>
</label>
{{if description}}
<div class="description">{{{description}}}</div>
{{/if}}
</div>
+18 -13
View File
@@ -1,14 +1,19 @@
<label class="component component-toggle tap-highlight"> <div class="component component-toggle">
<span class="label">{{{label}}}</span> <label class="tap-highlight">
<span class="input"> <span class="label">{{{label}}}</span>
<input <span class="input">
data-manipulator-target <input
type="checkbox" data-manipulator-target
{{each key: attributes}}{{key}}="{{this}}"{{/each}} type="checkbox"
/> {{each key: attributes}}{{key}}="{{this}}"{{/each}}
<span class="graphic"> />
<span class="slide"></span> <span class="graphic">
<span class="marker"></span> <span class="slide"></span>
<span class="marker"></span>
</span>
</span> </span>
</span> </label>
</label> {{if description}}
<div class="description">{{{description}}}</div>
{{/if}}
</div>
+1 -1
View File
@@ -77,7 +77,7 @@ describe('ClayItem', function() {
describe('.$element', function() { describe('.$element', function() {
it('sets $element correctly', function() { it('sets $element correctly', function() {
var clayItem = fixture.clayItem('input'); var clayItem = fixture.clayItem('input');
assert.strictEqual(clayItem.$element[0].tagName, 'LABEL'); assert.strictEqual(clayItem.$element[0].classList.contains('component'), true);
}); });
}); });