Last active
December 20, 2020 13:56
-
-
Save highfiiv/58af050f41faa4058d649e9a649c0622 to your computer and use it in GitHub Desktop.
vertical input ranges for setting sensitivity scale on frequency eq bands
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
<label class="range__label"> | |
<input type="range" | |
[id]="forID" | |
class="range__input" | |
[max]="max" | |
[step]="step" | |
(touch)="onTouched()" | |
[ngModel]="value" | |
(ngModelChange)="onInput($event)" | |
[name]="name" | |
[disabled]="disabled" | |
tabindex="0" | |
orient="vertical"> | |
</label> |
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
p { | |
width: 100%; | |
margin: 10px 0; | |
} | |
span { | |
margin-left: auto; | |
} | |
.range__label { | |
} | |
.range__label-text { | |
width: fit-content; | |
} | |
.range__value { | |
flex: 1; | |
justify-content: flex-end; | |
} | |
.range__input { | |
padding: 0; | |
} | |
input-range { | |
flex: 100%; | |
} | |
// Styling Cross-Browser Compatible Range Inputs with Sass | |
// Github: https://github.com/darlanrod/input-range-sass | |
// Author: Darlan Rod https://github.com/darlanrod | |
// Version 1.5.2 | |
// MIT License | |
// THUMB | |
$thumb-color: #607d8b !default; | |
$thumb-radius: 0 !default; | |
$thumb-height: 6px !default; | |
$thumb-width: 15px !default; | |
$thumb-shadow-size: 4px !default; | |
$thumb-shadow-blur: 4px !default; | |
$thumb-shadow-color: rgba(0, 0, 0, 0.2) !default; | |
$thumb-border-width: 1px !default; | |
$thumb-border-color: #eceff1 !default; | |
// TRACK | |
$track-color: #eceff1 !default; | |
$track-width: 100% !default; | |
$track-height: 255px !default; | |
$track-shadow-size: 1px !default; | |
$track-shadow-blur: 1px !default; | |
$track-shadow-color: rgba(0, 0, 0, 0.2) !default; | |
$track-border-width: 1px !default; | |
$track-border-color: #cfd8dc !default; | |
$track-radius: 0 !default; | |
$contrast: 5% !default; | |
$ie-bottom-track-color: darken($track-color, $contrast) !default; | |
@mixin shadow($shadow-size, $shadow-blur, $shadow-color) { | |
box-shadow: $shadow-size $shadow-size $shadow-blur $shadow-color, 0 0 $shadow-size lighten($shadow-color, 5%); | |
} | |
@mixin track { | |
cursor: default; | |
height: $track-height; | |
transition: all 0.2s ease; | |
width: $track-width; | |
} | |
@mixin thumb { | |
@include shadow($thumb-shadow-size, $thumb-shadow-blur, $thumb-shadow-color); | |
background: $thumb-color; | |
border: $thumb-border-width solid $thumb-border-color; | |
border-radius: $thumb-radius; | |
box-sizing: border-box; | |
cursor: default; | |
height: $thumb-height; | |
max-height: $thumb-height; | |
width: $thumb-width; | |
} | |
[type='range'] { | |
-webkit-appearance: none; | |
background: transparent; | |
margin: 0; | |
width: $track-width; | |
// FOR VERTICAL | |
&[orient="vertical"]{ | |
writing-mode: bt-lr; /* IE */ | |
-webkit-appearance: slider-vertical; /* WebKit */ | |
} | |
&::-webkit-slider-runnable-track { | |
@include track; | |
@include shadow($track-shadow-size, $track-shadow-blur, $track-shadow-color); | |
background: $track-color; | |
border: $track-border-width solid $track-border-color; | |
border-radius: $track-radius; | |
} | |
&::-webkit-slider-thumb { | |
@include thumb; | |
-webkit-appearance: none; | |
} | |
&::-moz-range-track { | |
@include shadow($track-shadow-size, $track-shadow-blur, $track-shadow-color); | |
@include track; | |
background: $track-color; | |
border: $track-border-width solid $track-border-color; | |
border-radius: $track-radius; | |
height: $track-height / 2; | |
} | |
&::-moz-range-thumb { | |
@include thumb; | |
} | |
&::-ms-track { | |
@include track; | |
background: transparent; | |
border-color: transparent; | |
border-width: ($thumb-height / 2) 0; | |
color: transparent; | |
} | |
&::-ms-fill-lower { | |
@include shadow($track-shadow-size, $track-shadow-blur, $track-shadow-color); | |
background: $ie-bottom-track-color; | |
border: $track-border-width solid $track-border-color; | |
border-radius: ($track-radius * 2); | |
} | |
&::-ms-fill-upper { | |
@include shadow($track-shadow-size, $track-shadow-blur, $track-shadow-color); | |
background: $track-color; | |
border: $track-border-width solid $track-border-color; | |
border-radius: ($track-radius * 2); | |
} | |
&::-ms-thumb { | |
@include thumb; | |
margin-top: $track-height / 4; | |
} | |
&::-moz-focus-outer { | |
border: 0; | |
} | |
&:focus { | |
outline: 0; | |
cursor: hand; | |
&::-webkit-slider-runnable-track { | |
background: lighten($track-color, $contrast); | |
} | |
&::-ms-fill-lower { | |
background: $track-color; | |
} | |
&::-ms-fill-upper { | |
background: lighten($track-color, $contrast); | |
} | |
} | |
&:disabled { | |
&::-webkit-slider-thumb, | |
&::-moz-range-thumb, | |
&::-ms-thumb, | |
&::-webkit-slider-runnable-track, | |
&::-ms-fill-lower, | |
&::-ms-fill-upper { | |
cursor: not-allowed; | |
} | |
} | |
} |
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 { Component, forwardRef, Input, OnInit } from '@angular/core'; | |
import { NG_VALUE_ACCESSOR } from '@angular/forms'; | |
import { BaseControlValueAccessor } from '@shared/utilities/BaseControlValueAccessor'; | |
@Component({ | |
selector: 'input-range', | |
templateUrl: './input-range.component.html', | |
styleUrls: ['./input-range.component.scss'], | |
providers: [{ | |
provide: NG_VALUE_ACCESSOR, | |
useExisting: forwardRef(() => InputRangeComponent), | |
multi: true | |
}] | |
}) | |
export class InputRangeComponent extends BaseControlValueAccessor<any> implements OnInit { | |
@Input() value: string = '2.5'; | |
@Input() name: string = ''; | |
@Input() forID: string; // id value to match a parent label | |
@Input() max: number = 255; | |
@Input() step: number = 1; | |
@Input() disabled = false; | |
constructor() { super(); } | |
public ngOnInit(): void {} | |
public writeValue(val: string): void { | |
this.value = val; | |
this.onChange(+this.value); // set the control/form value | |
} | |
public onInput(val: string): void { | |
this.value = val; | |
this.onChange(+this.value); // set the control/form value | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment