@jskit-ai/material-web 0.1.4 → 0.1.5

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
@@ -2,6 +2,10 @@
2
2
 
3
3
  ## Unreleased
4
4
 
5
+ - `material.css` draws every `v-bottom-navigation` as Material 3's navigation bar: a destination (each of its stacked buttons) has its icon, its `prepend-icon` or the first icon in its content (bare or in a badge), 24dp in a 64x32 pill that is its active indicator (`secondary-container`, the icon `on-secondary-container`) and holds its hover, focus and pressed state layer, where Vuetify drew its overlay and ripple across the whole button; the label is label-medium, 4dp below, `on-surface-variant` at rest and `on-surface` when active. A comfortable bar (48dp) drops the 4dp and a compact one (40dp) has a 24dp pill, so neither clips a label. The colours apply only where the app set none: a bar's `bg-color` (other than a surface tone) or colour class, and a destination's `color`, `base-color` or colour class, keep the app's colour on label and icon, the active pill drawn in that colour. An append icon, a badge's own icon and `mode="horizontal"` keep Vuetify's look. It was drawn only by the shell's `ShellTabLinkItem`, so an app's own bar of `v-btn`s kept Vuetify's look.
6
+ - **Breaking (visual).** Fields (`v-text-field`, `v-textarea`, `v-select`, `v-autocomplete`, `v-combobox`, `v-file-input`) keep Vuetify's line for their supporting text, as a Material 3 text field does: the defaults no longer set `hideDetails: "auto"`. With it, a field had no line until it had a message, so an error shown on blur or submit pushed the rest of the form down under the person's finger, and forms made up the space with a margin under each field. Upgrading: in a form, remove the `mb-*` margin under each field (the line is the gap now); a field outside a form (a search box, a filter, a toolbar select, a composer) sets `hide-details`, or `hide-details="auto"` to show a message only when it has one.
7
+ - `material.css` has a `text-on-*` class for every `on-*` role of the scheme. It had them for the main roles, success, warning and info, but not for the fixed roles' (`on-primary-fixed`, `on-primary-fixed-variant` and the secondary and tertiary ones) or the surface tones' (`on-surface-dim`, `on-surface-bright`, `on-surface-container-lowest` to `-highest`), so `color="on-primary-fixed-variant"` found no class. Vuetify names an `on-*` role's class `.on-<role>` only; an app colour's `on-*` roles keep that class alone. material-web's node test checks the classes against the generated scheme's roles.
8
+ - An active list item's subtitle is at full strength too, in the item's own colour, as a selected Material 3 list item's supporting text takes its label's: it was at Vuetify's medium-emphasis opacity, 4.45:1 on a card's surface-container-low, under WCAG's 4.5:1. So is the subtitle of an item with its own text colour, in that colour; an item at rest without one is still on-surface-variant, and a disabled item keeps its fade. shell-web's adaptive-shell browser test measures both subtitles' contrast over the card and the active item's state layer, in light and dark.
5
9
  - A text field's label and its supporting text (hints and messages) are on-surface-variant at full strength, as Material 3's text field draws them, instead of Vuetify's on-surface at the medium-emphasis opacity, which read 4.4:1 on a light surface, under WCAG's 4.5:1. A focused field's label keeps the field's colour, and an invalid field's label and messages keep error.
6
10
  - A list item's subtitle is on-surface-variant at full strength, as Material 3's list draws its supporting text, instead of the item's on-surface at the medium-emphasis opacity (4.35:1 on surface-container-low). An active item, one with its own text colour and a disabled one keep theirs.
7
11
  - Buttons' and pressable chips' state layers are their shape again: the 48dp touch target makes a button's overflow visible, which stopped it clipping Vuetify's overlay and underlay, so hover, focus and press drew a square on every round icon button (an app bar avatar, the rail's menu control) and on disabled ones. They now take the button's corners.
package/README.md CHANGED
@@ -83,10 +83,19 @@ export const theme = {
83
83
  `aria-pressed` too), fixed tabs that share the width or else scroll, dialog
84
84
  actions 24dp from the edges, a menu's own list as its container
85
85
  (`surface-container` at level 2, in the menu's 4dp corners) while a list in a
86
- rich menu panel (a card or sheet in the menu) stays plain, emphasized easing
87
- and reduced motion. Its
86
+ rich menu panel (a card or sheet in the menu) stays plain, a
87
+ `v-bottom-navigation` as Material 3's navigation bar (each destination's 24dp
88
+ icon in a 64x32 indicator, in `secondary-container` when active and holding
89
+ the state layer, over a label-medium label; the indicator 24dp tall in a
90
+ compact bar; a bar's `bg-color` or a destination's `color`, `base-color` or
91
+ colour class keeps the app's colours), emphasized easing and reduced
92
+ motion. It adds a `text-on-*` class for every `on-*` role of the
93
+ scheme, which Vuetify names only `.on-<role>`, so `color="on-surface-variant"`
94
+ and `class="text-on-surface-variant"` work; an app colour's `on-*` roles keep
95
+ only Vuetify's `.on-<name>` class. Its
88
96
  component rules sit in Vuetify's `vuetify-overrides` cascade layer, so an
89
- app's own props and utility classes still win; only a disabled button's
97
+ app's own props and utility classes still win (a typography class for a
98
+ navigation bar's label goes on the label); only a disabled button's
90
99
  colours and a full-screen dialog's surface are unlayered, over the colour
91
100
  class a `color` prop gives. Nothing uses
92
101
  `!important` or Sass.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jskit-ai/material-web",
3
- "version": "0.1.4",
3
+ "version": "0.1.5",
4
4
  "type": "module",
5
5
  "description": "Exact Material 3 for JSKIT Vuetify apps: seed-generated light and dark schemes, Material Symbols Rounded icon aliases, Roboto Flex and Material 3 component defaults.",
6
6
  "exports": {
@@ -78,28 +78,25 @@ const materialDefaults = Object.freeze({
78
78
  color: "primary",
79
79
  inset: "material"
80
80
  },
81
+ // Outlined fields keep Vuetify's line for their supporting text, as a Material 3 text field does, so an error or
82
+ // hint appears in place without moving what is below it. A field outside a form (a search box, a filter, a
83
+ // composer) sets `hide-details` itself.
81
84
  VAutocomplete: {
82
- hideDetails: "auto",
83
85
  variant: "outlined"
84
86
  },
85
87
  VCombobox: {
86
- hideDetails: "auto",
87
88
  variant: "outlined"
88
89
  },
89
90
  VFileInput: {
90
- hideDetails: "auto",
91
91
  variant: "outlined"
92
92
  },
93
93
  VSelect: {
94
- hideDetails: "auto",
95
94
  variant: "outlined"
96
95
  },
97
96
  VTextarea: {
98
- hideDetails: "auto",
99
97
  variant: "outlined"
100
98
  },
101
99
  VTextField: {
102
- hideDetails: "auto",
103
100
  variant: "outlined"
104
101
  },
105
102
  VCheckbox: {
@@ -432,12 +432,17 @@
432
432
  opacity: 1;
433
433
  }
434
434
 
435
- /* A list item's supporting text is on-surface-variant at full strength, as Material 3's list draws it, instead of
436
- the item's on-surface at the medium-emphasis opacity (4.35:1 on surface-container-low). An active item and one
437
- with its own text colour keep that colour, and a disabled item keeps its own fade. */
435
+ /* A list item's supporting text is at full strength, as Material 3's list draws it, instead of the item's colour at
436
+ Vuetify's medium-emphasis opacity: 4.35:1 on surface-container-low for an item at rest and 4.45:1 for an active
437
+ one, under WCAG's 4.5:1. An item at rest without a text colour of its own draws it in on-surface-variant; an
438
+ active item keeps the item's colour, as a selected Material 3 list item's supporting text takes its label's, and
439
+ so does one with its own text colour. A disabled item keeps its own fade. */
440
+ .v-list-item:not(.v-list-item--disabled) .v-list-item-subtitle {
441
+ opacity: 1;
442
+ }
443
+
438
444
  .v-list-item:not(.v-list-item--active, .v-list-item--disabled, [class*=" text-"]) .v-list-item-subtitle {
439
445
  color: rgb(var(--v-theme-on-surface-variant));
440
- opacity: 1;
441
446
  }
442
447
 
443
448
  /* Dividers and table rules use outline-variant at full strength (the theme's border colour). Vuetify draws a
@@ -450,6 +455,94 @@
450
455
  color: rgb(var(--v-theme-outline-variant));
451
456
  }
452
457
 
458
+ /* Material 3's navigation bar (v-bottom-navigation). Its destinations are its stacked buttons (mode="horizontal"
459
+ lays them flat, as Vuetify draws them). A destination's icon (its prepend-icon, or the first icon in its content,
460
+ bare or in a badge; not an append icon or a badge's own) sits in a 64x32 pill, the icon's own box: the active
461
+ indicator, and the state layer, where Vuetify draws its overlay and ripple across the whole button. The label is
462
+ label-medium, 4dp below; a comfortable bar (48dp) drops the 4dp and a compact one (40dp) has a 24dp pill as well,
463
+ so neither clips a label. The label's type is set on the button's content, which Vuetify's reset otherwise gives
464
+ the button's own (`font: inherit`), so a typography class goes on the label itself. */
465
+ .v-bottom-navigation .v-bottom-navigation__content > .v-btn--stacked > :is(.v-btn__overlay, .v-btn__underlay, .v-ripple__container) {
466
+ display: none;
467
+ }
468
+
469
+ .v-bottom-navigation .v-bottom-navigation__content > .v-btn--stacked > .v-btn__content {
470
+ font-size: 0.75rem;
471
+ font-weight: 500;
472
+ gap: 4px;
473
+ letter-spacing: 0.03125rem;
474
+ line-height: 1rem;
475
+ }
476
+
477
+ .v-bottom-navigation .v-bottom-navigation__content > .v-btn--stacked
478
+ :is(.v-btn__prepend > .v-icon, .v-btn__content > .v-icon:first-child,
479
+ .v-btn__content > .v-badge:first-child > .v-badge__wrapper > .v-icon) {
480
+ --jskit-navigation-state: transparent;
481
+ background-image: linear-gradient(var(--jskit-navigation-state), var(--jskit-navigation-state));
482
+ border-radius: 16px;
483
+ box-sizing: border-box;
484
+ font-size: 24px;
485
+ height: 32px;
486
+ padding: 4px 20px;
487
+ transition: background-color 200ms var(--md-sys-motion-easing-standard);
488
+ width: 64px;
489
+ }
490
+
491
+ .v-bottom-navigation .v-bottom-navigation__content > .v-btn--stacked:hover
492
+ :is(.v-btn__prepend > .v-icon, .v-btn__content > .v-icon:first-child,
493
+ .v-btn__content > .v-badge:first-child > .v-badge__wrapper > .v-icon) {
494
+ --jskit-navigation-state: color-mix(in srgb, currentColor calc(var(--v-hover-opacity) * 100%), transparent);
495
+ }
496
+
497
+ .v-bottom-navigation .v-bottom-navigation__content > .v-btn--stacked:is(:focus-visible, :active)
498
+ :is(.v-btn__prepend > .v-icon, .v-btn__content > .v-icon:first-child,
499
+ .v-btn__content > .v-badge:first-child > .v-badge__wrapper > .v-icon) {
500
+ --jskit-navigation-state: color-mix(in srgb, currentColor calc(var(--v-focus-opacity) * 100%), transparent);
501
+ }
502
+
503
+ /* The active indicator in the destination's own colour, where the app gave the bar or the destination one. */
504
+ .v-bottom-navigation .v-bottom-navigation__content > .v-btn--stacked.v-btn--active
505
+ :is(.v-btn__prepend > .v-icon, .v-btn__content > .v-icon:first-child,
506
+ .v-btn__content > .v-badge:first-child > .v-badge__wrapper > .v-icon) {
507
+ background-color: color-mix(in srgb, currentColor calc(var(--v-activated-opacity) * 100%), transparent);
508
+ }
509
+
510
+ .v-bottom-navigation:is(.v-bottom-navigation--density-comfortable, .v-bottom-navigation--density-compact)
511
+ .v-bottom-navigation__content > .v-btn--stacked,
512
+ .v-bottom-navigation:is(.v-bottom-navigation--density-comfortable, .v-bottom-navigation--density-compact)
513
+ .v-bottom-navigation__content > .v-btn--stacked > .v-btn__content {
514
+ gap: 0;
515
+ }
516
+
517
+ .v-bottom-navigation.v-bottom-navigation--density-compact .v-bottom-navigation__content > .v-btn--stacked
518
+ :is(.v-btn__prepend > .v-icon, .v-btn__content > .v-icon:first-child,
519
+ .v-btn__content > .v-badge:first-child > .v-badge__wrapper > .v-icon) {
520
+ height: 24px;
521
+ padding: 0 20px;
522
+ }
523
+
524
+ /* Material 3's colours, where the app set none: on a bar with no bg-color but a surface tone, no colour class and
525
+ no colour of its own, to a destination with no color, base-color or colour class (Vuetify's text-* and bg-*). A
526
+ destination the app colours, or any destination of a bar it colours, keeps that colour, label and icon alike.
527
+ They are set on the content and the icon, as the reset gives the button its bar's colour. */
528
+ .v-bottom-navigation:not([class*=" bg-"]:not([class*=" bg-surface"]), [class*=" text-"], [style*="background"], [style*="color"])
529
+ .v-bottom-navigation__content > .v-btn--stacked:not([class*=" text-"], [class*=" bg-"], [style*="color"]) > :is(.v-btn__prepend, .v-btn__content) {
530
+ color: rgb(var(--v-theme-on-surface-variant));
531
+ }
532
+
533
+ .v-bottom-navigation:not([class*=" bg-"]:not([class*=" bg-surface"]), [class*=" text-"], [style*="background"], [style*="color"])
534
+ .v-bottom-navigation__content > .v-btn--stacked:not([class*=" text-"], [class*=" bg-"], [style*="color"]).v-btn--active > .v-btn__content {
535
+ color: rgb(var(--v-theme-on-surface));
536
+ }
537
+
538
+ .v-bottom-navigation:not([class*=" bg-"]:not([class*=" bg-surface"]), [class*=" text-"], [style*="background"], [style*="color"])
539
+ .v-bottom-navigation__content > .v-btn--stacked:not([class*=" text-"], [class*=" bg-"], [style*="color"]).v-btn--active
540
+ :is(.v-btn__prepend > .v-icon, .v-btn__content > .v-icon:first-child,
541
+ .v-btn__content > .v-badge:first-child > .v-badge__wrapper > .v-icon) {
542
+ background-color: rgb(var(--v-theme-secondary-container));
543
+ color: rgb(var(--v-theme-on-secondary-container));
544
+ }
545
+
453
546
  /* Motion: emphasized easing; entering elements decelerate, leaving ones accelerate. */
454
547
  .v-navigation-drawer,
455
548
  .v-bottom-navigation,
@@ -484,7 +577,9 @@
484
577
 
485
578
  /*
486
579
  * Vuetify names the utility class of an on-* colour role ".on-surface-variant", so color="on-surface-variant" on an
487
- * icon or a text button would find no class. These text-on-* forms make it work.
580
+ * icon or a text button would find no class. These text-on-* forms make it work for every on-* role of the scheme:
581
+ * the scheme's roles, the fixed roles' and the surface tones', and success, warning and info with their containers.
582
+ * An app colour's on-* roles have only Vuetify's own class (class="on-partner"); bg-partner already sets on-partner.
488
583
  */
489
584
  @layer vuetify-utilities {
490
585
  /* A menu's own list is surface-container. In this layer, outside its theme sublayers, so it outranks the
@@ -514,6 +609,34 @@
514
609
  color: rgb(var(--v-theme-on-surface-variant));
515
610
  }
516
611
 
612
+ .text-on-surface-dim {
613
+ color: rgb(var(--v-theme-on-surface-dim));
614
+ }
615
+
616
+ .text-on-surface-bright {
617
+ color: rgb(var(--v-theme-on-surface-bright));
618
+ }
619
+
620
+ .text-on-surface-container-lowest {
621
+ color: rgb(var(--v-theme-on-surface-container-lowest));
622
+ }
623
+
624
+ .text-on-surface-container-low {
625
+ color: rgb(var(--v-theme-on-surface-container-low));
626
+ }
627
+
628
+ .text-on-surface-container {
629
+ color: rgb(var(--v-theme-on-surface-container));
630
+ }
631
+
632
+ .text-on-surface-container-high {
633
+ color: rgb(var(--v-theme-on-surface-container-high));
634
+ }
635
+
636
+ .text-on-surface-container-highest {
637
+ color: rgb(var(--v-theme-on-surface-container-highest));
638
+ }
639
+
517
640
  .text-on-primary {
518
641
  color: rgb(var(--v-theme-on-primary));
519
642
  }
@@ -538,6 +661,30 @@
538
661
  color: rgb(var(--v-theme-on-tertiary-container));
539
662
  }
540
663
 
664
+ .text-on-primary-fixed {
665
+ color: rgb(var(--v-theme-on-primary-fixed));
666
+ }
667
+
668
+ .text-on-primary-fixed-variant {
669
+ color: rgb(var(--v-theme-on-primary-fixed-variant));
670
+ }
671
+
672
+ .text-on-secondary-fixed {
673
+ color: rgb(var(--v-theme-on-secondary-fixed));
674
+ }
675
+
676
+ .text-on-secondary-fixed-variant {
677
+ color: rgb(var(--v-theme-on-secondary-fixed-variant));
678
+ }
679
+
680
+ .text-on-tertiary-fixed {
681
+ color: rgb(var(--v-theme-on-tertiary-fixed));
682
+ }
683
+
684
+ .text-on-tertiary-fixed-variant {
685
+ color: rgb(var(--v-theme-on-tertiary-fixed-variant));
686
+ }
687
+
541
688
  .text-on-error {
542
689
  color: rgb(var(--v-theme-on-error));
543
690
  }
@@ -153,6 +153,10 @@ test("the Vuetify options follow the system scheme on the md3 blueprint with Mat
153
153
  assert.equal(options.defaults.VSnackbar.color, "inverse-surface");
154
154
  // A button with `to` is active only on exactly its route.
155
155
  assert.equal(options.defaults.VBtn.exact, true);
156
+ // Fields keep their supporting-text line, so an error or hint appears without moving the form below it.
157
+ for (const field of ["VAutocomplete", "VCombobox", "VFileInput", "VSelect", "VTextarea", "VTextField"]) {
158
+ assert.deepEqual(options.defaults[field], { variant: "outlined" }, field);
159
+ }
156
160
  assert.throws(() => createMaterialVuetifyOptions({ icons: { "my-leaf": "M0 0" } }), /camelCase/u);
157
161
  });
158
162
 
@@ -208,6 +212,20 @@ test("material.css holds the exact-size rules without Sass or !important", async
208
212
  assert.match(css, /\.text-on-surface-variant \{\s*color: rgb\(var\(--v-theme-on-surface-variant\)\);/u);
209
213
  });
210
214
 
215
+ // Vuetify gives an on-* role only the class ".on-<role>", so color="on-<role>" finds no text-on-<role> class unless
216
+ // material.css has one: it has one for every Material 3 on-* role the scheme defines (surface-light is a Vuetify-only
217
+ // name, so its on-surface-light is not one), and none for a role the scheme lacks.
218
+ test("material.css has a text-on-* class for every Material 3 on-* role of the scheme", async () => {
219
+ const css = await readFile(path.join(PACKAGE_ROOT, "src/client/material.css"), "utf8");
220
+ const onRoles = Object.keys(materialThemes("#6750A4").light.colors)
221
+ .filter((role) => role.startsWith("on-") && role !== "on-surface-light")
222
+ .sort();
223
+ const classes = [...css.matchAll(/^ {2}\.text-(on-[a-z-]+) \{\s*color: rgb\(var\(--v-theme-(on-[a-z-]+)\)\);\s*\}/gmu)];
224
+ for (const [, name, role] of classes) assert.equal(name, role, `.text-${name} reads its own role`);
225
+ assert.deepEqual(classes.map(([, name]) => name).sort(), onRoles);
226
+ assert.ok(onRoles.includes("on-primary-fixed-variant") && onRoles.includes("on-surface-container-high"), onRoles.join(", "));
227
+ });
228
+
211
229
  test("segmented buttons and filter chips select in secondary-container; a menu's own list is the menu's container", () => {
212
230
  const { defaults } = createMaterialVuetifyOptions();
213
231
  assert.deepEqual(defaults.VBtnToggle, {
@@ -290,11 +308,13 @@ test("material.css draws segmented buttons, filter chips, fixed tabs and dialog
290
308
  css,
291
309
  /\.v-input:not\(\.v-input--error, \.v-input--disabled\) > \.v-input__details \.v-messages \{\s*color: rgb\(var\(--v-theme-on-surface-variant\)\);\s*opacity: 1;/u
292
310
  );
293
- // So is an inactive, uncoloured list item's subtitle.
311
+ // So is an inactive, uncoloured list item's subtitle; every enabled item's subtitle, an active one's included, is
312
+ // at full strength in the item's own colour.
294
313
  assert.match(
295
314
  css,
296
- /\.v-list-item:not\(\.v-list-item--active, \.v-list-item--disabled, \[class\*=" text-"\]\) \.v-list-item-subtitle \{\s*color: rgb\(var\(--v-theme-on-surface-variant\)\);\s*opacity: 1;/u
315
+ /\.v-list-item:not\(\.v-list-item--active, \.v-list-item--disabled, \[class\*=" text-"\]\) \.v-list-item-subtitle \{\s*color: rgb\(var\(--v-theme-on-surface-variant\)\);\s*\}/u
297
316
  );
317
+ assert.match(css, /\.v-list-item:not\(\.v-list-item--disabled\) \.v-list-item-subtitle \{\s*opacity: 1;\s*\}/u);
298
318
  // A disabled container button is on-surface 12% and 38%, unlayered over its colour class.
299
319
  assert.match(
300
320
  css,