@thednp/color-picker 0.0.1-alpha1 → 0.0.1-alpha2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (38) hide show
  1. package/LICENSE +1 -1
  2. package/README.md +40 -19
  3. package/dist/css/color-picker.css +481 -337
  4. package/dist/css/color-picker.min.css +2 -0
  5. package/dist/css/color-picker.rtl.css +506 -0
  6. package/dist/css/color-picker.rtl.min.css +2 -0
  7. package/dist/js/color-picker-element-esm.js +3810 -2
  8. package/dist/js/color-picker-element-esm.min.js +2 -0
  9. package/dist/js/color-picker-element.js +2009 -1242
  10. package/dist/js/color-picker-element.min.js +2 -2
  11. package/dist/js/color-picker-esm.js +3704 -0
  12. package/dist/js/color-picker-esm.min.js +2 -0
  13. package/dist/js/color-picker.js +1962 -1256
  14. package/dist/js/color-picker.min.js +2 -2
  15. package/package.json +18 -9
  16. package/src/js/color-palette.js +62 -0
  17. package/src/js/color-picker-element.js +55 -13
  18. package/src/js/color-picker.js +686 -595
  19. package/src/js/color.js +615 -349
  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 +27 -19
  25. package/src/js/util/getColorMenu.js +95 -0
  26. package/src/js/util/isValidJSON.js +13 -0
  27. package/src/js/util/nonColors.js +5 -0
  28. package/src/js/util/templates.js +1 -0
  29. package/src/scss/color-picker.rtl.scss +23 -0
  30. package/src/scss/color-picker.scss +430 -0
  31. package/types/cp.d.ts +263 -160
  32. package/types/index.d.ts +9 -2
  33. package/types/source/source.ts +2 -1
  34. package/types/source/types.d.ts +28 -5
  35. package/dist/js/color-picker.esm.js +0 -2998
  36. package/dist/js/color-picker.esm.min.js +0 -2
  37. package/src/js/util/getColorControl.js +0 -49
  38. package/src/js/util/init.js +0 -14
@@ -0,0 +1,430 @@
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
+ // max-height: 160px;
184
+ margin: 0;
185
+ // overflow-y: auto;
186
+ list-style: none;
187
+ padding-inline: 0;
188
+ }
189
+
190
+ .color-dropdown.menu .color-defaults,
191
+ .color-dropdown.picker .color-controls {
192
+ display: flex;
193
+ }
194
+
195
+ .color-dropdown.menu {
196
+ max-height: 230px;
197
+ }
198
+
199
+ .color-defaults .color-option {
200
+ padding: .25rem .5rem;
201
+ color: inherit;
202
+ }
203
+
204
+ .color-option {
205
+ cursor: pointer;
206
+ }
207
+
208
+ .color-defaults .color-option:focus,
209
+ .color-defaults .color-option:hover {
210
+ background: rgba(255,255,255,.3);
211
+ outline: none;
212
+ }
213
+
214
+ .color-defaults .color-option:active,
215
+ .color-defaults .color-option.active {
216
+ color: #000;
217
+ background: #fff;
218
+ }
219
+
220
+ /* color-options grid */
221
+ .color-options {
222
+ display: grid;
223
+ padding: 0;
224
+ margin: 0;
225
+ list-style: none;
226
+ }
227
+ .color-options.scrollable {
228
+ margin: 0 -.5rem 0 0; // 0.5rem is the scrollbar width
229
+ overflow-y: scroll;
230
+ transition: height .33s ease;
231
+ }
232
+ .multiline + .color-defaults {
233
+ flex-direction: row;
234
+ flex-wrap: wrap;
235
+ margin-top: .25rem;
236
+ .color-option {
237
+ padding: .25rem .33rem; font-size: 12px;
238
+ }
239
+ }
240
+ .color-options .color-option {
241
+ // hide any text
242
+ position: relative;
243
+ overflow: hidden;
244
+ text-indent: 2.1rem;
245
+ background: #eee;
246
+ opacity: .8;
247
+ }
248
+ .color-options .color-option:hover,
249
+ .color-options .color-option:active,
250
+ .color-options .color-option:focus {
251
+ opacity: 1;
252
+ }
253
+ .color-options .color-option:active,
254
+ .color-options .color-option:focus {
255
+ outline: none;
256
+ }
257
+
258
+ .color-options .color-option:active,
259
+ .color-options .color-option:focus {
260
+ box-shadow: 0 0 0 4px rgba(125,125,125,.75) inset;
261
+ }
262
+
263
+ .color-options .color-option.active {
264
+ opacity: 1;
265
+ &:after {
266
+ position: absolute;
267
+ top: 50%;
268
+ left: 50%;
269
+ width: 4px;
270
+ height: 4px;
271
+ margin: -2px 0 0 -2px;
272
+ content: " ";
273
+ border-radius: 4px;
274
+ }
275
+ }
276
+ .txt-dark .color-options .color-option.active:after {
277
+ box-shadow: 0 0 0 4px rgba(255,255,255,.9);
278
+ }
279
+ .txt-light .color-options .color-option.active:after {
280
+ box-shadow: 0 0 0 4px rgba(0,0,0,.9);
281
+ }
282
+
283
+ /* color-form */
284
+ .color-form {
285
+ display: flex;
286
+ flex-direction: row;
287
+ flex-wrap: wrap;
288
+ align-items: center;
289
+ // max-width: fit-content;
290
+ padding: .5rem 0 0;
291
+ font: 12px sans-serif;
292
+ }
293
+
294
+ .color-form.hex { max-width: initial; }
295
+
296
+ .color-form > * {
297
+ flex: 1 0 0%;
298
+ width: 17.5%;
299
+ max-width: 17.5%;
300
+ }
301
+
302
+ .color-form label {
303
+ width: 7.5%;
304
+ max-width: 7.5%;
305
+ text-align: center;
306
+ }
307
+
308
+ .color-input {
309
+ color: inherit;
310
+ text-align: right;
311
+ background: transparent;
312
+ border: 1px solid rgba(255,255,255,.15);
313
+ outline: none;
314
+ }
315
+
316
+ .color-input.hex {
317
+ width: 92.5%;
318
+ max-width: 92.5%;
319
+ /* width: calc(100% - 4% - 1rem); */
320
+ }
321
+
322
+ .color-input:active,
323
+ .color-input:focus {
324
+ background: rgba(0,0,0,.25);
325
+ border: 1px solid rgba(255,255,255,.33);
326
+ }
327
+
328
+ /* visual control */
329
+ .visual-control {
330
+ height: 150px;
331
+ }
332
+
333
+ .visual-control1 {
334
+ width: 150px;
335
+ }
336
+ .visual-control2,
337
+ .visual-control3 {
338
+ width: 21px;
339
+ cursor: ns-resize;
340
+ }
341
+
342
+ @media (min-width: 578px) {
343
+ .visual-control { height: 230px; }
344
+ .visual-control1 { width: 230px; }
345
+ }
346
+
347
+ @media (min-width: 1200px) {
348
+ .visual-control { height: 300px; }
349
+ .visual-control1 { width: 300px; }
350
+ }
351
+
352
+ .color-control {
353
+ position: relative;
354
+ display: inline-block;
355
+ }
356
+
357
+ .color-slider {
358
+ left: 0;
359
+ width: calc(100% - 2px);
360
+ cursor: ns-resize;
361
+ }
362
+
363
+ .color-control + .color-control {
364
+ margin-left: .5rem;
365
+ }
366
+
367
+ /* knob */
368
+ .knob {
369
+ position: absolute;
370
+ top: 0;
371
+ left: 0;
372
+ height: 7px;
373
+ user-select: none;
374
+ background-color: #000;
375
+ border: 1px solid #fff;
376
+ outline: none;
377
+ will-change: transform;
378
+ }
379
+ .knob:hover {
380
+ box-shadow: 0 0 0 6px rgba(255,255,255,.5);
381
+ }
382
+ .knob:focus,
383
+ .knob:active {
384
+ z-index: 1;
385
+ box-shadow: 0 0 0 6px rgba(255,255,255,.9);
386
+ }
387
+
388
+ /* color-pointer */
389
+ .color-pointer {
390
+ width: 7px;
391
+ background-color: transparent;
392
+ border: 0;
393
+ border-radius: 5px;
394
+ }
395
+
396
+ .txt-dark .color-pointer {
397
+ box-shadow: 0 0 0 5px rgba(255,255,255,.5);
398
+ }
399
+ .txt-light .color-pointer {
400
+ box-shadow: 0 0 0 5px rgba(0,0,0,.5);
401
+ }
402
+
403
+ .txt-dark .color-pointer:hover {
404
+ box-shadow: 0 0 0 5px rgba(255,255,255,.75);
405
+ }
406
+ .txt-light .color-pointer:hover {
407
+ box-shadow: 0 0 0 5px rgba(0,0,0,.75);
408
+ }
409
+
410
+ .txt-dark .color-pointer:focus,
411
+ .txt-dark .color-pointer:active {
412
+ box-shadow: 0 0 0 5px rgba(255,255,255,.9);
413
+ }
414
+ .txt-light .color-pointer:focus,
415
+ .txt-light .color-pointer:active {
416
+ box-shadow: 0 0 0 5px rgba(0,0,0,.9);
417
+ }
418
+
419
+ /* utility */
420
+ .v-hidden {
421
+ position: absolute !important;
422
+ width: 1px !important;
423
+ height: 1px !important;
424
+ padding: 0 !important;
425
+ margin: -1px !important;
426
+ overflow: hidden !important;
427
+ clip: rect(0,0,0,0) !important;
428
+ white-space: nowrap !important;
429
+ border: 0 !important;
430
+ }