Allow placeholder to be configured for `combo-box`.

This commit is contained in:
Guo Xiang Tan 2018-03-29 10:25:29 +08:00
parent a64cc9a990
commit 27f06505b1
4 changed files with 17 additions and 4 deletions

View File

@ -24,8 +24,11 @@ export default SingleSelectComponent.extend({
@on("didReceiveAttrs") @on("didReceiveAttrs")
_setComboBoxOptions() { _setComboBoxOptions() {
const placeholder = this.get('placeholder');
this.get("headerComponentOptions").setProperties({ this.get("headerComponentOptions").setProperties({
clearable: this.get("clearable"), clearable: this.get("clearable"),
placeholder: placeholder ? I18n.t(placeholder) : "",
}); });
} }
}); });

View File

@ -7,5 +7,6 @@ export default SelectKitHeaderComponent.extend({
clearable: Ember.computed.alias("options.clearable"), clearable: Ember.computed.alias("options.clearable"),
caretUpIcon: Ember.computed.alias("options.caretUpIcon"), caretUpIcon: Ember.computed.alias("options.caretUpIcon"),
caretDownIcon: Ember.computed.alias("options.caretDownIcon"), caretDownIcon: Ember.computed.alias("options.caretDownIcon"),
shouldDisplayClearableButton: Ember.computed.and("clearable", "computedContent.hasSelection") shouldDisplayClearableButton: Ember.computed.and("clearable", "computedContent.hasSelection"),
placeholder: Ember.computed.alias("options.placeholder"),
}); });

View File

@ -1,8 +1,14 @@
{{#each icons as |icon|}} {{d-icon icon}} {{/each}} {{#each icons as |icon|}} {{d-icon icon}} {{/each}}
<span class="selected-name"> {{#if label}}
<span class="selected-name">
{{{label}}} {{{label}}}
</span> </span>
{{else}}
<span class="combo-box-placeholder">
{{placeholder}}
</span>
{{/if}}
{{#if shouldDisplayClearableButton}} {{#if shouldDisplayClearableButton}}
<button class="btn-clear" {{action onClearSelection bubbles=false}}> <button class="btn-clear" {{action onClearSelection bubbles=false}}>

View File

@ -1,5 +1,8 @@
.select-kit { .select-kit {
&.combo-box { &.combo-box {
.combo-box-placeholder {
color: dark-light-choose($primary-high, $secondary-low);
}
.select-kit-body { .select-kit-body {
width: 100%; width: 100%;