Repository navigation
Expand file tree
/
Copy pathindex.html
More file actions
1717 lines (1495 loc) · 69.7 KB
/
Copy pathindex.html
File metadata and controls
1717 lines (1495 loc) · 69.7 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>pixelpicker — dependency-free color picker</title>
<meta name="description" content="A dependency-free color picker for text inputs. Uses the Popover API and CSS Anchor Positioning, with a JavaScript fallback. MIT licensed.">
<link rel="canonical" href="https://mattopen.github.io/pixelpicker/">
<meta property="og:type" content="website">
<meta property="og:title" content="pixelpicker — dependency-free color picker">
<meta property="og:description" content="A dependency-free color picker for text inputs. The panel is a helper, never a replacement for the input field.">
<meta property="og:url" content="https://mattopen.github.io/pixelpicker/">
<link rel="icon" href="data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'><rect width='16' height='16' rx='3' fill='%23a0522d'/></svg>">
<link rel="stylesheet" href="assets/pixelpicker.css">
<style>
:root {
--bg: #ffffff;
--surface: #f6f7f9;
--border: #e1e4e9;
--text: #1d2129;
--muted: #6b7280;
--accent: #4361ee;
--code-bg: #f2f4f7;
--radius: 10px;
/* Die Palette traegt Hero, Bubbles und Akzente -- bei einem Colorpicker
ist Farbe kein Schmuck, sondern das Thema selbst. Vier Stimmungen
stehen zur Wahl, der Schalter unten rechts wechselt sie.
Standard ist 'earth': gebrochene Warmtoene, Terrakotta und
Schokolade. Sie wirken wertiger als reine Buntwerte und heben die
Seite von der ueblichen Bibliotheksoptik ab (Matt, 2026-09-18). */
--pop-pink: #c65d3b;
--pop-yellow: #c88a4b;
--pop-green: #87a878;
--pop-blue: #6f4e37;
--pop-orange: #a0522d;
--pop-cyan: #8c6a56;
--pop-violet: #7d5a50;
--pop-deep: #4a3428;
--accent: #a0522d;
--hero-1: #f6ece2;
--hero-2: #faf3e7;
--hero-3: #f2e8e0;
--hero-base: #fdfaf6;
--title-gradient: linear-gradient(100deg, #6f4e37 0%, #a0522d 42%, #c65d3b 74%, #c88a4b 100%);
--cta-gradient: linear-gradient(135deg, #a0522d, #6f4e37);
--cta-ink: #fff;
--cta-shadow: 160 82 45;
}
/* --- Die anderen drei Stimmungen ---------------------------------------
Jede setzt dieselben Variablen neu; alles Uebrige liest nur daraus. */
/* Die knallige: Indigo bis Magenta. */
:root[data-palette='vivid'] {
--pop-pink: #f72585;
--pop-yellow: #ffbe0b;
--pop-green: #4cc9f0;
--pop-blue: #4361ee;
--pop-orange: #fb5607;
--pop-cyan: #b5179e;
--pop-violet: #7209b7;
--pop-deep: #3a0ca3;
--accent: #4361ee;
--hero-1: #ffe9f3;
--hero-2: #fff1d6;
--hero-3: #ebe6ff;
--hero-base: #fffdfb;
--title-gradient: linear-gradient(100deg, #4361ee 0%, #7209b7 40%, #f72585 72%, #fb5607 100%);
--cta-gradient: linear-gradient(135deg, #4361ee, #7209b7);
--cta-ink: #fff;
--cta-shadow: 67 97 238;
}
/* Tief und edel: Petrol, Smaragd, Aubergine. Dunklere Buntwerte, die
ohne Neon auskommen. */
:root[data-palette='jewel'] {
--pop-pink: #9e2a2b;
--pop-yellow: #d4a017;
--pop-green: #0f7b6c;
--pop-blue: #1d3557;
--pop-orange: #bc6c25;
--pop-cyan: #2a6f97;
--pop-violet: #5b2c6f;
--pop-deep: #14213d;
--accent: #1d3557;
--hero-1: #e4ecf2;
--hero-2: #fdf3e0;
--hero-3: #e9e4f0;
--hero-base: #fbfcfd;
--title-gradient: linear-gradient(100deg, #1d3557 0%, #0f7b6c 40%, #5b2c6f 72%, #9e2a2b 100%);
--cta-gradient: linear-gradient(135deg, #1d3557, #0f7b6c);
--cta-ink: #fff;
--cta-shadow: 29 53 87;
}
/* Eierschale und Salbei: die leiseste Variante, fuer alles, was neben
viel Text steht. */
:root[data-palette='shell'] {
--pop-pink: #d4a59a;
--pop-yellow: #e8dcc8;
--pop-green: #a3b18a;
--pop-blue: #7d8597;
--pop-orange: #dda15e;
--pop-cyan: #a5a58d;
--pop-violet: #9c89b8;
--pop-deep: #52565e;
--accent: #6b705c;
--hero-1: #f4ede4;
--hero-2: #faf6ef;
--hero-3: #eef0e9;
--hero-base: #fdfcf9;
--title-gradient: linear-gradient(100deg, #52565e 0%, #6b705c 40%, #a3b18a 72%, #dda15e 100%);
--cta-gradient: linear-gradient(135deg, #6b705c, #52565e);
--cta-ink: #fff;
--cta-shadow: 107 112 92;
}
@media (prefers-color-scheme: dark) {
:root:not([data-theme='light']) {
--bg: #161a22;
--surface: #1e242f;
--border: #303849;
--text: #e8eaf0;
--muted: #9aa3b5;
--accent: #48cae4;
--code-bg: #1a1f28;
}
}
:root[data-theme='dark'] {
--bg: #161a22;
--surface: #1e242f;
--border: #303849;
--text: #e8eaf0;
--muted: #9aa3b5;
--accent: #48cae4;
--code-bg: #1a1f28;
}
* { box-sizing: border-box; }
body {
margin: 0;
padding: 0 16px 80px;
background: var(--bg);
color: var(--text);
font-family: system-ui, -apple-system, 'Segoe UI', roboto, sans-serif;
line-height: 1.6;
-webkit-font-smoothing: antialiased;
}
.wrap { max-width: 900px; margin: 0 auto; }
/* --- Kopfleiste ------------------------------------------------------- */
.topbar {
position: sticky;
top: 0;
z-index: 50;
display: flex;
align-items: center;
gap: 16px;
padding: 12px 20px;
background: color-mix(in srgb, var(--bg) 88%, transparent);
backdrop-filter: blur(10px);
border-bottom: 1px solid var(--border);
}
.topbar__brand {
display: flex;
align-items: center;
gap: 9px;
font-weight: 700;
letter-spacing: -0.01em;
margin-right: auto;
}
/* Das Markenzeichen ist ein Farbfeld -- dasselbe, was der Picker ausgibt. */
.topbar__mark {
width: 26px;
height: 26px;
border-radius: 7px;
background: linear-gradient(135deg, var(--pop-green), var(--pop-blue));
}
.topbar__version {
font-size: 0.72rem;
font-weight: 500;
color: var(--muted);
}
.topbar__nav { display: flex; gap: 18px; font-size: 0.88rem; }
.topbar__nav a { color: var(--muted); text-decoration: none; }
.topbar__nav a:hover { color: var(--accent); }
@media (max-width: 640px) {
.topbar__version { display: none; }
.topbar__nav { gap: 12px; font-size: 0.8rem; }
}
/* --- Hero ------------------------------------------------------------- */
.hero {
position: relative;
overflow: hidden;
margin: 0 -16px 48px;
padding: 72px 16px 80px;
background:
radial-gradient(circle at 15% 20%, var(--hero-1) 0%, transparent 55%),
radial-gradient(circle at 85% 15%, var(--hero-2) 0%, transparent 50%),
radial-gradient(circle at 70% 90%, var(--hero-3) 0%, transparent 55%),
var(--hero-base);
text-align: center;
transition: background 200ms ease;
}
/* Die Bubbles: Farbfelder in verschiedenen Groessen, leicht durchscheinend
und weich gezeichnet. Sie liegen hinter dem Text, nie darueber. */
.hero__bubbles {
position: absolute;
inset: 0;
pointer-events: none;
}
.bubble {
position: absolute;
border-radius: 50%;
opacity: 0.75;
filter: blur(0.3px);
}
h1 {
position: relative;
margin: 0 0 14px;
font-size: clamp(2.4rem, 8vw, 4rem);
letter-spacing: -0.035em;
font-weight: 800;
background: var(--title-gradient);
-webkit-background-clip: text;
background-clip: text;
color: transparent;
}
.tagline {
position: relative;
max-width: 30em;
margin: 0 auto 26px;
color: #4a5568;
font-size: clamp(1rem, 2.4vw, 1.15rem);
}
.badges {
position: relative;
display: flex;
flex-wrap: wrap;
gap: 8px;
justify-content: center;
margin-bottom: 30px;
}
.badge {
padding: 5px 13px;
border: 1px solid color-mix(in srgb, var(--pop-deep) 14%, transparent);
border-radius: 999px;
background: rgb(255 255 255 / 72%);
font-size: 0.79rem;
font-weight: 500;
color: #3d4a5c;
backdrop-filter: blur(4px);
}
.badge--ok {
border-color: var(--accent);
color: color-mix(in srgb, var(--accent) 85%, #000);
}
.cta { position: relative; display: flex; flex-wrap: wrap; gap: 12px; justify-content: center; }
.cta a {
padding: 11px 22px;
border-radius: 9px;
font-size: 0.93rem;
font-weight: 600;
text-decoration: none;
transition: transform 0.12s ease, box-shadow 0.12s ease;
}
.cta a:hover { transform: translateY(-1px); }
.cta__primary {
background: var(--cta-gradient);
color: var(--cta-ink);
box-shadow: 0 4px 14px rgb(var(--cta-shadow) / 38%);
}
.cta__primary:hover { box-shadow: 0 6px 20px rgb(var(--cta-shadow) / 48%); }
.cta__ghost {
border: 1px solid color-mix(in srgb, var(--pop-deep) 18%, transparent);
background: rgb(255 255 255 / 70%);
color: var(--pop-deep);
}
.cta__ghost:hover { border-color: var(--pop-blue); color: var(--pop-blue); }
h2 {
margin: 48px 0 6px;
font-size: 1.4rem;
letter-spacing: -0.01em;
}
h2:first-of-type { margin-top: 0; }
h3 { margin: 28px 0 6px; font-size: 1.05rem; }
.lead { margin: 0 0 20px; color: var(--muted); }
.grid {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
gap: 18px;
}
/* Karten stehen auf hellem Grund mit feiner Kontur und weichem Schatten --
das graue Feld davor wirkte neben dem Hero stumpf. */
.card {
display: flex;
flex-direction: column;
padding: 18px;
border: 1px solid color-mix(in srgb, var(--pop-deep) 9%, transparent);
border-radius: 14px;
background: var(--bg);
box-shadow: 0 1px 2px rgb(16 24 40 / 5%), 0 6px 18px rgb(16 24 40 / 5%);
transition: box-shadow 0.15s ease, border-color 0.15s ease;
}
.card:hover {
border-color: color-mix(in srgb, var(--accent) 28%, transparent);
box-shadow: 0 1px 2px rgb(16 24 40 / 6%), 0 10px 26px rgb(16 24 40 / 9%);
}
.card h3 { margin: 0 0 4px; font-size: 0.95rem; }
.card p { margin: 0 0 12px; font-size: 0.83rem; color: var(--muted); }
/* Der Rest der Karte schiebt das Feld nach unten, damit die Felder
mehrerer Karten auf einer Linie stehen, auch bei ungleich langem Text. */
.card .card__demo { margin-top: auto; }
/* Karten ohne farbigen Kopf -- etwa die Panel-Varianten -- richten ihre
Zeilen ebenso aneinander aus: Ueberschrift, Text, Feld. Sonst sitzt das
Feld bei jeder Karte woanders, je nachdem wie lang der Text ist. */
/* Nur wo subgrid wirklich greift: Ohne die Abfrage wuerde grid-row: span 3
die Karten ueber drei Zeilen strecken, ohne dass sie sich ausrichten --
das Ergebnis waere schlechter als der Ausgangszustand. */
@supports (grid-template-rows: subgrid) {
.grid--aligned { align-items: stretch; }
.grid--aligned > .card {
display: grid;
grid-row: span 3;
grid-template-rows: subgrid;
align-content: start;
gap: 4px;
}
.grid--aligned > .card > :last-child { align-self: end; }
}
/* --- Karte, die ihre Farbe zeigt ---------------------------------------
Der Kopf der Karte nimmt die gewaehlte Farbe an -- genau das, was der
Picker im Einsatz tut: Man waehlt eine Farbe, und sie wirkt woanders.
Das Eingabefeld bleibt auf weissem Grund, sonst waeren helle Farben
nicht mehr von ihm zu unterscheiden.
Damit die Trennlinie bei allen Karten auf derselben Hoehe sitzt, teilen
sie sich ueber subgrid dieselben Zeilen: Ueberschrift, Text, Schalter
und Feld. Jede Zeile ist so hoch wie ihr laengster Inhalt in der Reihe
-- ohne feste Hoehen, die beim naechsten Satz wieder brechen. */
.card--tinted {
padding: 0;
overflow: hidden;
}
@supports (grid-template-rows: subgrid) {
#thumb-grid { align-items: stretch; }
.card--tinted {
display: grid;
grid-row: span 4;
grid-template-rows: subgrid;
}
.card--tinted .card__head {
display: grid;
grid-row: span 3;
grid-template-rows: subgrid;
align-content: start;
gap: 4px;
}
}
.card--tinted .card__head {
padding: 18px 18px 16px;
border-bottom: 1px solid var(--border);
/* Farbe und Schrift setzt das Skript je Auswahl. */
background: var(--card-tint, var(--surface));
color: var(--card-ink, inherit);
transition: background 160ms ease, color 160ms ease;
}
/* Der Schalter steht unten in seiner Zeile: Karten ohne ihn lassen die
Zeile leer, statt den Text nach unten zu ziehen. */
.card--tinted .side-switch { align-self: end; margin-bottom: 0; }
.card--tinted .card__head h3,
.card--tinted .card__head p {
color: inherit;
}
/* Der Variantenname steht auf farbigem Grund: Er erbt die Schriftfarbe
und traegt einen Schleier davon als Hintergrund, statt der blauen
Auszeichnung aus dem Fliesstext -- die verschwindet auf Blau. */
.card--tinted .card__head h3 code {
background: color-mix(in srgb, currentcolor 15%, transparent);
color: inherit;
}
/* Der Optionsname steht vor dem Wert, damit die Kachel die Schreibweise
zeigt und nicht nur den Namen der Variante. Er tritt zurueck: Gesucht
wird der Wert, der Name ist die Einordnung dazu. */
.card--tinted .card__head h3 .opt-name {
opacity: 0.65;
font-weight: 400;
}
/* thumbPosition als zweite Zeile unter thumbStyle; der Seitenschalter
schreibt den Wert mit. */
.card--tinted .card__head h3 .opt-line {
display: inline-block;
margin-top: 4px;
}
/* Der Beschreibungstext darf etwas zuruecktreten, aber lesbar bleiben --
deshalb Deckkraft statt einer zweiten Farbe, die zum Grund passen muss. */
.card--tinted .card__head p { opacity: 0.82; }
.card--tinted .card__demo {
padding: 16px 18px 18px;
background: var(--bg);
}
/* Der Seitenschalter sitzt im farbigen Kopf und muss beides vertragen:
hellen und dunklen Grund. Deshalb erbt er die Schriftfarbe. */
.card--tinted .side-switch {
border-color: color-mix(in srgb, currentcolor 28%, transparent);
background: color-mix(in srgb, currentcolor 10%, transparent);
}
.card--tinted .side-switch button { color: inherit; opacity: 0.75; }
/* Der gewaehlte Knopf kehrt die Farben um: Schriftfarbe als Grund, die
Kartenfarbe als Schrift. Beides liegt schon fest und ist gegeneinander
lesbar -- eine dritte Farbe waere geraten. */
.card--tinted .side-switch button[aria-pressed='true'] {
background: var(--card-ink, var(--accent));
color: var(--card-tint, #fff);
opacity: 1;
}
/* Links/Rechts-Schalter je Karte: dieselbe Variante, andere Seite. */
.side-switch {
display: inline-flex;
margin-bottom: 10px;
padding: 2px;
border: 1px solid var(--border);
border-radius: 7px;
background: var(--surface);
}
.side-switch button {
padding: 3px 10px;
border: none;
border-radius: 5px;
background: none;
color: var(--muted);
font: inherit;
font-size: 0.74rem;
font-weight: 600;
cursor: pointer;
}
.side-switch button[aria-pressed='true'] {
background: var(--accent);
color: #fff;
}
@media (prefers-color-scheme: dark) {
:root:not([data-theme='light']) .card {
border-color: var(--border);
box-shadow: none;
}
}
label.field-label {
display: block;
margin-bottom: 6px;
font-size: 0.8rem;
font-weight: 600;
color: var(--muted);
}
input[type='text'] {
width: 100%;
height: 40px;
padding: 0 10px;
border: 1px solid var(--border);
border-radius: 6px;
background: var(--bg);
color: var(--text);
font: inherit;
font-size: 0.9rem;
}
input[type='text']:focus-visible {
outline: none;
border-color: var(--accent);
box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 25%, transparent);
}
/* Code im Fliesstext bekommt eine eigene Farbe, nicht nur einen grauen
Kasten: Mit der Textfarbe des Absatzes hebt er sich faktisch nicht ab,
und genau darum geht es -- man soll auf einen Blick sehen, was Option
und was Wert ist. */
code {
padding: 1.5px 6px;
border-radius: 5px;
background: color-mix(in srgb, var(--accent) 9%, transparent);
color: color-mix(in srgb, var(--accent) 88%, #000);
font-family: ui-monospace, 'SF Mono', 'Cascadia Code', consolas, monospace;
font-size: 0.86em;
font-weight: 500;
}
/* Werte in der Tabelle: die Option traegt die Akzentfarbe, ihr Wert eine
zweite -- so sind beide in einer Zeile auseinanderzuhalten. */
td code.val {
background: color-mix(in srgb, var(--pop-pink) 10%, transparent);
color: color-mix(in srgb, var(--pop-pink) 82%, #000);
}
th { font-weight: 700; }
td:first-child code { font-weight: 600; }
/* Codeblöcke stehen dunkel, damit sie sich vom Fließtext abheben und in
beiden Farbschemata gleich aussehen. Die Auszeichnung ist von Hand
gesetzt -- eine Highlighting-Bibliothek wäre die erste Abhängigkeit
einer Seite, die Abhängigkeitsfreiheit bewirbt. */
pre {
margin: 12px 0;
padding: 16px 18px;
border-radius: var(--radius);
background: #1e1e2e;
color: #e2e8f0;
overflow-x: auto;
font-size: 0.83rem;
line-height: 1.6;
tab-size: 2;
}
pre code {
padding: 0;
background: none;
color: inherit;
font-size: 1em;
}
.cm { color: #6d7fa8; font-style: italic; }
.kw { color: #c792ea; }
.str { color: #c3e88d; }
.fn { color: #82aaff; }
.at { color: #ffcb6b; }
.pu { color: #89ddff; }
/* --- Demo mit Reitern -------------------------------------------------- */
.tabs {
display: flex;
flex-wrap: wrap;
gap: 4px;
margin: 20px 0 0;
border-bottom: 1px solid var(--border);
}
.tab {
padding: 9px 15px;
border: none;
border-bottom: 2px solid transparent;
background: none;
color: var(--muted);
font: inherit;
font-size: 0.88rem;
font-weight: 500;
cursor: pointer;
transition: color 0.12s ease, border-color 0.12s ease;
}
.tab:hover { color: var(--text); }
.tab[aria-selected='true'] {
color: var(--accent);
border-bottom-color: var(--accent);
font-weight: 600;
}
.tab-panel { padding-top: 22px; }
.tab-panel[hidden] { display: none; }
/* Der Knopf, der den Aufsetzcode zeigt. Er steht bei jeder Demo, damit
niemand raten muss, wie das Gezeigte konfiguriert ist. */
.code-btn {
padding: 7px 14px;
border: 1px solid var(--border);
border-radius: 7px;
background: var(--surface);
color: var(--text);
font: inherit;
font-size: 0.82rem;
font-weight: 500;
cursor: pointer;
transition: border-color 0.12s ease, color 0.12s ease;
}
.code-btn:hover { border-color: var(--accent); color: var(--accent); }
.demo-controls {
display: flex;
flex-wrap: wrap;
gap: 8px;
align-items: center;
margin: 16px 0 18px;
}
/* --- Themenwechsler ----------------------------------------------------
Bleibt dauerhaft: Auf der Seite eines Colorpickers ist eine Farbwahl
kein Behelf, sondern das Thema. Die Knoepfe zeigen die Stimmung, statt
sie zu benennen -- ein Farbfeld sagt mehr als ein Name. */
.palette-switch {
position: fixed;
right: 16px;
bottom: 16px;
z-index: 60;
display: flex;
gap: 6px;
padding: 7px;
border: 1px solid var(--border);
border-radius: 999px;
background: color-mix(in srgb, var(--bg) 92%, transparent);
backdrop-filter: blur(8px);
box-shadow: 0 4px 16px rgb(16 24 40 / 12%);
}
.palette-switch button {
width: 26px;
height: 26px;
padding: 0;
border: 2px solid transparent;
border-radius: 50%;
background: var(--swatch);
cursor: pointer;
transition: transform 0.12s ease, border-color 0.12s ease;
}
.palette-switch button:hover { transform: scale(1.12); }
.palette-switch button[aria-pressed='true'] {
border-color: var(--text);
transform: scale(1.12);
}
@media (max-width: 480px) {
.palette-switch { right: 12px; bottom: 12px; padding: 5px; gap: 4px; }
.palette-switch button { width: 22px; height: 22px; }
}
/* --- Der Beweis: abgeschnitten gegen Top Layer -------------------------- */
.clip-compare {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
gap: 18px;
margin-top: 18px;
}
/* Genau der Fall aus der Praxis: ein Input in einem Kasten, der ueber die
Kante hinaus nichts durchlaesst. */
.clip-box {
overflow: hidden;
height: 160px;
padding: 14px;
border: 1px dashed color-mix(in srgb, var(--pop-pink) 45%, transparent);
border-radius: 10px;
background: var(--surface);
}
/* Ein nachgebautes Panel der klassischen Bauart -- absolut positioniert im
Kasten und deshalb an dessen Kante zu Ende. Es ist Attrappe, kein Picker:
Es soll zeigen, was pixelpicker gerade NICHT tut. */
.fake-panel {
position: relative;
width: 200px;
margin-top: 4px;
padding: 10px;
border: 1px solid var(--border);
border-radius: 9px;
background: var(--bg);
box-shadow: 0 8px 24px rgb(16 24 40 / 14%);
}
.fake-panel__area {
height: 62px;
border-radius: 5px;
background: linear-gradient(to top, #000, transparent),
linear-gradient(to right, #fff, var(--pop-pink));
}
.fake-panel__row {
height: 9px;
margin-top: 8px;
border-radius: 999px;
background: linear-gradient(to right, #f00, #ff0, #0f0, #0ff, #00f, #f0f, #f00);
}
.fake-panel__note {
margin: 8px 0 0;
font-size: 0.72rem;
color: var(--pop-pink);
}
table {
width: 100%;
margin: 14px 0 8px;
border-collapse: collapse;
font-size: 0.85rem;
}
th, td {
padding: 8px 10px;
border-bottom: 1px solid var(--border);
text-align: left;
vertical-align: top;
}
th { font-weight: 600; color: var(--muted); font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.04em; }
td:first-child { white-space: nowrap; }
.scroll-demo {
height: 190px;
padding: 16px;
border: 1px solid var(--border);
border-radius: var(--radius);
background: var(--surface);
overflow: auto;
}
.spacer { height: 130px; }
.log {
margin-top: 10px;
padding: 10px 12px;
border: 1px solid var(--border);
border-radius: 6px;
background: var(--code-bg);
font-family: ui-monospace, consolas, monospace;
font-size: 0.78rem;
color: var(--muted);
min-height: 2.6em;
white-space: pre-wrap;
}
.row { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-top: 12px; }
button.demo-btn {
padding: 7px 14px;
border: 1px solid var(--border);
border-radius: 6px;
background: var(--bg);
color: var(--text);
font: inherit;
font-size: 0.85rem;
cursor: pointer;
}
button.demo-btn:hover { border-color: var(--accent); color: var(--accent); }
.note {
margin: 16px 0;
padding: 12px 16px;
border-left: 3px solid var(--accent);
border-radius: 0 6px 6px 0;
background: var(--surface);
font-size: 0.88rem;
}
footer {
margin-top: 64px;
padding-top: 24px;
border-top: 1px solid var(--border);
color: var(--muted);
font-size: 0.83rem;
}
a { color: var(--accent); }
/* Der Hero behaelt seine Farben auch im dunklen Schema: Die Bubbles sind
der Inhalt, nicht Dekor -- auf dunklem Grund verloeschen sie. */
@media (prefers-color-scheme: dark) {
:root:not([data-theme='light']) .hero { color-scheme: light; }
}
</style>
</head>
<body>
<div class="palette-switch" role="group" aria-label="Color theme">
<button type="button" data-palette="" aria-pressed="true" title="Earth"
style="--swatch:linear-gradient(135deg,#6f4e37,#c88a4b)"></button>
<button type="button" data-palette="vivid" aria-pressed="false" title="Vivid"
style="--swatch:linear-gradient(135deg,#4361ee,#f72585)"></button>
<button type="button" data-palette="jewel" aria-pressed="false" title="Jewel"
style="--swatch:linear-gradient(135deg,#1d3557,#0f7b6c)"></button>
<button type="button" data-palette="shell" aria-pressed="false" title="Shell"
style="--swatch:linear-gradient(135deg,#a3b18a,#e8dcc8)"></button>
</div>
<nav class="topbar">
<span class="topbar__brand">
<span class="topbar__mark"></span>
pixelpicker
<span class="topbar__version">v1.1.0</span>
</span>
<span class="topbar__nav">
<a href="#demo">Demo</a>
<a href="#install">Install</a>
<a href="#options">Options</a>
<a href="https://www.npmjs.com/package/pixelpicker" target="_blank" rel="noopener">npm</a>
<a href="https://github.com/MattOpen/pixelpicker" target="_blank" rel="noopener">GitHub</a>
</span>
</nav>
<header class="hero">
<div class="hero__bubbles" id="hero-bubbles" aria-hidden="true"></div>
<h1>pixelpicker</h1>
<p class="tagline">A lightweight, dependency-free color picker for text inputs. The panel is a helper — never a replacement for the field.</p>
<div class="badges">
<span class="badge">No jQuery</span>
<span class="badge">Zero dependencies</span>
<span class="badge">ESM · CJS · IIFE</span>
<span class="badge" id="badge-size">~20 KB minified</span>
<span class="badge" id="badge-popover">Popover API: checking…</span>
<span class="badge" id="badge-anchor">Anchor Positioning: checking…</span>
<span class="badge">MIT License</span>
</div>
<div class="cta">
<a class="cta__primary" href="#install">Get started</a>
<a class="cta__ghost" href="https://www.npmjs.com/package/pixelpicker" target="_blank" rel="noopener">View on npm</a>
<a class="cta__ghost" href="https://github.com/MattOpen/pixelpicker" target="_blank" rel="noopener">View on GitHub</a>
</div>
</header>
<div class="wrap">
<h2 id="demo">Live demo</h2>
<p class="lead">Every tab shows a working picker. <strong>Show setup code</strong> reveals exactly how it was configured.</p>
<div class="tabs" role="tablist">
<button class="tab" role="tab" aria-selected="true" aria-controls="tab-thumbs" id="t-thumbs">The field</button>
<button class="tab" role="tab" aria-selected="false" aria-controls="tab-variants" id="t-variants">The panel</button>
<button class="tab" role="tab" aria-selected="false" aria-controls="tab-typing" id="t-typing">From your code</button>
</div>
<!-- ── Tab 1: The field ── -->
<div class="tab-panel" role="tabpanel" id="tab-thumbs" aria-labelledby="t-thumbs">
<p class="lead">How the chosen color appears in the input itself. Six variants via <code>thumbStyle</code>, each on either side via <code>thumbPosition</code> — click a field to open its picker, or switch the side.</p>
<div class="demo-controls">
<button class="code-btn" data-code="code-thumbs">Show setup code</button>
</div>
<pre id="code-thumbs" hidden><code><span class="cm">// Per Attribut, ohne einen eigenen Aufruf je Feld:</span>
<span class="pu"><</span><span class="fn">input</span> <span class="at">type</span>=<span class="str">"text"</span> <span class="at">data-pp-thumb</span>=<span class="str">"circle"</span> <span class="at">value</span>=<span class="str">"#06d6a0"</span><span class="pu">></span>
<span class="cm">// …oder fuer viele Felder auf einmal:</span>
<span class="fn">create</span>(<span class="str">'.color-input'</span>, { <span class="at">thumbStyle</span>: <span class="str">'circle'</span> });
<span class="cm">// Die Seite waehlen -- 'start' folgt der Schreibrichtung,</span>
<span class="cm">// steht also in einem RTL-Layout rechts.</span>
<span class="fn">create</span>(<span class="str">'.color-input'</span>, {
<span class="at">thumbStyle</span>: <span class="str">'circle'</span>,
<span class="at">thumbPosition</span>: <span class="str">'start'</span>
});
<span class="cm">// Die Schalter oben bauen die Instanz jeweils neu auf:</span>
<span class="fn">destroy</span>(field);
<span class="fn">create</span>(field, { <span class="at">thumbStyle</span>: style, <span class="at">thumbPosition</span>: side });</code></pre>
<div class="grid" id="thumb-grid">
<div class="card card--tinted">
<div class="card__head">
<h3><code><span class="opt-name">thumbStyle:</span> 'bar'</code><br><code class="opt-line"><span class="opt-name">thumbPosition:</span> <span class="opt-side">'end'</span></code></h3>
<p>A strip at the edge of the field. The default.</p>
<div class="side-switch" role="group" aria-label="Thumb position for bar">
<button type="button" data-side="start" aria-pressed="false">Start</button>
<button type="button" data-side="end" aria-pressed="true">End</button>
</div>
</div>
<div class="card__demo">
<input type="text" class="demo-thumb" data-pp-thumb="bar" value="#6f4e37">
</div>
</div>
<div class="card card--tinted">
<div class="card__head">
<h3><code><span class="opt-name">thumbStyle:</span> 'circle'</code><br><code class="opt-line"><span class="opt-name">thumbPosition:</span> <span class="opt-side">'end'</span></code></h3>
<p>A round swatch inside the field.</p>
<div class="side-switch" role="group" aria-label="Thumb position for circle">
<button type="button" data-side="start" aria-pressed="false">Start</button>
<button type="button" data-side="end" aria-pressed="true">End</button>
</div>
</div>
<div class="card__demo">
<input type="text" class="demo-thumb" data-pp-thumb="circle" value="#87a878">
</div>
</div>
<div class="card card--tinted">
<div class="card__head">
<h3><code><span class="opt-name">thumbStyle:</span> 'square'</code><br><code class="opt-line"><span class="opt-name">thumbPosition:</span> <span class="opt-side">'end'</span></code></h3>
<p>A square swatch inside the field.</p>
<div class="side-switch" role="group" aria-label="Thumb position for square">
<button type="button" data-side="start" aria-pressed="false">Start</button>
<button type="button" data-side="end" aria-pressed="true">End</button>
</div>
</div>
<div class="card__demo">
<input type="text" class="demo-thumb" data-pp-thumb="square" value="#c88a4b">
</div>
</div>
<div class="card card--tinted">
<div class="card__head">
<h3><code><span class="opt-name">thumbStyle:</span> 'fill'</code></h3>
<p>The color covers the field completely — the value is hidden. For fields where the color <em>is</em> the display.</p>
</div>
<div class="card__demo">
<input type="text" class="demo-thumb" data-pp-thumb="fill" value="#a0522d">
</div>
</div>
<div class="card card--tinted">
<div class="card__head">
<h3><code><span class="opt-name">thumbStyle:</span> 'fill-behind'</code></h3>
<p>The color fills the field <em>behind</em> the text, so the value stays readable.</p>
</div>
<div class="card__demo">
<input type="text" class="demo-thumb" data-pp-thumb="fill-behind" value="#c65d3b">
</div>
</div>
<div class="card card--tinted">
<div class="card__head">
<h3><code><span class="opt-name">thumbStyle:</span> 'none'</code></h3>
<p>No swatch at all — the input is left exactly as it was.</p>
</div>
<div class="card__demo">
<input type="text" class="demo-thumb" data-pp-thumb="none" value="#f4ede4">
</div>
</div>
</div>
</div>
<!-- ── Tab 2: The panel ── -->
<div class="tab-panel" role="tabpanel" id="tab-variants" aria-labelledby="t-variants" hidden>
<div class="demo-controls">
<button class="code-btn" data-code="code-variants">Show setup code</button>
</div>
<pre id="code-variants" hidden><code><span class="fn">create</span>(<span class="str">'#demo-format'</span>, { <span class="at">formatToggle</span>: <span class="kw">true</span> });
<span class="fn">create</span>(<span class="str">'#demo-swatches'</span>, { <span class="at">swatchesOnly</span>: <span class="kw">true</span> });
<span class="fn">create</span>(<span class="str">'#demo-noalpha'</span>, { <span class="at">alpha</span>: <span class="kw">false</span> });
<span class="fn">create</span>(<span class="str">'#demo-pill'</span>, { <span class="at">theme</span>: <span class="str">'pill'</span> });
<span class="fn">create</span>(<span class="str">'#demo-dark'</span>, { <span class="at">themeMode</span>: <span class="str">'dark'</span> });
<span class="fn">create</span>(<span class="str">'#demo-clear'</span>, { <span class="at">clearButton</span>: <span class="kw">true</span> });
<span class="cm">// Eigene Farbfelder statt der zwoelf Standardwerte:</span>
<span class="fn">create</span>(<span class="str">'#brand-color'</span>, {
<span class="at">swatches</span>: [<span class="str">'#4361ee'</span>, <span class="str">'#7209b7'</span>, <span class="str">'#f72585'</span>, <span class="str">'#ffbe0b'</span>],