@slotted/theme 0.1.0-beta.1 → 0.1.0-beta.11

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.
@@ -10,7 +10,7 @@ import { LAYER_ORDER_STATEMENT, parseSeed, resolveTokens } from '../dist/index.j
10
10
  * that is the theme's identity, and it belongs to the theme's own tests.
11
11
  */
12
12
 
13
- const VARIANTS = ['accent', 'secondary', 'success', 'warning', 'danger'];
13
+ const VARIANTS = ['accent', 'secondary', 'success', 'info', 'warning', 'danger'];
14
14
  const SOLID_STATES = ['solid', 'solid-hover', 'solid-active'];
15
15
  const SURFACES = ['--slotted-surface', '--slotted-surface-raised', '--slotted-surface-sunken'];
16
16
 
@@ -30,6 +30,8 @@ const NON_TEXT_RATIO = 3;
30
30
  const CONTROL_EDGE_RATIO = 1.5;
31
31
  /** The OKLab lightness step a neutral highlight keeps from the ground it is drawn on. */
32
32
  const HIGHLIGHT_STEP = 0.02;
33
+ /** The OKLab lightness step a dark scheme's raised layer keeps above the page, unless `thresholds.layerStep` says. */
34
+ const LAYER_STEP = 0.04;
33
35
 
34
36
  /** The collapsed duration is short enough to read as instant, and never zero. */
35
37
  const MAX_REDUCED_MOTION_MS = 1;
@@ -205,8 +207,9 @@ function structureCases(contract, theme, css) {
205
207
  });
206
208
  }
207
209
 
208
- function contrastCases(theme) {
210
+ function contrastCases(theme, thresholds) {
209
211
  const label = theme.name;
212
+ const layerStep = thresholds.layerStep ?? LAYER_STEP;
210
213
 
211
214
  /**
212
215
  * One radius for every control, at every size. Button carried three of its
@@ -267,6 +270,24 @@ function contrastCases(theme) {
267
270
  }
268
271
  });
269
272
 
273
+ /**
274
+ * A card, a menu or a dialog is a layer over the page. In a light scheme
275
+ * its shadow separates it; in a dark scheme a shadow on a dark ground does
276
+ * not read, and the layer has to stand lighter than the page. At 0.017 in
277
+ * OKLab lightness a card read apart only by its border.
278
+ */
279
+ if (scheme === 'dark') {
280
+ test(`${label} ${scheme} raises a layer visibly above the page`, () => {
281
+ const step =
282
+ parseSeed(values['--slotted-surface-raised']).l -
283
+ parseSeed(values['--slotted-surface']).l;
284
+ assert.ok(
285
+ step >= layerStep,
286
+ `${scheme} --slotted-surface-raised is ${step.toFixed(3)} above --slotted-surface, below ${layerStep} (thresholds.layerStep)`,
287
+ );
288
+ });
289
+ }
290
+
270
291
  test(`${label} ${scheme} inverts a surface without losing its text`, () => {
271
292
  assert.ok(
272
293
  contrast(values['--slotted-surface-inverse'], values['--slotted-text-inverse']) >= required,
@@ -444,9 +465,13 @@ function glyphCases(contract, theme) {
444
465
  });
445
466
  }
446
467
 
447
- /** Registers every case a theme has to pass. `theme` is `flattenTheme(theme)`; `css` is `renderTheme(theme)`. */
448
- export function themeConformance({ contract, theme, css }) {
468
+ /**
469
+ * Registers every case a theme has to pass. `theme` is `flattenTheme(theme)`;
470
+ * `css` is `renderTheme(theme)`. `thresholds.layerStep` is the OKLab lightness
471
+ * a dark scheme's raised layer keeps above the page, 0.04 unless given.
472
+ */
473
+ export function themeConformance({ contract, theme, css, thresholds = {} }) {
449
474
  structureCases(contract, theme, css);
450
- contrastCases(theme);
475
+ contrastCases(theme, thresholds);
451
476
  glyphCases(contract, theme);
452
477
  }