Skip to content

Instantly share code, notes, and snippets.

@lukesargeant
Last active March 4, 2016 20:31
Show Gist options
  • Save lukesargeant/7458f598e571ae3f16dd to your computer and use it in GitHub Desktop.
Save lukesargeant/7458f598e571ae3f16dd to your computer and use it in GitHub Desktop.
Multi-line label select
import Ember from 'ember';
export default Ember.Controller.extend({
appName: 'Ember Twiddle',
options: Ember.A([
'Multi-line option one',
'Multi-line option two',
'Multi-line option three',
])
});
{{label-select options=options}}
import Ember from 'ember';
export default Ember.Component.extend({
classNames: ['label-select'],
tagName: 'label',
value: Ember.computed('options', function() {
return this.get('options').objectAt(0);
})
});
{{value}}
<select value={{value}} onchange={{action (mut value) value='target.value'}}>
{{#each options as |option|}}
<option value={{option}}>{{option}}</option>
{{/each}}
</select>
body {
margin: 12px 16px;
font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;
font-size: 12pt;
}
.label-select {
position: relative;
display: inline-block;
padding-right: 10px;
width: 100px;
}
.label-select:hover {
color: #777;
}
.label-select select {
position: absolute;
top: 0;
width: 100%;
bottom: 0;
left: 0;
background: transparent;
border: 0 none;
-webkit-appearance: none;
-moz-appearance: none;
font-size: 0;
}
.label-select select option {
font-size: 12px;
}
.label-select::after {
display: inline-block;
content: '';
font-size: 0;
width: 0;
height: 0;
border-left: 4px solid transparent;
border-right: 4px solid transparent;
border-top: 7px solid black;
margin-bottom: 1px;
margin-left: 3px;
}
{
"version": "0.6.1",
"EmberENV": {
"FEATURES": {}
},
"options": {
"enable-testing": false
},
"dependencies": {
"jquery": "https://cdnjs.cloudflare.com/ajax/libs/jquery/1.11.3/jquery.js",
"ember": "https://cdnjs.cloudflare.com/ajax/libs/ember.js/2.3.1/ember.debug.js",
"ember-data": "https://cdnjs.cloudflare.com/ajax/libs/ember-data.js/2.3.3/ember-data.js",
"ember-template-compiler": "https://cdnjs.cloudflare.com/ajax/libs/ember.js/2.2.0/ember-template-compiler.js"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment