@jay-framework/design-system-validator 0.22.2 → 0.24.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.
@@ -0,0 +1,2 @@
1
+ label: Design themes
2
+ route: /design-system/settings
@@ -97,7 +97,7 @@ Use the token values directly in your `<style>` blocks:
97
97
  }
98
98
  ```
99
99
 
100
- CSS custom properties (`var(--name)`) are resolved statically when defined in `:root`. Unresolvable vars are accepted without validation.
100
+ CSS custom properties (`var(--name)`) are resolved statically when defined in the page's CSS (inline `<style>` or linked local stylesheets). Variables that are used but never defined are flagged as warnings.
101
101
 
102
102
  ## Breakpoints
103
103
 
@@ -132,12 +132,18 @@ The `components` section defines expected styles for HTML elements (matched by c
132
132
 
133
133
  When a value intentionally breaks the design system, exempt it:
134
134
 
135
- **In CSS** — add a comment after the declaration:
135
+ **In CSS** — add a comment on the same line or the line immediately after the declaration:
136
136
 
137
137
  ```css
138
138
  .hero {
139
139
  padding: 7.5rem 0; /* design-system: allow */
140
140
  }
141
+
142
+ /* or on the next line: */
143
+ .hero {
144
+ padding: 7.5rem 0;
145
+ /* design-system: allow */
146
+ }
141
147
  ```
142
148
 
143
149
  **On elements** — add the `jay-design="allow"` attribute:
@@ -213,6 +219,14 @@ These are the errors the validator produces. Use them to align your CSS with the
213
219
  Suggestion: Use a DESIGN.md breakpoint: mobile (600px), tablet (768px), desktop (1024px)
214
220
  ```
215
221
 
222
+ **Undefined CSS variable:**
223
+
224
+ ```
225
+ ⚠ CSS variable "--color-surface-tint" is used but never defined
226
+ Suggestion: Define --color-surface-tint in a :root block, or replace with a DESIGN.md token value directly.
227
+ To suppress: add /* design-system: allow */ on the same line or the line after the declaration.
228
+ ```
229
+
216
230
  **Low contrast:**
217
231
 
218
232
  ```
@@ -0,0 +1,78 @@
1
+ # Font Fallback Patterns
2
+
3
+ ## Why metric-matched fallbacks matter
4
+
5
+ When a web font loads via `font-display: swap`, the browser renders a system fallback font first. Differences in vertical metrics (ascent, descent, line-gap) and horizontal metrics (character width) between the web font and fallback cause visible layout jumps — known as Flash of Unstyled Text (FOUT) — and degrade Cumulative Layout Shift (CLS).
6
+
7
+ A metric-matched fallback `@font-face` overrides the system font's metrics to match the web font, so the swap is visually seamless.
8
+
9
+ ## Using the action
10
+
11
+ Generate a fallback `@font-face` for any known Google Font or system font:
12
+
13
+ ```bash
14
+ npx jay-stack-cli action design-system-validator/fontFallback --input '{"primary":"Inter","fallback":"Arial"}'
15
+ ```
16
+
17
+ This outputs the CSS you need:
18
+
19
+ ```css
20
+ @font-face {
21
+ font-family: 'Inter Fallback';
22
+ src: local('Arial'), local('ArialMT');
23
+ ascent-override: 90.44%;
24
+ descent-override: 22.52%;
25
+ line-gap-override: 0%;
26
+ size-adjust: 107.12%;
27
+ }
28
+ ```
29
+
30
+ Then add the fallback to your `font-family` stack:
31
+
32
+ ```css
33
+ body {
34
+ font-family: 'Inter', 'Inter Fallback', sans-serif;
35
+ }
36
+ ```
37
+
38
+ ## Where to place the fallback CSS
39
+
40
+ - **DESIGN.md**: If your design system defines fonts in the frontmatter, add the fallback `@font-face` to the page's `<style>` block or a shared stylesheet
41
+ - **Page `<head>` styles**: For per-page fonts, place the `@font-face` in the page's `<style>` tag
42
+
43
+ ## Common font pairs
44
+
45
+ | Web font | Fallback | Category |
46
+ | ---------------- | -------- | ---------- |
47
+ | Inter | Arial | sans-serif |
48
+ | Roboto | Arial | sans-serif |
49
+ | Open Sans | Arial | sans-serif |
50
+ | Playfair Display | Georgia | serif |
51
+ | Merriweather | Georgia | serif |
52
+ | Lora | Georgia | serif |
53
+
54
+ ## Manual pattern
55
+
56
+ If the action doesn't support your font, you can write the fallback manually. The key CSS properties are:
57
+
58
+ - `size-adjust` — scales the fallback to match the web font's character width
59
+ - `ascent-override` — matches the space above the baseline
60
+ - `descent-override` — matches the space below the baseline
61
+ - `line-gap-override` — matches the inter-line spacing
62
+
63
+ ```css
64
+ @font-face {
65
+ font-family: 'MyFont-Fallback';
66
+ src: local('Arial');
67
+ size-adjust: <value>%;
68
+ ascent-override: <value>%;
69
+ descent-override: <value>%;
70
+ line-gap-override: <value>%;
71
+ }
72
+ ```
73
+
74
+ ## Validation
75
+
76
+ The `font-fallbacks` validator detects `@font-face` rules that load from a URL without a companion metric-matched fallback. It checks both page CSS and DESIGN.md typography tokens.
77
+
78
+ To suppress a false positive, use the standard `/* design-system: allow */` comment after the `font-family` declaration.
@@ -0,0 +1,12 @@
1
+ name: fontFallback
2
+ description: >
3
+ Generate a metric-matched fallback @font-face for a web font to prevent layout shift (CLS).
4
+ Uses pre-computed metrics from @capsizecss/metrics for known Google and system fonts.
5
+
6
+ inputSchema:
7
+ primary: string
8
+ fallback: string
9
+
10
+ outputSchema:
11
+ fontFamily: string
12
+ fontFaces: string
@@ -0,0 +1,7 @@
1
+ import * as _jay_framework_fullstack_component from '@jay-framework/fullstack-component';
2
+ import { Signals, PageProps } from '@jay-framework/fullstack-component';
3
+ import * as _jay_framework_component from '@jay-framework/component';
4
+
5
+ declare const designSystemSettingsPage: _jay_framework_fullstack_component.JayStackComponentDefinition<any, any, any, any, [], [Signals<any>, {}], PageProps, {}, _jay_framework_component.JayComponentCore<PageProps, any>>;
6
+
7
+ export { designSystemSettingsPage };