Skip to content

Instantly share code, notes, and snippets.

@lalitindoria
Last active February 6, 2020 04:40
Show Gist options
  • Select an option

  • Save lalitindoria/30d9b5dc516adb56cc8767ed31033a5d to your computer and use it in GitHub Desktop.

Select an option

Save lalitindoria/30d9b5dc516adb56cc8767ed31033a5d to your computer and use it in GitHub Desktop.
New Twiddle
import Ember from 'ember';
export default Ember.Component.extend({
applyBackground() {
let el = this.$('input'),
val = parseInt(el.val()),
min = parseInt(el.attr('min')),
max = parseInt(el.attr('max'));
let valPercent = (val - min) /
(max - min);
let style = `background-image: -webkit-gradient(linear, 0% 0%, 100% 0%, color-stop(${valPercent}, #3498db), color-stop(${valPercent}, #f5f6f8));`;
el[0].style = style;
},
didInsertElement: function() {
this.applyBackground();
let self = this;
this.$('input').on('input', function(e) {
self.applyBackground();
});
}
});
import Ember from 'ember';
export default Ember.Controller.extend({
appName: 'Ember Twiddle'
});
body {
margin: 12px 16px;
font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;
font-size: 12pt;
}
.__range {
-webkit-appearance: none;
width: 100%;
margin: 5.8px 0;
background-color: #049ee0;
}
.__range:focus{
outline:none;
}
.__range::-webkit-slider-runnable-track {
width: 100%;
height: 8.4px;
cursor: pointer;
box-shadow: 1.5px 1.5px 3.5px #000000, 0px 0px 1.5px #0d0d0d;
/* background: #3498db; */
border-radius: 1.3px;
border: 0.2px solid #010101;
}
.__range::-webkit-slider-thumb {
box-shadow: 2.7px 2.7px 8px #000000, 0px 0px 2.7px #0d0d0d;
border: 3.6px solid #ffffff;
height: 20px;
width: 20px;
border-radius: 20px;
background: #3498db;
cursor: pointer;
-webkit-appearance: none;
margin-top: -6px;
}
}
<h1>Welcome to {{appName}}</h1>
<br>
<br>
{{input-range}}
<br>
<br>
<input class='__range' type='range' min=1 max=10 />
{
"version": "0.15.1",
"EmberENV": {
"FEATURES": {}
},
"options": {
"use_pods": false,
"enable-testing": false
},
"dependencies": {
"jquery": "https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.js",
"ember": "3.4.3",
"ember-template-compiler": "3.4.3",
"ember-testing": "3.4.3"
},
"addons": {
"ember-data": "3.4.2"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment