@thednp/color-picker 2.0.2 → 2.0.3
Sign up to get free protection for your applications and to get access to all the features.
- package/README.md +25 -14
- package/dist/css/color-picker.css +3 -6
- package/dist/css/color-picker.css.map +1 -0
- package/dist/css/color-picker.min.css +1 -2
- package/dist/css/color-picker.min.css.map +1 -0
- package/dist/css/color-picker.rtl.css +3 -6
- package/dist/css/color-picker.rtl.css.map +1 -0
- package/dist/css/color-picker.rtl.min.css +1 -2
- package/dist/css/color-picker.rtl.min.css.map +1 -0
- package/dist/js/color-picker.cjs +2 -2
- package/dist/js/color-picker.cjs.map +1 -1
- package/dist/js/color-picker.d.ts +307 -300
- package/dist/js/color-picker.js +2 -2
- package/dist/js/color-picker.js.map +1 -1
- package/dist/js/color-picker.mjs +369 -332
- package/dist/js/color-picker.mjs.map +1 -1
- package/package.json +36 -44
- package/.eslintrc.cjs +0 -199
- package/.lgtm.yml +0 -9
- package/.prettierrc.json +0 -15
- package/.stylelintrc.json +0 -236
- package/compile.cjs +0 -51
- package/dts.config.ts +0 -15
- package/src/scss/_variables.scss +0 -6
- package/src/scss/color-picker.rtl.scss +0 -27
- package/src/scss/color-picker.scss +0 -536
- package/src/ts/colorPalette.ts +0 -89
- package/src/ts/index.ts +0 -1237
- package/src/ts/interface/ColorNames.ts +0 -20
- package/src/ts/interface/colorPickerLabels.ts +0 -20
- package/src/ts/interface/colorPickerOptions.ts +0 -11
- package/src/ts/interface/paletteOptions.ts +0 -6
- package/src/ts/util/colorNames.ts +0 -21
- package/src/ts/util/colorPickerLabels.ts +0 -24
- package/src/ts/util/getColorControls.ts +0 -90
- package/src/ts/util/getColorForm.ts +0 -75
- package/src/ts/util/getColorMenu.ts +0 -83
- package/src/ts/util/isValidJSON.ts +0 -19
- package/src/ts/util/setMarkup.ts +0 -130
- package/src/ts/util/vHidden.ts +0 -2
- package/test/color-palette.test.ts +0 -137
- package/test/color-picker.test.ts +0 -705
- package/test/fixtures/colorNamesFrench.js +0 -3
- package/test/fixtures/componentLabelsFrench.js +0 -21
- package/test/fixtures/format.js +0 -3
- package/test/fixtures/getMarkup.js +0 -36
- package/test/fixtures/getRandomInt.js +0 -6
- package/test/fixtures/sampleWebcolors.js +0 -18
- package/test/fixtures/swipe.ts +0 -33
- package/test/fixtures/testSample.js +0 -8
- package/test/fixtures/write.ts +0 -37
- package/tsconfig.json +0 -47
- package/vite.config.mts +0 -27
- package/vitest.config-ui.ts +0 -26
- package/vitest.config.ts +0 -26
@@ -1,27 +0,0 @@
|
|
1
|
-
@import "color-picker";
|
2
|
-
|
3
|
-
[dir="rtl"] {
|
4
|
-
.color-preview { text-align: right; }
|
5
|
-
|
6
|
-
.menu-toggle {
|
7
|
-
right: auto; left: 0;
|
8
|
-
border-radius: .25rem 0 0 .25rem;
|
9
|
-
}
|
10
|
-
|
11
|
-
.color-dropdown.picker {
|
12
|
-
right: 0; left: auto;
|
13
|
-
}
|
14
|
-
|
15
|
-
.color-dropdown.menu {
|
16
|
-
right: auto; left: 0;
|
17
|
-
}
|
18
|
-
|
19
|
-
.color-control + .color-control {
|
20
|
-
margin-right: .5rem;
|
21
|
-
margin-left: 0;
|
22
|
-
}
|
23
|
-
|
24
|
-
.color-options.scrollable {
|
25
|
-
margin: 0 0 0 -.5rem;
|
26
|
-
}
|
27
|
-
}
|
@@ -1,536 +0,0 @@
|
|
1
|
-
@import "variables";
|
2
|
-
|
3
|
-
*, *::before, *::after {
|
4
|
-
box-sizing: border-box;
|
5
|
-
}
|
6
|
-
|
7
|
-
/* :host */
|
8
|
-
.color-picker {
|
9
|
-
position: relative;
|
10
|
-
display: flex;
|
11
|
-
|
12
|
-
@each $name in "white", "black" {
|
13
|
-
@each $lvl in $transparency-levels {
|
14
|
-
@if type-of($name) == "string" and type-of($lvl) == "number" {
|
15
|
-
$color: #fff;
|
16
|
-
|
17
|
-
@if $name == "black" {
|
18
|
-
$color: #000;
|
19
|
-
}
|
20
|
-
|
21
|
-
$rgba: rgba($color, $lvl * 1%);
|
22
|
-
|
23
|
-
--#{$name}-#{$lvl}: #{$rgba};
|
24
|
-
|
25
|
-
// --#{$name}-#{$lvl}: #{rgba($color, $lvl * 1%)};
|
26
|
-
}
|
27
|
-
}
|
28
|
-
}
|
29
|
-
|
30
|
-
--dropdown-transition: #{$dropdown-transition};
|
31
|
-
--btn-transition: #{$btn-transition};
|
32
|
-
--options-transition: #{$options-transition};
|
33
|
-
--dropdown-bg: var(--black-75);
|
34
|
-
--dropdown-color: var(--white-75);
|
35
|
-
--dropdown-shadow: 0 6px 12px var(--black-33);
|
36
|
-
--dropdown-scrollbar-bg: var(--white-33);
|
37
|
-
--dropdown-scrollbar-bg-hover: var(--white-50);
|
38
|
-
--knob-bg: #000;
|
39
|
-
--knob-border: 1px solid var(--white-90);
|
40
|
-
--knob-shadow-hover: 0 0 0 6px var(--white-50);
|
41
|
-
--knob-shadow-active: 0 0 0 6px var(--white-90);
|
42
|
-
--input-border: 1px solid var(--white-15);
|
43
|
-
--input-border-hover: 1px solid var(--white-33);
|
44
|
-
--input-bg-hover: var(--black-15);
|
45
|
-
--option-color-hover: var(--black-75);
|
46
|
-
--option-bg-hover: var(--white-50);
|
47
|
-
--option-color-active: var(--black-75);
|
48
|
-
--option-bg-active: var(--white-90);
|
49
|
-
--visual-shadow: 0 0 0 1px var(--white-15) inset;
|
50
|
-
}
|
51
|
-
|
52
|
-
.color-picker:focus {
|
53
|
-
outline: none;
|
54
|
-
}
|
55
|
-
|
56
|
-
/* color-dropdown */
|
57
|
-
.color-dropdown {
|
58
|
-
position: absolute;
|
59
|
-
z-index: 50;
|
60
|
-
display: none;
|
61
|
-
flex-direction: column;
|
62
|
-
width: min-content;
|
63
|
-
padding: .5rem;
|
64
|
-
color: var(--dropdown-color);
|
65
|
-
background: var(--dropdown-bg);
|
66
|
-
border-radius: .5rem;
|
67
|
-
box-shadow: var(--dropdown-shadow);
|
68
|
-
opacity: 0;
|
69
|
-
transition: var(--dropdown-transition);
|
70
|
-
}
|
71
|
-
|
72
|
-
.color-dropdown.picker { left: 0; }
|
73
|
-
|
74
|
-
.color-dropdown.menu {
|
75
|
-
right: 0;
|
76
|
-
max-height: 230px;
|
77
|
-
}
|
78
|
-
|
79
|
-
.open .color-dropdown.top {
|
80
|
-
top: auto;
|
81
|
-
bottom: 100%;
|
82
|
-
}
|
83
|
-
.color-dropdown.bottom { top: 100%; }
|
84
|
-
|
85
|
-
.open .color-dropdown.top,
|
86
|
-
.open .color-dropdown.bottom {
|
87
|
-
display: flex;
|
88
|
-
}
|
89
|
-
|
90
|
-
.color-dropdown.show {
|
91
|
-
opacity: 1;
|
92
|
-
}
|
93
|
-
.color-dropdown.show.top { transform: translate(0, -5px); }
|
94
|
-
.color-dropdown.show.bottom { transform: translate(0, 5px); }
|
95
|
-
|
96
|
-
/* color-controls */
|
97
|
-
.color-controls {
|
98
|
-
display: none;
|
99
|
-
flex-wrap: wrap;
|
100
|
-
justify-content: space-between;
|
101
|
-
width: max-content;
|
102
|
-
}
|
103
|
-
|
104
|
-
/* btn-appearance */
|
105
|
-
.btn-appearance {
|
106
|
-
width: 100%;
|
107
|
-
|
108
|
-
// height: 1.5rem;
|
109
|
-
padding: .6rem 1rem;
|
110
|
-
font-size: 1rem;
|
111
|
-
line-height: 1.5;
|
112
|
-
border: 0;
|
113
|
-
border-radius: .25rem;
|
114
|
-
outline: none;
|
115
|
-
appearance: none;
|
116
|
-
|
117
|
-
// transition-duration: .33s;
|
118
|
-
// transition-property: box-shadow, border;
|
119
|
-
transition: var(--btn-transition);
|
120
|
-
}
|
121
|
-
|
122
|
-
.btn-appearance:focus,
|
123
|
-
.btn-appearance:hover {
|
124
|
-
box-shadow: 0 0 0 3px var(--black-15);
|
125
|
-
}
|
126
|
-
|
127
|
-
/* color-preview */
|
128
|
-
.color-preview {
|
129
|
-
box-shadow: 0 0 0 1px rgba(120,120,120,33%) inset;
|
130
|
-
direction: ltr; /* color value can never be rtl */
|
131
|
-
}
|
132
|
-
|
133
|
-
.txt-dark .color-preview {
|
134
|
-
color: var(--white-75);
|
135
|
-
}
|
136
|
-
|
137
|
-
.txt-dark .color-preview:focus {
|
138
|
-
box-shadow: 0 0 0 1px #fff inset, 0 0 0 3px var(--black-15);
|
139
|
-
}
|
140
|
-
|
141
|
-
.txt-dark .color-preview::placeholder {
|
142
|
-
color: var(--white-50);
|
143
|
-
}
|
144
|
-
|
145
|
-
.txt-light .color-preview {
|
146
|
-
color: var(--black-75);
|
147
|
-
}
|
148
|
-
|
149
|
-
.txt-light .color-preview:focus {
|
150
|
-
color: var(--black-75);
|
151
|
-
box-shadow: 0 0 0 1px #000 inset, 0 0 0 3px var(--black-15);
|
152
|
-
}
|
153
|
-
|
154
|
-
.txt-light .color-preview::placeholder {
|
155
|
-
color: var(--black-50);
|
156
|
-
}
|
157
|
-
|
158
|
-
/* picker-toggle */
|
159
|
-
.picker-toggle {
|
160
|
-
position: absolute;
|
161
|
-
inset: 0;
|
162
|
-
width: 100%;
|
163
|
-
height: 100%;
|
164
|
-
cursor: pointer;
|
165
|
-
background: transparent;
|
166
|
-
border: 0;
|
167
|
-
}
|
168
|
-
|
169
|
-
.open .picker-toggle {
|
170
|
-
z-index: -1;
|
171
|
-
}
|
172
|
-
|
173
|
-
/* menu-toggle */
|
174
|
-
.menu-toggle {
|
175
|
-
position: absolute;
|
176
|
-
top: 0;
|
177
|
-
right: 0;
|
178
|
-
display: flex;
|
179
|
-
width: 3rem;
|
180
|
-
height: 100%;
|
181
|
-
padding: 0 .25rem;
|
182
|
-
cursor: pointer;
|
183
|
-
border: 0;
|
184
|
-
border-radius: 0 .25rem .25rem 0;
|
185
|
-
}
|
186
|
-
|
187
|
-
.txt-light .menu-toggle {
|
188
|
-
background: var(--black-50);
|
189
|
-
|
190
|
-
&:focus {
|
191
|
-
background: var(--black-75);
|
192
|
-
}
|
193
|
-
}
|
194
|
-
|
195
|
-
.txt-dark .menu-toggle {
|
196
|
-
background: var(--white-33);
|
197
|
-
|
198
|
-
&:focus {
|
199
|
-
background: var(--white-50);
|
200
|
-
}
|
201
|
-
}
|
202
|
-
|
203
|
-
.menu-toggle svg {
|
204
|
-
width: auto;
|
205
|
-
height: 100%;
|
206
|
-
}
|
207
|
-
|
208
|
-
/* scrollable */
|
209
|
-
.scrollable {
|
210
|
-
overflow: hidden auto;
|
211
|
-
|
212
|
-
// overflow-x: hidden;
|
213
|
-
// overflow-y: auto;
|
214
|
-
scrollbar-width: thin;
|
215
|
-
}
|
216
|
-
|
217
|
-
.scrollable::-webkit-scrollbar {
|
218
|
-
width: .5rem;
|
219
|
-
}
|
220
|
-
|
221
|
-
.scrollable::-webkit-scrollbar-track {
|
222
|
-
background-color: transparent;
|
223
|
-
}
|
224
|
-
|
225
|
-
.scrollable::-webkit-scrollbar-thumb {
|
226
|
-
width: .5rem;
|
227
|
-
background-color: transparent;
|
228
|
-
background-clip: content-box;
|
229
|
-
border: 0;
|
230
|
-
}
|
231
|
-
|
232
|
-
.scrollable:hover::-webkit-scrollbar-thumb {
|
233
|
-
background-color: var(--dropdown-scrollbar-bg);
|
234
|
-
}
|
235
|
-
|
236
|
-
.scrollable::-webkit-scrollbar-thumb:hover {
|
237
|
-
background-color: var(--dropdown-scrollbar-bg-hover);
|
238
|
-
}
|
239
|
-
|
240
|
-
/* color-defaults */
|
241
|
-
.color-defaults {
|
242
|
-
display: none;
|
243
|
-
|
244
|
-
// flex-wrap: ;
|
245
|
-
flex-flow: column wrap;
|
246
|
-
margin: 0;
|
247
|
-
list-style: none;
|
248
|
-
padding-inline: 0; // Firefox
|
249
|
-
}
|
250
|
-
|
251
|
-
.color-dropdown.menu .color-defaults,
|
252
|
-
.color-dropdown.picker .color-controls {
|
253
|
-
display: flex;
|
254
|
-
}
|
255
|
-
|
256
|
-
// .color-dropdown.menu {
|
257
|
-
// max-height: 230px;
|
258
|
-
// }
|
259
|
-
|
260
|
-
.color-defaults .color-option {
|
261
|
-
padding: .25rem .5rem;
|
262
|
-
color: inherit;
|
263
|
-
}
|
264
|
-
|
265
|
-
.color-option {
|
266
|
-
cursor: pointer;
|
267
|
-
}
|
268
|
-
|
269
|
-
.color-defaults .color-option:focus,
|
270
|
-
.color-defaults .color-option:hover {
|
271
|
-
color: var(--option-color-hover);
|
272
|
-
background: var(--option-bg-hover);
|
273
|
-
outline: none;
|
274
|
-
}
|
275
|
-
|
276
|
-
.color-defaults .color-option:active,
|
277
|
-
.color-defaults .color-option.active {
|
278
|
-
color: var(--option-color-active);
|
279
|
-
background: var(--option-bg-active);
|
280
|
-
}
|
281
|
-
|
282
|
-
/* color-options grid */
|
283
|
-
.color-options {
|
284
|
-
--grid-item-size: 2rem; // grid item width / height
|
285
|
-
--grid-fit: 5; // grid columns
|
286
|
-
--grid-gap: .25rem; // grid vertical / horizontal spacing
|
287
|
-
--grid-height: auto; // default height
|
288
|
-
--grid-hover-height: auto; // height on hover
|
289
|
-
|
290
|
-
display: grid;
|
291
|
-
padding: 0;
|
292
|
-
margin: 0;
|
293
|
-
list-style: none;
|
294
|
-
grid-template-columns: repeat(var(--grid-fit), var(--grid-item-size));
|
295
|
-
grid-template-rows: repeat(auto-fill, var(--grid-item-size));
|
296
|
-
gap: var(--grid-gap);
|
297
|
-
}
|
298
|
-
|
299
|
-
.color-options.scrollable {
|
300
|
-
height: var(--grid-height);
|
301
|
-
margin: 0 -.5rem 0 0; // 0.5rem is the scrollbar width
|
302
|
-
overflow-y: scroll;
|
303
|
-
transition: var(--options-transition);
|
304
|
-
}
|
305
|
-
|
306
|
-
// .color-options.scrollable:hover {
|
307
|
-
.color-dropdown.menu:hover .scrollable {
|
308
|
-
height: var(--grid-hover-height);
|
309
|
-
}
|
310
|
-
|
311
|
-
.color-options + .color-defaults {
|
312
|
-
margin-top: .25rem;
|
313
|
-
}
|
314
|
-
|
315
|
-
.multiline + .color-defaults {
|
316
|
-
flex-flow: row wrap;
|
317
|
-
|
318
|
-
.color-option {
|
319
|
-
padding: .25rem .33rem; font-size: 12px;
|
320
|
-
}
|
321
|
-
}
|
322
|
-
|
323
|
-
.color-options .color-option {
|
324
|
-
// hide any text
|
325
|
-
position: relative;
|
326
|
-
width: var(--grid-item-size);
|
327
|
-
height: var(--grid-item-size);
|
328
|
-
overflow: hidden;
|
329
|
-
color: rgba(0,0,0,0%);
|
330
|
-
|
331
|
-
&:active, &:focus {
|
332
|
-
outline: none;
|
333
|
-
box-shadow: 0 0 0 4px rgba(125,125,125,75%) inset;
|
334
|
-
}
|
335
|
-
}
|
336
|
-
|
337
|
-
// .color-options .color-option:active,
|
338
|
-
// .color-options .color-option:focus {
|
339
|
-
// outline: none;
|
340
|
-
// }
|
341
|
-
|
342
|
-
.color-options .color-option::before {
|
343
|
-
position: absolute;
|
344
|
-
inset: 0;
|
345
|
-
}
|
346
|
-
|
347
|
-
.color-options .color-option:hover::before,
|
348
|
-
.color-options .color-option:active::before,
|
349
|
-
.color-options .color-option:focus::before {
|
350
|
-
content: "";
|
351
|
-
border: 3px solid var(--white-75);
|
352
|
-
mix-blend-mode: difference;
|
353
|
-
}
|
354
|
-
|
355
|
-
// .color-options .color-option {
|
356
|
-
// &:active, &:focus {
|
357
|
-
// outline: none;
|
358
|
-
// box-shadow: 0 0 0 4px rgba(125,125,125,75%) inset;
|
359
|
-
// }
|
360
|
-
// }
|
361
|
-
|
362
|
-
.color-options .color-option.active {
|
363
|
-
&::after {
|
364
|
-
position: absolute;
|
365
|
-
top: 50%;
|
366
|
-
left: 50%;
|
367
|
-
width: 4px;
|
368
|
-
height: 4px;
|
369
|
-
margin: -2px 0 0 -2px;
|
370
|
-
content: "";
|
371
|
-
border-radius: 4px;
|
372
|
-
}
|
373
|
-
}
|
374
|
-
|
375
|
-
.txt-dark .color-options .color-option.active::after {
|
376
|
-
box-shadow: 0 0 0 4px var(--white-90);
|
377
|
-
}
|
378
|
-
|
379
|
-
.txt-light .color-options .color-option.active::after {
|
380
|
-
box-shadow: 0 0 0 4px var(--black-90);
|
381
|
-
}
|
382
|
-
|
383
|
-
/* color-form */
|
384
|
-
.color-form {
|
385
|
-
display: flex;
|
386
|
-
flex-flow: row wrap;
|
387
|
-
align-items: center;
|
388
|
-
padding: .25rem 0 0;
|
389
|
-
font: 12px sans-serif;
|
390
|
-
}
|
391
|
-
|
392
|
-
.color-form.hex { max-width: initial; }
|
393
|
-
|
394
|
-
.color-form > * {
|
395
|
-
flex: 1 0 0%;
|
396
|
-
width: 17.5%;
|
397
|
-
max-width: 17.5%;
|
398
|
-
}
|
399
|
-
|
400
|
-
.color-form label {
|
401
|
-
width: 7.5%;
|
402
|
-
max-width: 7.5%;
|
403
|
-
text-align: center;
|
404
|
-
}
|
405
|
-
|
406
|
-
.color-input {
|
407
|
-
color: inherit;
|
408
|
-
text-align: right;
|
409
|
-
background: transparent;
|
410
|
-
border: var(--input-border);
|
411
|
-
outline: none;
|
412
|
-
}
|
413
|
-
|
414
|
-
.color-input.hex {
|
415
|
-
width: 92.5%;
|
416
|
-
max-width: 92.5%;
|
417
|
-
}
|
418
|
-
|
419
|
-
.color-input:active,
|
420
|
-
.color-input:focus {
|
421
|
-
background: var(--input-bg-hover);
|
422
|
-
border: var(--input-border-hover);
|
423
|
-
}
|
424
|
-
|
425
|
-
/* visual control */
|
426
|
-
.visual-control {
|
427
|
-
height: 230px;
|
428
|
-
|
429
|
-
/* important for mobile devices */
|
430
|
-
touch-action: none;
|
431
|
-
box-shadow: var(--visual-shadow);
|
432
|
-
}
|
433
|
-
|
434
|
-
.visual-control1 {
|
435
|
-
width: 230px;
|
436
|
-
}
|
437
|
-
|
438
|
-
.visual-control2,
|
439
|
-
.visual-control3 {
|
440
|
-
width: 21px;
|
441
|
-
cursor: ns-resize;
|
442
|
-
}
|
443
|
-
|
444
|
-
@media (width >= 980px) {
|
445
|
-
.visual-control { height: 300px; }
|
446
|
-
.visual-control1 { width: 300px; }
|
447
|
-
}
|
448
|
-
|
449
|
-
.color-control {
|
450
|
-
position: relative;
|
451
|
-
display: inline-block;
|
452
|
-
}
|
453
|
-
|
454
|
-
.color-slider {
|
455
|
-
left: 0;
|
456
|
-
width: calc(100% - 2px);
|
457
|
-
cursor: ns-resize;
|
458
|
-
}
|
459
|
-
|
460
|
-
.color-control + .color-control {
|
461
|
-
margin-left: .5rem;
|
462
|
-
}
|
463
|
-
|
464
|
-
/* knob */
|
465
|
-
.knob {
|
466
|
-
position: absolute;
|
467
|
-
top: 0;
|
468
|
-
left: 0;
|
469
|
-
width: 100%;
|
470
|
-
height: 7px;
|
471
|
-
|
472
|
-
/* important for mobile devices */
|
473
|
-
touch-action: none;
|
474
|
-
user-select: none;
|
475
|
-
background-color: var(--knob-bg);
|
476
|
-
border: var(--knob-border);
|
477
|
-
border-radius: 5px;
|
478
|
-
outline: none;
|
479
|
-
will-change: transform;
|
480
|
-
}
|
481
|
-
|
482
|
-
.knob:hover {
|
483
|
-
box-shadow: var(--knob-shadow-hover);
|
484
|
-
}
|
485
|
-
|
486
|
-
.knob:focus,
|
487
|
-
.knob:active {
|
488
|
-
z-index: 1;
|
489
|
-
box-shadow: var(--knob-shadow-active);
|
490
|
-
}
|
491
|
-
|
492
|
-
/* color-pointer */
|
493
|
-
.color-pointer {
|
494
|
-
width: 7px;
|
495
|
-
background-color: transparent;
|
496
|
-
border: 0;
|
497
|
-
}
|
498
|
-
|
499
|
-
.txt-dark .color-pointer {
|
500
|
-
box-shadow: 0 0 0 5px var(--white-50);
|
501
|
-
}
|
502
|
-
|
503
|
-
.txt-light .color-pointer {
|
504
|
-
box-shadow: 0 0 0 5px var(--black-50);
|
505
|
-
}
|
506
|
-
|
507
|
-
.txt-dark .color-pointer:hover {
|
508
|
-
box-shadow: 0 0 0 5px var(--white-75);
|
509
|
-
}
|
510
|
-
|
511
|
-
.txt-light .color-pointer:hover {
|
512
|
-
box-shadow: 0 0 0 5px var(--black-75);
|
513
|
-
}
|
514
|
-
|
515
|
-
.txt-dark .color-pointer:focus,
|
516
|
-
.txt-dark .color-pointer:active {
|
517
|
-
box-shadow: 0 0 0 5px var(--white-90);
|
518
|
-
}
|
519
|
-
|
520
|
-
.txt-light .color-pointer:focus,
|
521
|
-
.txt-light .color-pointer:active {
|
522
|
-
box-shadow: 0 0 0 5px var(--black-90);
|
523
|
-
}
|
524
|
-
|
525
|
-
/* utility */
|
526
|
-
.v-hidden {
|
527
|
-
position: absolute !important;
|
528
|
-
width: 1px !important;
|
529
|
-
height: 1px !important;
|
530
|
-
padding: 0 !important;
|
531
|
-
margin: -1px !important;
|
532
|
-
overflow: hidden !important;
|
533
|
-
clip: rect(0,0,0,0) !important;
|
534
|
-
white-space: nowrap !important;
|
535
|
-
border: 0 !important;
|
536
|
-
}
|
package/src/ts/colorPalette.ts
DELETED
@@ -1,89 +0,0 @@
|
|
1
|
-
import Color from '@thednp/color';
|
2
|
-
// import { isNumber } from '@thednp/shorty';
|
3
|
-
|
4
|
-
/**
|
5
|
-
* Returns a color palette with a given set of parameters.
|
6
|
-
*
|
7
|
-
* @example
|
8
|
-
* new ColorPalette(0, 12, 10, 80);
|
9
|
-
* // => { hue: 0, hueSteps: 12, lightSteps: 10, saturation: 80, colors: Array<Color> }
|
10
|
-
*/
|
11
|
-
export default class ColorPalette {
|
12
|
-
public static Color = Color;
|
13
|
-
hue: number;
|
14
|
-
hueSteps: number;
|
15
|
-
lightSteps: number;
|
16
|
-
saturation: number;
|
17
|
-
colors: Color[];
|
18
|
-
/**
|
19
|
-
* The `hue` parameter is optional, which would be set to 0.
|
20
|
-
* * `args.hue` the starting Hue [0, 360]
|
21
|
-
* * `args.hueSteps` Hue Steps Count [5, 24]
|
22
|
-
* * `args.lightSteps` Lightness Steps Count [5, 12]
|
23
|
-
* * `args.saturation` Saturation [0, 100]
|
24
|
-
*/
|
25
|
-
constructor(...args: [number?, number?, number?, number?]) {
|
26
|
-
let hue = 0;
|
27
|
-
let hueSteps = 12;
|
28
|
-
let lightSteps = 10;
|
29
|
-
let lightnessArray = [0.5];
|
30
|
-
let saturation = 100;
|
31
|
-
// if (!args.every(n => isNumber(n))) throw TypeError('ColorPalette only accepts numbers.');
|
32
|
-
|
33
|
-
if (args.length === 4) {
|
34
|
-
[hue, hueSteps, lightSteps, saturation] = args as [number, number, number, number];
|
35
|
-
} else if (args.length === 3) {
|
36
|
-
[hue, hueSteps, lightSteps] = args as [number, number, number];
|
37
|
-
} else if (args.length === 2) {
|
38
|
-
[hueSteps, lightSteps] = args as [number, number];
|
39
|
-
if ([hueSteps, lightSteps].some(n => n < 1)) {
|
40
|
-
throw TypeError('ColorPalette: the two minimum arguments must be numbers higher than 0.');
|
41
|
-
}
|
42
|
-
}
|
43
|
-
|
44
|
-
const colors: Color[] = [];
|
45
|
-
const hueStep = 360 / hueSteps;
|
46
|
-
const half = Color.roundPart((lightSteps - (lightSteps % 2 ? 1 : 0)) / 2);
|
47
|
-
const steps1To13 = [0.25, 0.2, 0.15, 0.11, 0.09, 0.075];
|
48
|
-
const lightSets = [
|
49
|
-
[1, 2, 3],
|
50
|
-
[4, 5],
|
51
|
-
[6, 7],
|
52
|
-
[8, 9],
|
53
|
-
[10, 11],
|
54
|
-
[12, 13],
|
55
|
-
];
|
56
|
-
const closestSet = lightSets.find(set => set.includes(lightSteps));
|
57
|
-
|
58
|
-
// find a lightStep that won't go beyond black and white
|
59
|
-
// something within the [10-90] range of lightness
|
60
|
-
const lightStep = closestSet
|
61
|
-
? steps1To13[lightSets.indexOf(closestSet)]
|
62
|
-
: 100 / (lightSteps + (lightSteps % 2 ? 0 : 1)) / 100;
|
63
|
-
|
64
|
-
// light tints
|
65
|
-
for (let i = 1; i < half + 1; i += 1) {
|
66
|
-
lightnessArray = [...lightnessArray, 0.5 + lightStep * i];
|
67
|
-
}
|
68
|
-
|
69
|
-
// dark tints
|
70
|
-
for (let i = 1; i < lightSteps - half; i += 1) {
|
71
|
-
lightnessArray = [0.5 - lightStep * i, ...lightnessArray];
|
72
|
-
}
|
73
|
-
|
74
|
-
// feed `colors` Array
|
75
|
-
for (let i = 0; i < hueSteps; i += 1) {
|
76
|
-
const currentHue = (hue + i * hueStep) % 360;
|
77
|
-
lightnessArray.forEach(l => {
|
78
|
-
const newColor = new Color({ h: currentHue, s: 100, l: l * 100 });
|
79
|
-
colors.push(saturation < 100 ? newColor.saturate(saturation - 100) : newColor);
|
80
|
-
});
|
81
|
-
}
|
82
|
-
|
83
|
-
this.hue = hue;
|
84
|
-
this.hueSteps = hueSteps;
|
85
|
-
this.lightSteps = lightSteps;
|
86
|
-
this.saturation = saturation;
|
87
|
-
this.colors = colors;
|
88
|
-
}
|
89
|
-
}
|