@thednp/color-picker 0.0.1-alpha1 → 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (41) hide show
  1. package/LICENSE +1 -1
  2. package/README.md +63 -26
  3. package/dist/css/color-picker.css +504 -337
  4. package/dist/css/color-picker.min.css +2 -0
  5. package/dist/css/color-picker.rtl.css +529 -0
  6. package/dist/css/color-picker.rtl.min.css +2 -0
  7. package/dist/js/color-picker-element-esm.js +3851 -2
  8. package/dist/js/color-picker-element-esm.min.js +2 -0
  9. package/dist/js/color-picker-element.js +2086 -1278
  10. package/dist/js/color-picker-element.min.js +2 -2
  11. package/dist/js/color-picker-esm.js +3742 -0
  12. package/dist/js/color-picker-esm.min.js +2 -0
  13. package/dist/js/color-picker.js +2030 -1286
  14. package/dist/js/color-picker.min.js +2 -2
  15. package/package.json +18 -9
  16. package/src/js/color-palette.js +71 -0
  17. package/src/js/color-picker-element.js +62 -16
  18. package/src/js/color-picker.js +734 -618
  19. package/src/js/color.js +621 -358
  20. package/src/js/index.js +0 -9
  21. package/src/js/util/colorNames.js +2 -152
  22. package/src/js/util/colorPickerLabels.js +22 -0
  23. package/src/js/util/getColorControls.js +103 -0
  24. package/src/js/util/getColorForm.js +26 -19
  25. package/src/js/util/getColorMenu.js +88 -0
  26. package/src/js/util/isValidJSON.js +13 -0
  27. package/src/js/util/nonColors.js +5 -0
  28. package/src/js/util/roundPart.js +9 -0
  29. package/src/js/util/setCSSProperties.js +12 -0
  30. package/src/js/util/tabindex.js +3 -0
  31. package/src/js/util/templates.js +1 -0
  32. package/src/scss/color-picker.rtl.scss +23 -0
  33. package/src/scss/color-picker.scss +449 -0
  34. package/types/cp.d.ts +263 -162
  35. package/types/index.d.ts +9 -2
  36. package/types/source/source.ts +2 -1
  37. package/types/source/types.d.ts +28 -5
  38. package/dist/js/color-picker.esm.js +0 -2998
  39. package/dist/js/color-picker.esm.min.js +0 -2
  40. package/src/js/util/getColorControl.js +0 -49
  41. package/src/js/util/init.js +0 -14
