@scalewing/react 1.62.0 → 1.63.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,22 @@
1
1
  # @scalewing/react
2
2
 
3
+ ## 1.63.0
4
+
5
+ ### Minor Changes
6
+
7
+ - 25d86b1: `displayFaceFamilies` (tokens) and `ThemeProvider displayFace` (react): `condensed` sets a page's titles (`hero`, `display`, `headline`, `heading`) in Barlow Condensed, which the app loads, falling back to the platform's narrow sans; `system` (default) keeps the body face. It writes `data-display-face`, which a page without `ThemeProvider` sets itself. Body text, labels and controls keep the system face (FutMas F-024).
8
+
9
+ ### Patch Changes
10
+
11
+ - Updated dependencies [25d86b1]
12
+ - @scalewing/tokens@1.9.0
13
+
14
+ ## 1.62.1
15
+
16
+ ### Patch Changes
17
+
18
+ - 1b9b367: `FixtureCard`'s enabled score boxes take the page's background, so an empty box stays visible on a tinted dark `Card` (FutMas F-010). `FixtureRow`'s boxes are unchanged.
19
+
3
20
  ## 1.62.0
4
21
 
5
22
  ### Minor Changes
package/README.md CHANGED
@@ -101,6 +101,14 @@ The accent does not keep 4.5:1 on the grey in every palette, so keep links and a
101
101
  </ThemeProvider>
102
102
  ```
103
103
 
104
+ `displayFace="condensed"` (opt-in; `displayFaces`, default `"system"`) sets a page's titles, the `hero`, `display`, `headline` and `heading` text, in the tokens' condensed face (`displayFaceFamilies.condensed`: Barlow Condensed, falling back to the platform's narrow sans) with no negative tracking, for a page that should read like a fixture board or a poster. Body text, labels and controls keep the system face. Scalewing ships no font files: load Barlow Condensed yourself, self-hosted (for example from `@fontsource/barlow-condensed`). It writes `data-display-face="condensed"` on the themed node; a page rendered without `ThemeProvider` sets that attribute on its `data-theme` node itself. Every title under it changes, so `Hero`, a section's `headline` and a `Card` or dialog title in those variants take the face too; a nested `ThemeProvider` cannot turn it back to `system` (that value writes no attribute), so set it once at the page's root. An unknown face throws a `RangeError`.
105
+
106
+ ```tsx
107
+ <ThemeProvider displayFace="condensed" frame="site" colorScheme="system">
108
+ …
109
+ </ThemeProvider>
110
+ ```
111
+
104
112
  ```html
105
113
  <div class="sw-padding-top-4 sw-padding-x-4"></div>
106
114
  ```
@@ -0,0 +1,12 @@
1
+ import { type DisplayFace } from '@scalewing/tokens';
2
+ /**
3
+ * The face a page's titles take: `system` (default) keeps the body face;
4
+ * `condensed` sets `hero`, `display`, `headline` and `heading` text in the
5
+ * tokens' condensed face, which the consumer loads.
6
+ */
7
+ export declare const displayFaces: DisplayFace[];
8
+ export type { DisplayFace };
9
+ export declare function assertDisplayFace(face: unknown): asserts face is DisplayFace;
10
+ /** The Text variants a display face reaches: a page's titles, never its body. */
11
+ export declare const displayFaceVariants: readonly ["hero", "display", "headline", "heading"];
12
+ export declare function cssDisplayFaceRules(): string;
@@ -0,0 +1,34 @@
1
+ import { displayFaceFamilies } from '@scalewing/tokens';
2
+ /**
3
+ * The face a page's titles take: `system` (default) keeps the body face;
4
+ * `condensed` sets `hero`, `display`, `headline` and `heading` text in the
5
+ * tokens' condensed face, which the consumer loads.
6
+ */
7
+ export const displayFaces = Object.keys(displayFaceFamilies);
8
+ export function assertDisplayFace(face) {
9
+ if (!displayFaces.includes(face))
10
+ throw new RangeError(`Unknown display face: ${String(face)}`);
11
+ }
12
+ /** The Text variants a display face reaches: a page's titles, never its body. */
13
+ export const displayFaceVariants = [
14
+ 'hero',
15
+ 'display',
16
+ 'headline',
17
+ 'heading',
18
+ ];
19
+ /*
20
+ * `data-display-face` on the themed node (or any node above the titles)
21
+ * switches the titles' family. A condensed face is already narrow, so it
22
+ * drops the system face's negative tracking. Two classes outrank a variant's
23
+ * one, so the compact sizes below `md` keep their size and lose only the
24
+ * tracking.
25
+ */
26
+ export function cssDisplayFaceRules() {
27
+ const titles = displayFaceVariants
28
+ .map((variant) => `.sw-text-${variant}`)
29
+ .join(', ');
30
+ return `[data-display-face='condensed'] :is(${titles}) {
31
+ font-family: ${displayFaceFamilies.condensed};
32
+ letter-spacing: 0;
33
+ }`;
34
+ }
@@ -1,6 +1,7 @@
1
1
  import { typographyVariants } from '@scalewing/tokens';
2
2
  import { cssBoxLinkClasses } from './css-box-link.js';
3
3
  import { cssCanvasGroupedRules } from './css-canvas-grouped.js';
4
+ import { cssDisplayFaceRules } from './css-display-face.js';
4
5
  import { cssThemeFrameRules } from './css-theme-frame.js';
5
6
  const body = typographyVariants.body;
6
7
  /** The native controls that take typed text: the canvas's text controls. */
@@ -90,6 +91,8 @@ ${cssCanvasGroupedRules()}
90
91
 
91
92
  ${cssThemeFrameRules()}
92
93
 
94
+ ${cssDisplayFaceRules()}
95
+
93
96
  [data-theme] a {
94
97
  color: var(--sw-color-accent);
95
98
  text-decoration: none;
@@ -66,6 +66,16 @@ function cardRules() {
66
66
  overflow-wrap: anywhere;
67
67
  }`;
68
68
  }
69
+ /*
70
+ * A box on the Card's surface would share its fill in a tinted dark palette
71
+ * and nearly vanish while empty, so it takes the page's. A disabled box keeps
72
+ * the canvas's disabled look.
73
+ */
74
+ function boxRules() {
75
+ return `[data-theme] .sw-fixture-card input.sw-fixture-score-box:not(:disabled) {
76
+ background: var(--sw-color-background);
77
+ }`;
78
+ }
69
79
  /*
70
80
  * The score's message is a live region, so it stays in place while empty; a
71
81
  * block with no words has no height, and its margin comes only with words.
@@ -100,6 +110,8 @@ function belowRules() {
100
110
  export function cssFixtureCardClasses() {
101
111
  return `${cardRules()}
102
112
 
113
+ ${boxRules()}
114
+
103
115
  ${belowRules()}`;
104
116
  }
105
117
  export function fixtureCardClassCatalog() {
package/dist/index.d.ts CHANGED
@@ -80,6 +80,7 @@ export { Text, textFonts, textMaxLines, type TextAlign, type TextElement, type T
80
80
  export { ThemeProvider, useTheme, type ThemeProviderProps, } from './theme/ThemeProvider.js';
81
81
  export { themeCanvases, type ThemeCanvas } from './css/css-canvas-grouped.js';
82
82
  export { themeFrames, type ThemeFrame } from './css/css-theme-frame.js';
83
+ export { displayFaces, type DisplayFace } from './css/css-display-face.js';
83
84
  export { themeDensities, type ThemeDensity } from './css/css-density.js';
84
85
  export { utilityClassCatalog } from './css/stylesheet.js';
85
86
  export type { VisibilityProps } from './visibility-classes.js';
package/dist/index.js CHANGED
@@ -76,6 +76,7 @@ export { Text, textFonts, textMaxLines, } from './components/Text.js';
76
76
  export { ThemeProvider, useTheme, } from './theme/ThemeProvider.js';
77
77
  export { themeCanvases } from './css/css-canvas-grouped.js';
78
78
  export { themeFrames } from './css/css-theme-frame.js';
79
+ export { displayFaces } from './css/css-display-face.js';
79
80
  export { themeDensities } from './css/css-density.js';
80
81
  export { utilityClassCatalog } from './css/stylesheet.js';
81
82
  export { breakpointQuery } from './css/breakpoints.js';
package/dist/styles.css CHANGED
@@ -641,6 +641,11 @@ body {
641
641
  margin-top: auto;
642
642
  }
643
643
 
644
+ [data-display-face='condensed'] :is(.sw-text-hero, .sw-text-display, .sw-text-headline, .sw-text-heading) {
645
+ font-family: "Barlow Condensed", "Arial Narrow", sans-serif;
646
+ letter-spacing: 0;
647
+ }
648
+
644
649
  [data-theme] a {
645
650
  color: var(--sw-color-accent);
646
651
  text-decoration: none;
@@ -3795,6 +3800,10 @@ button.sw-date-toggle-day[aria-disabled='true'] {
3795
3800
  overflow-wrap: anywhere;
3796
3801
  }
3797
3802
 
3803
+ [data-theme] .sw-fixture-card input.sw-fixture-score-box:not(:disabled) {
3804
+ background: var(--sw-color-background);
3805
+ }
3806
+
3798
3807
  .sw-fixture-card-error {
3799
3808
  color: var(--sw-color-danger);
3800
3809
  display: block;
@@ -3,6 +3,7 @@ import { type ColorScheme, type PaletteId, type Theme, type ThemeColors } from '
3
3
  import { type ThemeCanvas } from '../css/css-canvas-grouped.js';
4
4
  import { type ThemeDensity } from '../css/css-density.js';
5
5
  import { type ThemeFrame } from '../css/css-theme-frame.js';
6
+ import { type DisplayFace } from '../css/css-display-face.js';
6
7
  export type ThemeProviderProps = {
7
8
  colorScheme?: ColorScheme | 'system';
8
9
  palette?: PaletteId;
@@ -24,6 +25,15 @@ export type ThemeProviderProps = {
24
25
  * a `RangeError`.
25
26
  */
26
27
  frame?: ThemeFrame;
28
+ /**
29
+ * `system` (default) sets titles in the body face; `condensed` (opt-in)
30
+ * sets `hero`, `display`, `headline` and `heading` text in the tokens'
31
+ * condensed face (Barlow Condensed, which the app loads). It writes
32
+ * `data-display-face` on the themed node, which every title inside
33
+ * inherits; a nested provider's `system` cannot undo it, so set it once at
34
+ * the page's root. An unknown value throws a `RangeError`.
35
+ */
36
+ displayFace?: DisplayFace;
27
37
  /**
28
38
  * `comfortable` (default) draws today's touch-sized controls. `compact`
29
39
  * (opt-in) is a desktop data tool's scale, on a fine pointer only (a touch
@@ -37,5 +47,5 @@ export type ThemeProviderProps = {
37
47
  density?: ThemeDensity;
38
48
  children: ReactNode;
39
49
  };
40
- export declare function ThemeProvider({ colorScheme, palette, colors, canvas, frame, density, children, }: ThemeProviderProps): import("react").JSX.Element;
50
+ export declare function ThemeProvider({ colorScheme, palette, colors, canvas, frame, displayFace, density, children, }: ThemeProviderProps): import("react").JSX.Element;
41
51
  export declare function useTheme(): Theme;
@@ -4,6 +4,7 @@ import { createTheme, secondaryActionBorder, semanticColorKeys, } from '@scalewi
4
4
  import { assertThemeCanvas, } from '../css/css-canvas-grouped.js';
5
5
  import { assertThemeDensity } from '../css/css-density.js';
6
6
  import { assertThemeFrame } from '../css/css-theme-frame.js';
7
+ import { assertDisplayFace, } from '../css/css-display-face.js';
7
8
  const ThemeContext = createContext(null);
8
9
  /** The density of the ThemeProvider around this one. */
9
10
  const DensityContext = createContext('comfortable');
@@ -29,9 +30,10 @@ function themeCssVars(theme) {
29
30
  vars['--sw-glass-specular'] = theme.glass.specular;
30
31
  return vars;
31
32
  }
32
- export function ThemeProvider({ colorScheme = 'system', palette, colors, canvas = 'default', frame = 'none', density = 'comfortable', children, }) {
33
+ export function ThemeProvider({ colorScheme = 'system', palette, colors, canvas = 'default', frame = 'none', displayFace = 'system', density = 'comfortable', children, }) {
33
34
  assertThemeCanvas(canvas);
34
35
  assertThemeFrame(frame);
36
+ assertDisplayFace(displayFace);
35
37
  assertThemeDensity(density);
36
38
  const resolvedDensity = useContext(DensityContext) === 'compact' ? 'compact' : density;
37
39
  const [systemScheme, setSystemScheme] = useState(schemeFromMedia);
@@ -49,7 +51,7 @@ export function ThemeProvider({ colorScheme = 'system', palette, colors, canvas
49
51
  }, [colorScheme]);
50
52
  const resolvedScheme = colorScheme === 'system' ? systemScheme : colorScheme;
51
53
  const theme = useMemo(() => createTheme({ colorScheme: resolvedScheme, palette, colors }), [colors, palette, resolvedScheme]);
52
- return (_jsx(ThemeContext.Provider, { value: theme, children: _jsx(DensityContext.Provider, { value: resolvedDensity, children: _jsx("div", { "data-canvas": canvas === 'default' ? undefined : canvas, "data-density": resolvedDensity === 'compact' ? 'compact' : undefined, "data-frame": frame === 'none' ? undefined : frame, "data-palette": palette, "data-theme": theme.colorScheme, style: themeCssVars(theme), children: children }) }) }));
54
+ return (_jsx(ThemeContext.Provider, { value: theme, children: _jsx(DensityContext.Provider, { value: resolvedDensity, children: _jsx("div", { "data-canvas": canvas === 'default' ? undefined : canvas, "data-density": resolvedDensity === 'compact' ? 'compact' : undefined, "data-display-face": displayFace === 'system' ? undefined : displayFace, "data-frame": frame === 'none' ? undefined : frame, "data-palette": palette, "data-theme": theme.colorScheme, style: themeCssVars(theme), children: children }) }) }));
53
55
  }
54
56
  export function useTheme() {
55
57
  const theme = useContext(ThemeContext);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@scalewing/react",
3
- "version": "1.62.0",
3
+ "version": "1.63.0",
4
4
  "description": "Scalewing DOM components and package-owned CSS utilities.",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -45,7 +45,7 @@
45
45
  "dependencies": {
46
46
  "markdown-it": "14.3.2",
47
47
  "pdfjs-dist": "6.4.299",
48
- "@scalewing/tokens": "^1.8.0"
48
+ "@scalewing/tokens": "^1.9.0"
49
49
  },
50
50
  "peerDependencies": {
51
51
  "react": "^19.0.0",