Last active
August 21, 2022 19:16
-
-
Save rossjha/02ffd7db4a6aa14edb825eb4d0d79ae2 to your computer and use it in GitHub Desktop.
Range
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Controller from '@ember/controller'; | |
import { action } from "@ember/object"; | |
import { tracked } from '@glimmer/tracking'; | |
export default class ApplicationController extends Controller { | |
@tracked start = 10; | |
@tracked end = 30; | |
@action setInputRange([start, end]) { | |
this.start = start; | |
this.end = end; | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { modifier } from "ember-modifier"; | |
export default modifier( | |
function onInputRange(element, [doOnInputRange]) { | |
const rangeStart = element.querySelector('.range-start'); | |
const rangeEnd = element.querySelector('.range-end'); | |
const handleRangeInput = (evt) => { | |
const start = parseInt(rangeStart.value); | |
const end = parseInt(rangeEnd.value); | |
rangeStart.style.zIndex = 1; | |
rangeEnd.style.zIndex = 2; | |
if (start > end) { | |
rangeStart.style.zIndex = 2; | |
rangeEnd.style.zIndex = 1; | |
} | |
doOnInputRange([start, end]); | |
}; | |
element.addEventListener("input", handleRangeInput); | |
return () => { | |
element.removeEventListener("input", handleRangeInput); | |
}; | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@import "https://unpkg.com/tailwindcss@^2/dist/tailwind.min.css"; | |
body{ | |
background: #F9FAFB; | |
} | |
.Form-Range input[type="range"] { | |
pointer-events: none; | |
cursor: pointer; | |
} | |
.Form-Range input[type="range"]::-webkit-slider-thumb{ | |
pointer-events: all; | |
} | |
.Form-Range input[type="range"] { | |
outline: none; | |
} | |
.Form-Range input[type="range"]:focus::-webkit-slider-thumb { | |
border: 1px solid #0075FF; | |
border-radius: 50%; | |
outline: 3px solid #0075FF; | |
outline-offset: 0.125rem; | |
} | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"version": "0.17.1", | |
"EmberENV": { | |
"FEATURES": {}, | |
"_TEMPLATE_ONLY_GLIMMER_COMPONENTS": false, | |
"_APPLICATION_TEMPLATE_WRAPPER": true, | |
"_JQUERY_INTEGRATION": true | |
}, | |
"options": { | |
"use_pods": false, | |
"enable-testing": false | |
}, | |
"dependencies": { | |
"jquery": "https://cdnjs.cloudflare.com/ajax/libs/jquery/3.5.1/jquery.js", | |
"ember": "3.18.1", | |
"ember-template-compiler": "3.18.1", | |
"ember-testing": "3.18.1" | |
}, | |
"addons": { | |
"@glimmer/component": "1.0.0", | |
"ember-data": "3.18.0", | |
"ember-truth-helpers": "3.0.0", | |
"ember-modifier": "3.0.0" | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment