@pinuts/bsr-uikit-relaunch 0.4.2 → 0.4.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,159 @@
1
+ @use "sass:math";
2
+
3
+ // =========================================================================
4
+ // FORCED COLORS / HIGH CONTRAST
5
+ // (Windows-Kontrastdesigns, Firefox "Website contrast: Custom")
6
+ //
7
+ // Der Browser erzwingt dann eigene Farben. Zwei Fehlerbilder:
8
+ // 1. Indikator als url()-SVG -> wird NICHT umgefaerbt, bleibt orange
9
+ // 2. Indikator als background-color -> wird auf Canvas geflacht, verschwindet
10
+ // Reine box-shadow-Fokusringe verschwinden ebenfalls.
11
+ //
12
+ // Loesung: Box mit forced-color-adjust: none aus der Automatik nehmen und mit
13
+ // System-Keywords neu zeichnen (CanvasText = "Text", Canvas = "Hintergrund",
14
+ // GrayText = deaktiviert, Highlight = Auswahl/Fokus).
15
+ //
16
+ // ZWEI FALLEN:
17
+ // - forced-color-adjust VERERBT. Nur auf die Indikator-Box setzen, nie auf
18
+ // label oder Wrapper - sonst faellt der Labeltext aus der Nutzerpalette.
19
+ // - Wer es setzt, besitzt ALLE Farben des Elements inkl. outline-color.
20
+ // Bestehende Fokusregeln muessen mit fc-focus-ring gespiegelt werden.
21
+ //
22
+ // KEIN nativer Fallback (appearance: auto): Firefox malt native Controls im
23
+ // HCM in seiner eigenen Schwarz/Weiss-Palette und ignoriert die Nutzerfarben.
24
+ // Die Mixins funktionieren auf echten <input> wie auf Pseudo-Elementen.
25
+ // =========================================================================
26
+
27
+ /// Einziger Ansatzpunkt fuer die Media Query.
28
+ @mixin forced-colors {
29
+ @media (forced-colors: active) {
30
+ @content;
31
+ }
32
+ }
33
+
34
+ @mixin fc-control-box($border: CanvasText, $surface: Canvas) {
35
+ forced-color-adjust: none;
36
+ border-color: $border;
37
+ background-color: $surface;
38
+ background-image: none;
39
+ box-shadow: none;
40
+ }
41
+
42
+ @mixin fc-control-box-disabled($border: GrayText, $surface: Canvas) {
43
+ @include fc-control-box($border, $surface);
44
+ }
45
+
46
+ /// Radio-Punkt als Gradient auf der Box selbst - kein zusaetzliches Element,
47
+ /// kein Positionierungskontext. Setzt fc-control-box voraus, sonst wuerde der
48
+ /// Gradient auf none gezwungen. background-origin macht die Geometrie
49
+ /// unabhaengig von der Border-Breite (1,4px normal / 2px bei Hover, Fehler).
50
+ /// $size in px fuer bekannte Boxgroessen, oder ein Prozentwert, wenn die Box
51
+ /// unbekannt ist (dann skaliert der Punkt mit - der Gradient liegt ueber der
52
+ /// ganzen Box, `circle at center` mit Prozent-Stops).
53
+ @mixin fc-indicator-radio($color: CanvasText, $size: 16px) {
54
+ @if unit($size) == "%" {
55
+ $radius: $size * 0.5;
56
+
57
+ background-image: radial-gradient(
58
+ circle at center,
59
+ #{$color} 0,
60
+ #{$color} #{$radius},
61
+ transparent #{$radius + 1%}
62
+ );
63
+ } @else {
64
+ $radius: $size * 0.5;
65
+
66
+ background-image: radial-gradient(
67
+ circle at center,
68
+ #{$color} 0,
69
+ #{$color} #{$radius - 0.5px},
70
+ transparent #{$radius}
71
+ );
72
+ }
73
+ background-repeat: no-repeat;
74
+ background-position: center;
75
+ background-origin: border-box;
76
+ }
77
+
78
+ /// Haken aus zwei beschnittenen Gradient-Baendern.
79
+ ///
80
+ /// Groesse und Position sind in Prozent der Box ausgedrueckt, der Haken passt
81
+ /// sich also JEDER Boxgroesse an - noetig, weil die vom UM gelieferten
82
+ /// Formulare unterschiedlich grosse Controls verwenden.
83
+ ///
84
+ /// Herleitung gegen die urspruengliche 24x24-Geometrie (kurzer Strich 8x8 bei
85
+ /// 3/10, langer 12x12 bei 9/6). background-position in Prozent bedeutet
86
+ /// Offset = p * (Box - Bild), daraus:
87
+ /// kurz: 8/24 = 33.333%, p_x = 3/(24-8) = 18.75%, p_y = 10/16 = 62.5%
88
+ /// lang: 12/24 = 50%, p_x = 9/(24-12) = 75%, p_y = 6/12 = 50%
89
+ /// Bei 24px ergibt das exakt die alten Pixelwerte.
90
+ ///
91
+ /// Die Strichstaerke bleibt bewusst in px, damit der Haken auch in grossen
92
+ /// Boxen nicht fett wird.
93
+ @mixin fc-indicator-check($color: CanvasText, $stroke: 3.2px) {
94
+ $half: $stroke * 0.5; // deckende Haelfte
95
+ $soft: $half + 0.4px; // weiche Kante gegen Treppchen auf den Diagonalen
96
+
97
+ background-image:
98
+ // kurzer Strich, oben links -> Scheitelpunkt ("\")
99
+ linear-gradient(
100
+ 45deg,
101
+ transparent calc(50% - #{$soft}),
102
+ #{$color} calc(50% - #{$half}),
103
+ #{$color} calc(50% + #{$half}),
104
+ transparent calc(50% + #{$soft})
105
+ ),
106
+ // langer Strich, Scheitelpunkt -> oben rechts ("/")
107
+ linear-gradient(
108
+ 135deg,
109
+ transparent calc(50% - #{$soft}),
110
+ #{$color} calc(50% - #{$half}),
111
+ #{$color} calc(50% + #{$half}),
112
+ transparent calc(50% + #{$soft})
113
+ );
114
+ background-size: 33.333% 33.333%, 50% 50%;
115
+ background-position: 18.75% 62.5%, 75% 50%;
116
+ background-repeat: no-repeat;
117
+ background-origin: border-box;
118
+ }
119
+
120
+ /// Pflicht auf jedem Element mit forced-color-adjust: none.
121
+ @mixin fc-focus-ring($color: Highlight) {
122
+ outline-color: $color;
123
+ box-shadow: none;
124
+ }
125
+
126
+ /// Wie fc-focus-ring, aber fuer Elemente ohne eigene outline-Deklaration
127
+ /// (Basiszustand setzt outline: none oder nutzt nur box-shadow).
128
+ @mixin fc-focus-ring-full($color: Highlight, $width: 2px, $offset: 2px) {
129
+ outline: $width solid $color;
130
+ outline-offset: $offset;
131
+ box-shadow: none;
132
+ }
133
+
134
+ // -------------------------------------------------------------------------
135
+ // KACHEL- / PILL-SELEKTOREN
136
+ // "Ausgewaehlt" allein ueber background-color wird auf Canvas geflacht und
137
+ // damit ununterscheidbar (WCAG 1.4.1). Systempaar dafuer: Highlight /
138
+ // HighlightText.
139
+ //
140
+ // Anders als bei fc-control-box vererbt forced-color-adjust hier BEWUSST an
141
+ // den Labeltext - der steht auf der Highlight-Flaeche. Icons folgen nur mit
142
+ // fill/stroke="currentColor".
143
+ // -------------------------------------------------------------------------
144
+
145
+ @mixin fc-selected($surface: Highlight, $ink: HighlightText) {
146
+ forced-color-adjust: none;
147
+ background-color: $surface;
148
+ border-color: $surface;
149
+ color: $ink;
150
+ }
151
+
152
+ /// Gegenstueck zu fc-selected - noetig, weil der Container in beiden
153
+ /// Zustaenden aus der Automatik faellt.
154
+ @mixin fc-unselected($surface: Canvas, $ink: CanvasText) {
155
+ forced-color-adjust: none;
156
+ background-color: $surface;
157
+ border-color: $ink;
158
+ color: $ink;
159
+ }
@@ -351,6 +351,61 @@ input[type="radio"] {
351
351
  outline: 2px solid white;
352
352
  outline-offset: $bsr-border-width-m * -1 - 3px;
353
353
  }
354
+
355
+ // FORCED COLORS: Der Punkt entsteht oben aus background-color plus einem
356
+ // weissen outline mit negativem Offset als Innenring. background-color wird
357
+ // im Kontrastmodus auf Canvas geflacht und outline-color ohnehin ersetzt -
358
+ // der Punkt verschwindet also. Innenring-Trick deshalb abschalten und den
359
+ // Punkt als Gradient in Nutzerfarben zeichnen.
360
+ @include forced-colors {
361
+ @include fc-control-box;
362
+
363
+ outline: none;
364
+
365
+ &:hover,
366
+ &:active {
367
+ @include fc-control-box;
368
+
369
+ outline: none;
370
+ }
371
+
372
+ &:checked {
373
+ @include fc-control-box;
374
+ @include fc-indicator-radio;
375
+
376
+ outline: none;
377
+ }
378
+
379
+ &:disabled {
380
+ @include fc-control-box-disabled;
381
+
382
+ outline: none;
383
+ }
384
+
385
+ &:disabled:checked {
386
+ @include fc-control-box-disabled;
387
+ @include fc-indicator-radio($color: GrayText);
388
+
389
+ outline: none;
390
+ }
391
+
392
+ &:focus,
393
+ &:focus-visible {
394
+ @include fc-focus-ring-full;
395
+ }
396
+ }
397
+ }
398
+
399
+ // Kein Rot in der Palette: Fehler bleibt ueber die dickere Kontur
400
+ // (border-width wird nicht ueberschrieben) + Fehlermeldung erkennbar.
401
+ // Bewusst NICHT in den Block oben verschachtelt: `.formInput.error &` wuerde
402
+ // unter dem .bsr-uikit-Wrapper `.formInput.error .bsr-uikit input` ergeben,
403
+ // und .formInput liegt innerhalb des Wrappers.
404
+ @include forced-colors {
405
+ .formInput.error input[type="radio"] {
406
+ border-color: CanvasText;
407
+ outline: none;
408
+ }
354
409
  }
355
410
  button {
356
411
  text-underline-offset: 3px;
@@ -488,6 +543,46 @@ form input[type="checkbox"]:focus + label:before {
488
543
  box-shadow: 0 0 0 0.2rem rgba(255, 124.95, 38.25, 0.5);
489
544
  }
490
545
 
546
+ // FORCED COLORS: Der Haken oben ist ein url()-SVG und wird nicht umgefaerbt,
547
+ // Hover und Fokus sind reine box-shadow und verschwinden. Der Input selbst ist
548
+ // visuell versteckt, Box und Indikator liegen auf label:before - deshalb muss
549
+ // auch der Fokusring dorthin.
550
+ @include forced-colors {
551
+ form input[type="checkbox"] + label:before {
552
+ @include fc-control-box;
553
+ }
554
+
555
+ // Keine graue Hover-Vorschau: Hover zeigt oben nur eine dickere Kontur
556
+ // (border-width, keine Farbe - bleibt im Kontrastmodus erhalten). Ein Haken
557
+ // bei Hover wuerde einen nicht gesetzten Zustand vortaeuschen.
558
+
559
+ form input[type="checkbox"]:checked + label:before,
560
+ form input[type="checkbox"]:checked + label:hover:before {
561
+ @include fc-control-box;
562
+ @include fc-indicator-check;
563
+ }
564
+
565
+ // NICHT :read-only mitnehmen - das matcht JEDE Checkbox, weil :read-write
566
+ // nur fuer textuell editierbare Elemente gilt.
567
+ form input[type="checkbox"]:disabled + label:before {
568
+ @include fc-control-box-disabled;
569
+ }
570
+
571
+ form input[type="checkbox"]:disabled:checked + label:before {
572
+ @include fc-control-box-disabled;
573
+ @include fc-indicator-check($color: GrayText);
574
+ }
575
+
576
+ form input[type="checkbox"]:focus + label:before,
577
+ form input[type="checkbox"]:focus-visible + label:before {
578
+ @include fc-focus-ring-full;
579
+ }
580
+
581
+ .formInput.error input[type="checkbox"] + label:before {
582
+ border-color: CanvasText;
583
+ }
584
+ }
585
+
491
586
  /* TAG */
492
587
  .tag {
493
588
  position: relative;
@@ -1,5 +1,6 @@
1
1
  @use "sass:math";
2
2
  @import "./variables/_variables.scss";
3
+ @import "./forcedColors";
3
4
 
4
5
  // All CSS-emitting styles are scoped under `.bsr-uikit` so the UI-KIT's
5
6
  // global styles (element selectors like h1/body/p and class rules) do not
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pinuts/bsr-uikit-relaunch",
3
- "version": "0.4.2",
3
+ "version": "0.4.3",
4
4
  "private": false,
5
5
  "description": "BSR UI-KIT Relaunch",
6
6
  "main": "dist/index.js",