Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add range input to freestyle-dynamic #174

Merged
merged 4 commits into from
May 21, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,6 @@ jsconfig.json
.node_modules.ember-try/
bower.json.ember-try
package.json.ember-try

# text editors
.vscode/*
1 change: 1 addition & 0 deletions addon/components/freestyle-dynamic-input.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ export default Component.extend({
isTextarea: equal('inputType', 'textarea'),
isSelect: equal('inputType', 'select'),
isNumber: equal('inputType', 'number'),
isRange: equal('inputType', 'range'),

inputId: computed('propertyName', function() {
return `${this.get('elementId')}_${this.get('propertyName')}`;
Expand Down
10 changes: 10 additions & 0 deletions addon/templates/components/freestyle-dynamic-input.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,16 @@
id=inputId
input=(action 'sendChangedNumberValue' value='target.value')
}}
{{else if isRange}}
{{input
type='range'
id=inputId
min=min
max=max
input=(action 'sendChangedNumberValue' value='target.value')
value=(readonly value)
}}
{{value}}
{{else}}
{{input value=value id=inputId key-up=(action 'sendChangedValue')}}
{{/if}}
Expand Down
2 changes: 2 additions & 0 deletions addon/templates/components/freestyle-dynamic.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
options=propertyHash.options
inputType=propertyHash.inputType
description=propertyHash.description
min=propertyHash.min
max=propertyHash.max
changeValueTo=(action 'changeValueTo' propertyName)
}}
{{/each-in}}
Expand Down
13 changes: 13 additions & 0 deletions tests/dummy/app/components/x-bar/component.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import Component from '@ember/component';
import layout from './template';
import { computed } from '@ember/object';
import { htmlSafe } from '@ember/string';

export default Component.extend({
layout,
Expand All @@ -9,4 +11,15 @@ export default Component.extend({
showBorder: true,
isVisible: true,
isTasteful: false,

innerBorderThicknessStyle: computed('innerBorderThickness', function() {
const innerBorderThickness = this.get('innerBorderThickness');

// allow 0
if (innerBorderThickness != null) {
return htmlSafe(`border-width: ${innerBorderThickness}px`);
} else {
return '';
}
})
});
2 changes: 1 addition & 1 deletion tests/dummy/app/components/x-bar/template.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<div class="x-Bar-rank">{{rank}}</div>
</div>
<p>{{description}}</p>
<div class="x-Bar-description">
<div class="x-Bar-description" style={{innerBorderThicknessStyle}}>
{{yield}}
</div>
</div>
7 changes: 7 additions & 0 deletions tests/dummy/app/controllers/acceptance.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,13 @@ export default FreestyleController.extend({
value: false,
inputType: 'checkbox',
description: 'Changes to a tasteful color scheme'
},
innerBorderThickness: {
value: 1,
inputType: 'range',
min: 0,
max: 20,
description: 'Width of the inner border, in pixels',
}
}
}),
Expand Down
1 change: 1 addition & 0 deletions tests/dummy/app/templates/acceptance.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@
rank=dynamic.rank
isVisible=dynamic.isVisible
isTasteful=dynamic.isTasteful
innerBorderThickness=dynamic.innerBorderThickness
}}
<p>{{dynamic.blockContent}}</p>
<p>Static block content</p>
Expand Down