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 7
7
* .log
8
8
storybook-static
9
9
custom-elements.json
10
+ .idea
Original file line number Diff line number Diff line change @@ -33,6 +33,17 @@ export class PotentiometerElement extends LitElement {
33
33
word-spacing: 0px;
34
34
fill: #ffffff;
35
35
}
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
+ }
36
47
` ;
37
48
}
38
49
@@ -53,12 +64,26 @@ export class PotentiometerElement extends LitElement {
53
64
const knobDeg = ( this . endDegree - this . startDegree ) * percent + this . startDegree ;
54
65
55
66
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
+ />
56
79
< svg
80
+ role ="slider "
57
81
width ="20mm "
58
82
height ="20mm "
59
83
version ="1.1 "
60
84
viewBox ="0 0 20 20 "
61
85
xmlns ="http://www.w3.org/2000/svg "
86
+ @click ="${ this . focusInput } "
62
87
@mousedown =${ this . down }
63
88
@mousemove =${ this . move }
64
89
@mouseup=${ this . up }
@@ -69,6 +94,11 @@ export class PotentiometerElement extends LitElement {
69
94
'--knob-angle' : knobDeg + 'deg' ,
70
95
} ) }
71
96
>
97
+ < defs >
98
+ < filter id ="outline ">
99
+ < feDropShadow id ="glow " dx ="0 " dy ="0 " stdDeviation ="0.5 " flood-color ="cyan " />
100
+ </ filter >
101
+ </ defs >
72
102
< rect
73
103
x =".15 "
74
104
y =".15 "
@@ -120,6 +150,18 @@ export class PotentiometerElement extends LitElement {
120
150
` ;
121
151
}
122
152
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
+
123
165
private down ( event : MouseEvent ) {
124
166
if ( event . button === 0 || window . navigator . maxTouchPoints ) {
125
167
this . pressed = true ;
You can’t perform that action at this time.
0 commit comments