1
- import { html , createRef , ref } from "/static/vendor/js/lit-all.v3.2.1.min.js" ;
1
+ import { html , createRef , ref , nothing } from "/static/vendor/js/lit-all.v3.2.1.min.js" ;
2
2
import { LitWrapper } from "/static/js/common/lit-wrapper.js" ;
3
3
import { triggerActionOnForm } from "/static/js/jobboard/filters.js" ;
4
4
5
5
export class InputRange extends LitWrapper {
6
6
static properties = {
7
- form : { type : String } ,
8
- name : { type : String } ,
7
+ form : { type : String | undefined } ,
8
+ name : { type : String | undefined } ,
9
9
min : { type : Number } ,
10
10
max : { type : Number } ,
11
11
step : { type : Number } ,
@@ -14,13 +14,14 @@ export class InputRange extends LitWrapper {
14
14
unit : { type : String } ,
15
15
legendsNumber : { type : Number } ,
16
16
visibleTooltip : { type : Boolean } ,
17
+ type : { type : String } ,
17
18
} ;
18
19
19
20
inputRef = createRef ( ) ;
20
21
21
22
constructor ( ) {
22
23
super ( ) ;
23
- this . form = "" ;
24
+ this . form = undefined ;
24
25
this . name = undefined ;
25
26
this . min = 0 ;
26
27
this . max = 100 ;
@@ -33,6 +34,27 @@ export class InputRange extends LitWrapper {
33
34
this . legendsNumber = 5 ;
34
35
this . visibleTooltip = false ;
35
36
this . steps = [ ] ;
37
+ this . type = "type-1" ;
38
+ this . colors = {
39
+ "type-1" : {
40
+ "progress-line" : "var(--color-primary-500)" ,
41
+ thumb : "accent-primary-600" ,
42
+ "bg-color" : "bg-primary-900" ,
43
+ peak : "border-b-primary-900" ,
44
+ } ,
45
+ "type-2" : {
46
+ "progress-line" : "var(--color-lime-500)" ,
47
+ thumb : "accent-lime-600" ,
48
+ "bg-color" : "bg-lime-900" ,
49
+ peak : "border-b-lime-900" ,
50
+ } ,
51
+ "type-3" : {
52
+ "progress-line" : "var(--color-lime-300)" ,
53
+ thumb : "accent-lime-400" ,
54
+ "bg-color" : "bg-lime-800" ,
55
+ peak : "border-b-lime-800" ,
56
+ } ,
57
+ } ;
36
58
}
37
59
38
60
connectedCallback ( ) {
@@ -103,51 +125,39 @@ export class InputRange extends LitWrapper {
103
125
render ( ) {
104
126
return html `
105
127
< div class ="relative ">
106
- ${ this . form !== ""
107
- ? html `< input
108
- ${ ref ( this . inputRef ) }
109
- form ="${ this . form } "
110
- name ="${ this . name } "
111
- type ="range "
112
- @input =${ this . _onInputChange }
113
- @mousedown =${ ( ) => this . _updateTooltipVisibility ( true ) }
114
- @mouseup=${ this . _mouseup }
115
- min="${ this . min } "
116
- max="${ this . max } "
117
- step="${ this . step } "
118
- value="${ this . value } "
119
- class="w-full h-2 bg-stone-200 rounded-lg appearance-none cursor-pointer accent-primary-300"
120
- style="background-image: linear-gradient(90deg, var(--color-primary-500) 0%, var(--color-primary-500) ${ this
121
- . percentValue } %, rgb(231 229 228 / var(--tw-bg-opacity, 1)) ${ this
122
- . percentValue } %, rgb(231 229 228 / var(--tw-bg-opacity, 1)) 100%);"
123
- /> `
124
- : html `< input
125
- ${ ref ( this . inputRef ) }
126
- name ="${ this . name } "
127
- type ="range "
128
- @input =${ this . _onInputChange }
129
- @mousedown =${ ( ) => this . _updateTooltipVisibility ( true ) }
130
- @mouseup=${ this . _mouseup }
131
- min="${ this . min } "
132
- max="${ this . max } "
133
- step="${ this . step } "
134
- value="${ this . value } "
135
- class="w-full h-2 bg-stone-200 rounded-lg appearance-none cursor-pointer accent-primary-300"
136
- style="background-image: linear-gradient(90deg, var(--color-primary-500) 0%, var(--color-primary-500) ${ this
137
- . percentValue } %, rgb(231 229 228 / var(--tw-bg-opacity, 1)) ${ this
138
- . percentValue } %, rgb(231 229 228 / var(--tw-bg-opacity, 1)) 100%);"
139
- /> ` }
128
+ < input
129
+ ${ ref ( this . inputRef ) }
130
+ form ="${ this . form || nothing } "
131
+ name ="${ this . name } "
132
+ type ="range "
133
+ @input =${ this . _onInputChange }
134
+ @mousedown =${ ( ) => this . _updateTooltipVisibility ( true ) }
135
+ @mouseup=${ this . _mouseup }
136
+ min="${ this . min } "
137
+ max="${ this . max } "
138
+ step="${ this . step } "
139
+ value="${ this . value } "
140
+ class="w-full h-2 bg-stone-200 rounded-lg appearance-none cursor-pointer ${ this . colors [ this . type ]
141
+ . thumb } "
142
+ style="background-image: linear-gradient(90deg, ${ this . colors [ this . type ] [
143
+ "progress-line"
144
+ ] } 0%, ${ this . colors [ this . type ] [ "progress-line" ] } ${ this
145
+ . percentValue } %, rgb(231 229 228 / var(--tw-bg-opacity, 1)) ${ this
146
+ . percentValue } %, rgb(231 229 228 / var(--tw-bg-opacity, 1)) 100%);"
147
+ />
140
148
< div
141
149
role ="tooltip "
142
150
class ="duration-100 transition-opacity ${ this . visibleTooltip
143
151
? ""
144
- : "opacity-0" } absolute z-10 inline-block px-2 py-1 text-sm font-medium text-white text-center bg-primary-900 rounded-lg shadow-xs tooltip top-8 start-[8.5px] -ms-8 w-16 "
152
+ : "opacity-0" } absolute z-10 inline-block px-2 py-1 text-sm font-medium text-white text-center ${ this
153
+ . colors [ this . type ] [ "bg-color" ] } rounded-lg shadow-xs tooltip top-8 start-[8.5px] -ms-8 w-16 "
145
154
style ="left: calc(${ this . percentValue } % + ${ this . offset } px); "
146
155
>
147
156
< small > ${ this . prefix } </ small > < span > ${ this . _prettyNumber ( this . value ) } </ span
148
157
> < small > ${ this . unit } </ small >
149
158
< div
150
- class ="h-0 w-0 border-x-[6px] border-x-transparent border-b-[6px] border-b-primary-900 absolute -top-1.5 start-[25px] "
159
+ class ="h-0 w-0 border-x-[6px] border-x-transparent border-b-[6px] ${ this . colors [ this . type ]
160
+ . peak } absolute -top-1.5 start-[calc(50%-6px)] "
151
161
> </ div >
152
162
</ div >
153
163
< div class ="mx-[15px] ">
0 commit comments