@bobbykim/manguito-theme 1.5.0 → 1.6.0

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.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # Change Log
2
2
 
3
+ ## 1.6.0
4
+
5
+ ### Minor Changes
6
+
7
+ - b54519d: New two-tone keyboard focus ring. A focused `.btn` now shows a 3px outline in `--mcl-focus-color` (default `dark-3`) with a 2px halo in `--mcl-focus-halo` (default `light-1`) instead of an outline in the button's own colour, so the ring contrasts with any background (the old ring was as low as 1.37:1 on light pages). It follows `:focus-visible`: clicking a button no longer leaves a ring, and the progress fill and button-group lift also react to keyboard focus only. The same ring is available as the `mcl-focus-ring` utility (`focus-visible:mcl-focus-ring`). `btn-no-ring` is deprecated and no longer hides keyboard focus; buttons that used it now show the ring when reached with Tab.
8
+
3
9
  ## 1.5.0
4
10
 
5
11
  ### Minor Changes
package/README.md CHANGED
@@ -128,6 +128,25 @@ Users can implement theme switching by changing CSS variables dynamically:
128
128
  @import '@bobbykim/manguito-theme/mcl-theme-v4.css';
129
129
  ```
130
130
 
131
+ ### Keyboard focus ring
132
+
133
+ Buttons, form controls and carousel arrows share one keyboard focus ring: a
134
+ 3px outline in `--mcl-focus-color` (default `dark-3`) with a 2px halo in
135
+ `--mcl-focus-halo` (default `light-1`) between it and the control. One of the
136
+ two always contrasts with the background. It follows `:focus-visible`, so
137
+ buttons show it for keyboard focus only. Override the variables like any
138
+ other, for example per theme:
139
+
140
+ ```css
141
+ [data-theme='dark'] {
142
+ --mcl-focus-color: #f1ac18;
143
+ }
144
+ ```
145
+
146
+ Use it on your own controls with the `mcl-focus-ring` utility and a variant,
147
+ e.g. `focus-visible:mcl-focus-ring`. `btn-no-ring` is deprecated and no longer
148
+ hides it.
149
+
131
150
  ## Usage
132
151
 
133
152
  `import generateClass from '@bobbykim/manguito-theme'`
@@ -286,8 +286,7 @@
286
286
  padding: 0.5rem 1rem;
287
287
  cursor: pointer;
288
288
  font-size: 1rem;
289
- transition-property:
290
- color, background-color, outline-width, outline-offset, outline-color;
289
+ transition-property: color, background-color;
291
290
  transition-duration: 300ms;
292
291
  transition-timing-function: linear;
293
292
  overflow: hidden;
@@ -296,7 +295,6 @@
296
295
  outline-style: solid;
297
296
  outline-width: 0;
298
297
  outline-offset: 0;
299
- outline-color: var(--mcl-btn-color, theme(--color-primary));
300
298
  background-color: var(--mcl-btn-color, theme(--color-primary));
301
299
  text-align: center;
302
300
  border-radius: theme(--radius-sm);
@@ -305,11 +303,11 @@
305
303
  background-color: --alpha(
306
304
  var(--mcl-btn-color, theme(--color-primary)) / 70%
307
305
  );
308
- outline-color: --alpha(var(--mcl-btn-color, theme(--color-primary)) / 70%);
309
306
  }
310
- .btn:focus {
311
- outline-width: 0.25rem; /* 4px */
312
- outline-offset: 0.125rem; /* 2px */
307
+ /* Keyboard focus only (#122): the shared two-tone ring, never the button
308
+ colour, so it contrasts with whatever is behind the button. */
309
+ .btn:focus-visible {
310
+ @apply mcl-focus-ring;
313
311
  }
314
312
  /* Button variants */
315
313
  .btn.btn-round {
@@ -327,9 +325,9 @@
327
325
  padding: 0.625rem 1.25rem;
328
326
  font-size: 1.125rem;
329
327
  }
330
- .btn.btn-no-ring {
331
- outline: none;
332
- }
328
+ /* .btn-no-ring is deprecated (#122): with no ring after clicks there is
329
+ nothing left for it to mute, and it must not hide keyboard focus. The
330
+ class stays valid and does nothing. */
333
331
  /* Inverted button */
334
332
  .btn.btn-invert {
335
333
  border: 2px solid var(--mcl-btn-color, theme(--color-primary));
@@ -338,7 +336,6 @@
338
336
  }
339
337
  .btn.btn-invert:hover {
340
338
  background-color: var(--mcl-btn-color, theme(--color-primary));
341
- outline-color: var(--mcl-btn-color, theme(--color-primary));
342
339
  color: white;
343
340
  }
344
341
  /* Progress button */
@@ -372,18 +369,17 @@
372
369
  }
373
370
 
374
371
  .btn.btn-progress:hover,
375
- .btn.btn-progress:focus {
372
+ .btn.btn-progress:focus-visible {
376
373
  color: white;
377
- outline-color: var(--mcl-btn-color, theme(--color-primary));
378
374
  }
379
375
 
380
376
  .btn.btn-progress:hover::before,
381
- .btn.btn-progress:focus::before {
377
+ .btn.btn-progress:focus-visible::before {
382
378
  width: 100%;
383
379
  }
384
380
 
385
381
  .btn.btn-progress.btn-progress-r:hover::before,
386
- .btn.btn-progress.btn-progress-r:focus::before {
382
+ .btn.btn-progress.btn-progress-r:focus-visible::before {
387
383
  width: 100%;
388
384
  left: 0;
389
385
  }
@@ -408,7 +404,7 @@
408
404
 
409
405
  /* Keep the standard focus ring in a group, and lift the focused button so
410
406
  its neighbours don't paint over the ring (#110). */
411
- .btn-group .btn:focus {
407
+ .btn-group .btn:focus-visible {
412
408
  position: relative;
413
409
  z-index: 1;
414
410
  }
@@ -563,6 +559,25 @@
563
559
  outline-color: --alpha(--value(--color-*) / var(--mcl-outline-opacity));
564
560
  }
565
561
 
562
+ /*
563
+ Shared keyboard focus ring (#122): a 3px outline in --mcl-focus-color, 2px
564
+ out from the element, with the 2px gap filled by a halo in --mcl-focus-halo.
565
+ One of the two always contrasts with the background. The outline carries the
566
+ contrast because forced-colors mode drops box-shadows. The halo joins
567
+ Tailwind's shadow stack so shadow-md and friends survive; the fallbacks cover
568
+ apps whose CSS never defines those variables.
569
+ Use with a variant: focus-visible:mcl-focus-ring, peer-focus-visible:…
570
+ */
571
+ @utility mcl-focus-ring {
572
+ outline: 3px solid var(--mcl-focus-color, var(--color-dark-3));
573
+ outline-offset: 2px;
574
+ --tw-ring-offset-shadow: 0 0 0 2px var(--mcl-focus-halo, var(--color-light-1));
575
+ box-shadow:
576
+ var(--tw-inset-shadow, 0 0 #0000), var(--tw-inset-ring-shadow, 0 0 #0000),
577
+ var(--tw-ring-offset-shadow), var(--tw-ring-shadow, 0 0 #0000),
578
+ var(--tw-shadow, 0 0 #0000);
579
+ }
580
+
566
581
  /* utility classes for glassmorphism depth */
567
582
  @utility mcl-glass-* {
568
583
  --mcl-depth-color: --value(--color-*);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bobbykim/manguito-theme",
3
- "version": "1.5.0",
3
+ "version": "1.6.0",
4
4
  "description": "main theme file for manguito components library. Other MCL components will need to import this file to run.",
5
5
  "type": "module",
6
6
  "publishConfig": {