File tree Expand file tree Collapse file tree 2 files changed +43
-0
lines changed Expand file tree Collapse file tree 2 files changed +43
-0
lines changed Original file line number Diff line number Diff line change 77* .log
88storybook-static
99custom-elements.json
10+ .idea
Original file line number Diff line number Diff line change @@ -33,6 +33,17 @@ export class PotentiometerElement extends LitElement {
3333 word-spacing: 0px;
3434 fill: #ffffff;
3535 }
36+ .hide-input {
37+ position: absolute;
38+ clip: rect(0 0 0 0);
39+ width: 1px;
40+ height: 1px;
41+ margin: -1px;
42+ }
43+ input:focus + svg #knob {
44+ stroke: #ccdae3;
45+ filter: url(#outline);
46+ }
3647 ` ;
3748 }
3849
@@ -53,12 +64,26 @@ export class PotentiometerElement extends LitElement {
5364 const knobDeg = ( this . endDegree - this . startDegree ) * percent + this . startDegree ;
5465
5566 return html `
67+ < input
68+ tabindex ="0 "
69+ type ="range "
70+ class ="hide-input "
71+ max ="${ this . max } "
72+ min ="${ this . min } "
73+ value ="${ this . value } "
74+ step ="${ this . step } "
75+ aria-valuemin ="${ this . min } "
76+ aria-valuenow ="${ this . value } "
77+ @input ="${ this . onValueChange } "
78+ />
5679 < svg
80+ role ="slider "
5781 width ="20mm "
5882 height ="20mm "
5983 version ="1.1 "
6084 viewBox ="0 0 20 20 "
6185 xmlns ="http://www.w3.org/2000/svg "
86+ @click ="${ this . focusInput } "
6287 @mousedown =${ this . down }
6388 @mousemove =${ this . move }
6489 @mouseup=${ this . up }
@@ -69,6 +94,11 @@ export class PotentiometerElement extends LitElement {
6994 '--knob-angle' : knobDeg + 'deg' ,
7095 } ) }
7196 >
97+ < defs >
98+ < filter id ="outline ">
99+ < feDropShadow id ="glow " dx ="0 " dy ="0 " stdDeviation ="0.5 " flood-color ="cyan " />
100+ </ filter >
101+ </ defs >
72102 < rect
73103 x =".15 "
74104 y =".15 "
@@ -120,6 +150,18 @@ export class PotentiometerElement extends LitElement {
120150 ` ;
121151 }
122152
153+ private focusInput ( ) {
154+ const inputEl : HTMLInputElement | null | undefined = this . shadowRoot ?. querySelector (
155+ '.hide-input'
156+ ) ;
157+ inputEl ?. focus ( ) ;
158+ }
159+
160+ private onValueChange ( event : KeyboardEvent ) {
161+ const target = event . target as HTMLInputElement ;
162+ this . updateValue ( parseFloat ( target . value ) ) ;
163+ }
164+
123165 private down ( event : MouseEvent ) {
124166 if ( event . button === 0 || window . navigator . maxTouchPoints ) {
125167 this . pressed = true ;
You can’t perform that action at this time.
0 commit comments