Skip to content

Commit

Permalink
WIP - converting demo components to new format
Browse files Browse the repository at this point in the history
  • Loading branch information
HeroicEric committed Jul 9, 2016
1 parent a116ea2 commit 645d9fa
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 69 deletions.
44 changes: 1 addition & 43 deletions addon/components/demo--generic.js
Original file line number Diff line number Diff line change
@@ -1,49 +1,7 @@
import Ember from 'ember';
import layout from '../templates/components/demo--generic';

const SIZES = [
'x-small',
'small',
'medium',
'large',
'x-large'
];

export default Ember.Component.extend({
layout,
tagName: '',

init() {
this._super(...arguments);

if (!this.kinds) {
this.kinds = ['default'];
}

if (!this.sizes) {
this.sizes = [].concat(SIZES);
}

this.activeStates = {};
this.currentKind = 'default';
},

actions: {
setKind(size) {
this.set('currentKind', size);
},

setState(state) {
let activeStates = this.get('activeStates');
let newStates = Object.assign({}, activeStates);

if (newStates[state]) {
newStates[state] = false;
} else {
newStates[state] = true;
}

this.set('activeStates', newStates);
}
}
tagName: ''
});
19 changes: 3 additions & 16 deletions addon/components/demo--ui-button.js
Original file line number Diff line number Diff line change
@@ -1,20 +1,7 @@
import DemoGeneric from './demo--generic';
import Ember from 'ember';
import layout from 'ui-base-theme/templates/components/demo--ui-button';

export default DemoGeneric.extend({
export default Ember.Component.extend({
layout,

kinds: [
'default',
'material',
'primary',
'simple'
],

states: [
'active',
'focus',
'disabled',
'loading'
],
tagName: ''
});
4 changes: 2 additions & 2 deletions addon/templates/components/demo--ui-checkbox.hbs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{{!- BEGIN-SNIPPET demo--ui-checkbox -}}
{{#ui-field kind=kind states=states size=size type="checkbox" as |f|}}
{{#f.input}}
{{#ui-field kind=kind size=size type="checkbox" as |f|}}
{{#f.input disabled=activeStates.disabled error=activeStates.error}}
{{size}}
{{/f.input}}
{{/ui-field}}
Expand Down
6 changes: 3 additions & 3 deletions addon/templates/components/demo--ui-textarea.hbs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{{!- BEGIN-SNIPPET demo--ui-textarea -}}
{{#ui-field kind=kind states=states size=size type="textarea" as |f|}}
{{#ui-field kind=kind _activeStates=activeStates size=size type="textarea" as |f|}}
{{#f.label}}
{{size}}
{{/f.label}}
Expand All @@ -8,8 +8,8 @@
value=size
placeholder=(concat size ", 4 rows")
rows=4
error=states.error
disabled=states.disabled
error=activeStates.error
disabled=activeStates.disabled
}}
{{/ui-field}}
{{!- END-SNIPPET -}}
12 changes: 7 additions & 5 deletions tests/dummy/app/controllers/styleguide.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,17 +34,19 @@ let componentCustomizations = {
'ui-button': {
kinds: ['default', 'material', 'primary', 'simple'],
states: ['active', 'disabled', 'focus', 'loading']
},
'ui-checkbox': {
states: ['disabled', 'error']
},
'ui-textarea': {
states: ['disabled', 'error']
}
};

Ember.A(uiComponentNames).removeObjects(COMPONENT_BLACKLIST);

let kinds = ['default'];
let states = [];
// let states = ['active', 'focus', 'disabled', 'loading', 'error'];

let allComponents = uiComponentNames.map((componentName) => {
let attrs = { name: componentName, kinds: kinds.slice(), states: states.slice() };
let attrs = { name: componentName, kinds: ['default'], states: [] };
let customizations = componentCustomizations[componentName];

if (customizations) {
Expand Down

0 comments on commit 645d9fa

Please sign in to comment.