@@ -0,0 +1,449 @@
1
+ /* :host */
2
+ color-picker,
3
+ .color-picker {
4
+ position: relative;
5
+ display: flex;
6
+ }
7
+
8
+ color-picker:focus,
9
+ .color-picker:focus {
10
+ outline: none;
11
+ }
12
+
13
+ /* color-dropdown */
14
+ .color-dropdown {
15
+ position: absolute;
16
+ z-index: 50;
17
+ display: none;
18
+ flex-direction: column;
19
+ width: min-content;
20
+ padding: .5rem;
21
+ color: rgba(255,255,255,.8);
22
+ background: rgba(0,0,0,.75);
23
+ border-radius: .5rem;
24
+ box-shadow: 0 6px 12px rgba(0, 0, 0, .4);
25
+ opacity: 0;
26
+ transition: transform .33s ease, opacity .33s ease;
27
+ }
28
+
29
+ .color-dropdown.picker { left: 0; }
30
+ .color-dropdown.menu { right: 0; }
31
+
32
+ .open .color-dropdown.top {
33
+ top: auto;
34
+ bottom: 100%;
35
+ }
36
+ .color-dropdown.bottom { top: 100%; }
37
+
38
+ .open .color-dropdown.top,
39
+ .open .color-dropdown.bottom {
40
+ display: flex;
41
+ }
42
+
43
+ .color-dropdown.show {
44
+ opacity: 1;
45
+ }
46
+ .color-dropdown.show.top { transform: translate(0, -5px); }
47
+ .color-dropdown.show.bottom { transform: translate(0, 5px); }
48
+
49
+ /* color-controls */
50
+ .color-controls {
51
+ display: none;
52
+ flex-wrap: wrap;
53
+ justify-content: space-between;
54
+ width: max-content;
55
+ }
56
+
57
+ /* btn-appearance */
58
+ .btn-appearance {
59
+ width: 100%;
60
+ height: 1.5rem;
61
+ padding: .6rem 1rem;
62
+ font-size: 1rem;
63
+ line-height: 1.5;
64
+ border: 0;
65
+ border-radius: .25rem;
66
+ outline: none;
67
+ appearance: none;
68
+ transition-duration: .33s;
69
+ transition-property: box-shadow, border;
70
+ }
71
+ .btn-appearance:focus,
72
+ .btn-appearance:hover {
73
+ box-shadow: 0 0 0 3px rgba(0,0,0,.15);
74
+ }
75
+
76
+ /* color-preview */
77
+ .color-preview {
78
+ box-shadow: 0 0 0 1px rgba(120,120,120,.33) inset;
79
+ direction: ltr; /* color value can never be rtl */
80
+ }
81
+
82
+ .txt-dark .color-preview {
83
+ color: rgba(255,255,255,.8);
84
+ }
85
+ .txt-dark .color-preview:focus {
86
+ box-shadow: 0 0 0 1px rgb(255,255,255) inset, 0 0 0 3px rgba(0,0,0,.15);
87
+ }
88
+ .txt-dark .color-preview::placeholder {
89
+ color: rgba(255,255,255,.6);
90
+ }
91
+ .txt-light .color-preview {
92
+ color: rgba(0,0,0,.8);
93
+ }
94
+ .txt-light .color-preview:focus {
95
+ color: rgba(0,0,0,.8);
96
+ box-shadow: 0 0 0 1px rgba(0,0,0,.5) inset, 0 0 0 3px rgba(0,0,0,.15);
97
+ }
98
+ .txt-light .color-preview::placeholder {
99
+ color: rgba(0,0,0,.6);
100
+ }
101
+
102
+ /* picker-toggle */
103
+ .picker-toggle {
104
+ position: absolute;
105
+ top: 0;
106
+ left: 0;
107
+ width: 100%;
108
+ height: 100%;
109
+ background: transparent;
110
+ border: 0;
111
+ }
112
+
113
+ .open .picker-toggle {
114
+ z-index: -1;
115
+ }
116
+
117
+ /* menu-toggle */
118
+ .menu-toggle {
119
+ position: absolute;
120
+ top: 0;
121
+ right: 0;
122
+ display: flex;
123
+ width: 3rem;
124
+ height: 100%;
125
+ padding: 0 .25rem;
126
+ cursor: pointer;
127
+ border: 0;
128
+ border-radius: 0 .25rem .25rem 0;
129
+ }
130
+ .txt-light .menu-toggle {
131
+ background: rgba(0,0,0,.5);
132
+ }
133
+ .txt-light .menu-toggle:focus,
134
+ .txt-light .menu-toggle:focus {
135
+ background: rgba(0,0,0,.7);
136
+ }
137
+ .txt-dark .menu-toggle {
138
+ background: rgba(255,255,255,.33);
139
+ }
140
+ .txt-dark .menu-toggle:focus,
141
+ .txt-dark .menu-toggle:focus {
142
+ background: rgba(255,255,255,.5);
143
+ }
144
+ .menu-toggle svg {
145
+ width: auto;
146
+ height: 100%;
147
+ }
148
+
149
+ /* scrollable */
150
+ .scrollable {
151
+ overflow-x: hidden;
152
+ overflow-y: auto;
153
+ scrollbar-width: thin;
154
+ }
155
+ .scrollable::-webkit-scrollbar {
156
+ width: .5rem;
157
+ }
158
+
159
+ .scrollable::-webkit-scrollbar-track {
160
+ background-color: transparent;
161
+ }
162
+
163
+ .scrollable::-webkit-scrollbar-thumb {
164
+ width: .5rem;
165
+ background-color: transparent;
166
+ background-clip: content-box;
167
+ border: 0;
168
+ }
169
+
170
+ .scrollable:hover::-webkit-scrollbar-thumb {
171
+ background-color: rgba(255,255,255,.33);
172
+ }
173
+
174
+ .scrollable::-webkit-scrollbar-thumb:hover {
175
+ background-color: #fff;
176
+ }
177
+
178
+ /* color-defaults */
179
+ .color-defaults {
180
+ display: none;
181
+ flex-wrap: wrap;
182
+ flex-flow: column;
183
+ margin: 0;
184
+ list-style: none;
185
+ padding-inline: 0; // Firefox
186
+ }
187
+
188
+ .color-dropdown.menu .color-defaults,
189
+ .color-dropdown.picker .color-controls {
190
+ display: flex;
191
+ }
192
+
193
+ .color-dropdown.menu {
194
+ max-height: 230px;
195
+ }
196
+
197
+ .color-defaults .color-option {
198
+ padding: .25rem .5rem;
199
+ color: inherit;
200
+ }
201
+
202
+ .color-option {
203
+ cursor: pointer;
204
+ }
205
+
206
+ .color-defaults .color-option:focus,
207
+ .color-defaults .color-option:hover {
208
+ background: rgba(255,255,255,.3);
209
+ outline: none;
210
+ }
211
+
212
+ .color-defaults .color-option:active,
213
+ .color-defaults .color-option.active {
214
+ color: #000;
215
+ background: #fff;
216
+ }
217
+
218
+ /* color-options grid */
219
+ .color-options {
220
+ display: grid;
221
+ padding: 0;
222
+ margin: 0;
223
+ list-style: none;
224
+ --grid-item-size: 2rem; // grid item width / height
225
+ --grid-fit: 5; // grid columns
226
+ --grid-gap: .25rem; // grid vertical / horizontal spacing
227
+ --grid-height: auto; // default height
228
+ --grid-hover-height: auto; // height on hover
229
+ grid-template-columns: repeat(var(--grid-fit), var(--grid-item-size));
230
+ grid-template-rows: repeat(auto-fill, var(--grid-item-size));
231
+ gap: var(--grid-gap);
232
+ }
233
+ .color-options.scrollable {
234
+ height: var(--grid-height);
235
+ margin: 0 -.5rem 0 0; // 0.5rem is the scrollbar width
236
+ overflow-y: scroll;
237
+ transition: height .33s ease;
238
+ }
239
+ .color-options.scrollable:hover {
240
+ height: var(--grid-hover-height);
241
+ }
242
+ .color-options + .color-defaults {
243
+ margin-top: .25rem;
244
+ }
245
+ .multiline + .color-defaults {
246
+ flex-direction: row;
247
+ flex-wrap: wrap;
248
+ .color-option {
249
+ padding: .25rem .33rem; font-size: 12px;
250
+ }
251
+ }
252
+ .color-options .color-option {
253
+ // hide any text
254
+ position: relative;
255
+ width: var(--grid-item-size);
256
+ height: var(--grid-item-size);
257
+ overflow: hidden;
258
+ text-indent: 2.1rem;
259
+ }
260
+ .color-options .color-option:active,
261
+ .color-options .color-option:focus {
262
+ outline: none;
263
+ }
264
+ .color-options .color-option::before {
265
+ position: absolute;
266
+ top: 0;
267
+ right: 0;
268
+ bottom: 0;
269
+ left: 0;
270
+ }
271
+ .color-options .color-option:hover::before,
272
+ .color-options .color-option:active::before,
273
+ .color-options .color-option:focus::before {
274
+ content: "";
275
+ border: 3px solid rgba(255,255,255.3,.75);
276
+ mix-blend-mode: difference;
277
+ }
278
+
279
+ .color-options .color-option:active,
280
+ .color-options .color-option:focus {
281
+ box-shadow: 0 0 0 4px rgba(125,125,125,.75) inset;
282
+ }
283
+
284
+ .color-options .color-option.active {
285
+ &:after {
286
+ position: absolute;
287
+ top: 50%;
288
+ left: 50%;
289
+ width: 4px;
290
+ height: 4px;
291
+ margin: -2px 0 0 -2px;
292
+ content: "";
293
+ border-radius: 4px;
294
+ }
295
+ }
296
+ .txt-dark .color-options .color-option.active:after {
297
+ box-shadow: 0 0 0 4px rgba(255,255,255,.9);
298
+ }
299
+ .txt-light .color-options .color-option.active:after {
300
+ box-shadow: 0 0 0 4px rgba(0,0,0,.9);
301
+ }
302
+
303
+ /* color-form */
304
+ .color-form {
305
+ display: flex;
306
+ flex-direction: row;
307
+ flex-wrap: wrap;
308
+ align-items: center;
309
+ padding: .25rem 0 0;
310
+ font: 12px sans-serif;
311
+ }
312
+
313
+ .color-form.hex { max-width: initial; }
314
+
315
+ .color-form > * {
316
+ flex: 1 0 0%;
317
+ width: 17.5%;
318
+ max-width: 17.5%;
319
+ }
320
+
321
+ .color-form label {
322
+ width: 7.5%;
323
+ max-width: 7.5%;
324
+ text-align: center;
325
+ }
326
+
327
+ .color-input {
328
+ color: inherit;
329
+ text-align: right;
330
+ background: transparent;
331
+ border: 1px solid rgba(255,255,255,.15);
332
+ outline: none;
333
+ }
334
+
335
+ .color-input.hex {
336
+ width: 92.5%;
337
+ max-width: 92.5%;
338
+ /* width: calc(100% - 4% - 1rem); */
339
+ }
340
+
341
+ .color-input:active,
342
+ .color-input:focus {
343
+ background: rgba(0,0,0,.25);
344
+ border: 1px solid rgba(255,255,255,.33);
345
+ }
346
+
347
+ /* visual control */
348
+ .visual-control {
349
+ height: 150px;
350
+ }
351
+
352
+ .visual-control1 {
353
+ width: 150px;
354
+ }
355
+ .visual-control2,
356
+ .visual-control3 {
357
+ width: 21px;
358
+ cursor: ns-resize;
359
+ }
360
+
361
+ @media (min-width: 578px) {
362
+ .visual-control { height: 230px; }
363
+ .visual-control1 { width: 230px; }
364
+ }
365
+
366
+ @media (min-width: 1200px) {
367
+ .visual-control { height: 300px; }
368
+ .visual-control1 { width: 300px; }
369
+ }
370
+
371
+ .color-control {
372
+ position: relative;
373
+ display: inline-block;
374
+ }
375
+
376
+ .color-slider {
377
+ left: 0;
378
+ width: calc(100% - 2px);
379
+ cursor: ns-resize;
380
+ }
381
+
382
+ .color-control + .color-control {
383
+ margin-left: .5rem;
384
+ }
385
+
386
+ /* knob */
387
+ .knob {
388
+ position: absolute;
389
+ top: 0;
390
+ left: 0;
391
+ height: 7px;
392
+ user-select: none;
393
+ background-color: #000;
394
+ border: 1px solid #fff;
395
+ border-radius: 5px;
396
+ outline: none;
397
+ will-change: transform;
398
+ }
399
+ .knob:hover {
400
+ box-shadow: 0 0 0 6px rgba(255,255,255,.5);
401
+ }
402
+ .knob:focus,
403
+ .knob:active {
404
+ z-index: 1;
405
+ box-shadow: 0 0 0 6px rgba(255,255,255,.9);
406
+ }
407
+
408
+ /* color-pointer */
409
+ .color-pointer {
410
+ width: 7px;
411
+ background-color: transparent;
412
+ border: 0;
413
+ }
414
+
415
+ .txt-dark .color-pointer {
416
+ box-shadow: 0 0 0 5px rgba(255,255,255,.5);
417
+ }
418
+ .txt-light .color-pointer {
419
+ box-shadow: 0 0 0 5px rgba(0,0,0,.5);
420
+ }
421
+
422
+ .txt-dark .color-pointer:hover {
423
+ box-shadow: 0 0 0 5px rgba(255,255,255,.75);
424
+ }
425
+ .txt-light .color-pointer:hover {
426
+ box-shadow: 0 0 0 5px rgba(0,0,0,.75);
427
+ }
428
+
429
+ .txt-dark .color-pointer:focus,
430
+ .txt-dark .color-pointer:active {
431
+ box-shadow: 0 0 0 5px rgba(255,255,255,.9);
432
+ }
433
+ .txt-light .color-pointer:focus,
434
+ .txt-light .color-pointer:active {
435
+ box-shadow: 0 0 0 5px rgba(0,0,0,.9);
436
+ }
437
+
438
+ /* utility */
439
+ .v-hidden {
440
+ position: absolute !important;
441
+ width: 1px !important;
442
+ height: 1px !important;
443
+ padding: 0 !important;
444
+ margin: -1px !important;
445
+ overflow: hidden !important;
446
+ clip: rect(0,0,0,0) !important;
447
+ white-space: nowrap !important;
448
+ border: 0 !important;
449
+ }