@reqvire-org/ads 0.3.50 → 0.3.51
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/README.md +1 -1
- package/dist/browser-audit/first-render.mjs +18 -0
- package/dist/browser-audit/layout-overflow.mjs +80 -39
- package/dist/browser-audit/worker.mjs +16 -8
- package/dist/browser-audit.mjs +52 -11
- package/dist/capture/worker.mjs +2 -5
- package/dist/check.mjs +5 -3
- package/dist/cli.mjs +3 -2
- package/dist/config.mjs +2 -2
- package/dist/finding-rules.mjs +5 -0
- package/dist/layout-widths.mjs +123 -79
- package/dist/skills/ads-break-ui/SKILL.md +2 -1
- package/dist/skills/ads-break-ui/references/design-data.md +27 -14
- package/dist/skills/ads-break-ui/references/validation.md +1 -1
- package/dist/skills/ads-designer/SKILL.md +6 -4
- package/dist/skills/ads-designer/references/design-data.md +27 -14
- package/dist/skills/ads-designer/references/validation.md +1 -1
- package/dist/skills/ads-import/references/design-data.md +27 -14
- package/dist/skills/ads-import/references/validation.md +1 -1
- package/dist/skills/ads-motion/references/design-data.md +27 -14
- package/dist/skills/ads-motion/references/validation.md +1 -1
- package/dist/skills/ads-port/references/design-data.md +27 -14
- package/dist/skills/ads-port/references/validation.md +1 -1
- package/dist/starters/preact/ds.config.json +0 -1
- package/dist/starters/react/README.md +6 -4
- package/dist/starters/react/design-system/components/Content/Image/Image.tsx +7 -4
- package/dist/starters/react/design-system/components/Content/Image/README.md +2 -2
- package/dist/starters/react/design-system/tokens/spacing.css +1 -1
- package/dist/starters/react/ds.config.json +0 -1
- package/docs/ADS.md +2 -2
- package/docs/ARCHITECTURE.md +9 -6
- package/docs/CHANGELOG.md +47 -12
- package/docs/GUIDE.md +50 -20
- package/package.json +1 -1
package/dist/layout-widths.mjs
CHANGED
|
@@ -2,30 +2,30 @@ import valueParser from "postcss-value-parser";
|
|
|
2
2
|
import { contextValues } from "./themes.mjs";
|
|
3
3
|
import { findingSeverity } from "./finding-rules.mjs";
|
|
4
4
|
|
|
5
|
-
/**
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
* A
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
* layout.widthTokens pass
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
* knows a unit's layer, not whether it floats. */
|
|
5
|
+
/** In component, pattern and composition styles, a width (width, min-width, the logical inline
|
|
6
|
+
* sizes, flex-basis or the flex shorthand's basis, and grid-template-columns tracks) is a
|
|
7
|
+
* layout-fixed-width error when it cannot shrink below smallPartLimitPx: raw, through tokens, in
|
|
8
|
+
* any length unit, or by arithmetic. Every value is read as what it resolves to in the smallest
|
|
9
|
+
* and the largest container, so max(100%, 280px) is fixed at 280px, and min(100%, 280px) is not.
|
|
10
|
+
* A maximum cannot force overflow, so max-width and max-inline-size are not read at all, except
|
|
11
|
+
* that a fluid one in the same rule lets a width shrink.
|
|
12
|
+
* What the source cannot settle (a variable with no definition) passes; the audit renders it.
|
|
13
|
+
* Tokens named by layout.widthTokens pass when used plainly, and fixed ones are listed for review,
|
|
14
|
+
* as are the fixed widths of owners matched by layout.fixedWidthUnits, which is where overlays
|
|
15
|
+
* such as dialogs, menus, popovers and tooltips are declared: ADS knows a unit's layer, not
|
|
16
|
+
* whether it floats. */
|
|
18
17
|
|
|
19
|
-
|
|
20
|
-
const
|
|
21
|
-
const
|
|
22
|
-
const
|
|
23
|
-
/**
|
|
24
|
-
|
|
25
|
-
const
|
|
26
|
-
const absoluteUnits = { px: 1, rem: 16, pt: 4 / 3, pc: 16, in: 96, cm: 96 / 2.54, mm: 96 / 25.4, q: 96 / 101.6 };
|
|
18
|
+
/** The largest plain size a part may have: see the Layout section of the guide for the evidence. */
|
|
19
|
+
export const smallPartLimitPx = 96;
|
|
20
|
+
const widthProperties = new Set(["width", "min-width", "inline-size", "min-inline-size", "flex-basis", "flex", "grid-template-columns"]);
|
|
21
|
+
const fluidUnits = /^(?:%|fr|[sld]?v(?:w|h|i|b|min|max)|cq(?:w|h|i|b|min|max))$/i;
|
|
22
|
+
/** Lengths in px; a font-relative one at the 16 px root font, as an estimate. It is still fixed. */
|
|
23
|
+
const absoluteUnits = { px: 1, pt: 4 / 3, pc: 16, in: 96, cm: 96 / 2.54, mm: 96 / 25.4, q: 96 / 101.6 };
|
|
24
|
+
const fontUnits = { rem: 16, em: 16, ic: 16, ch: 8, ex: 8, cap: 11, lh: 24, rlh: 24 };
|
|
27
25
|
const keywords = /^(?:auto|none|min-content|max-content|fit-content|stretch|inherit|initial|unset|revert|revert-layer|content|subgrid)$/i;
|
|
28
|
-
const fluid = {
|
|
26
|
+
const fluid = { low: 0, high: Infinity }, neutral = { neutral: true }, unknown = { unknown: true };
|
|
27
|
+
const isLength = part => part.low !== undefined;
|
|
28
|
+
const fixedAt = px => ({ low: px, high: px });
|
|
29
29
|
|
|
30
30
|
/** A regular expression for a token or path glob: * within a path segment, ** across them. */
|
|
31
31
|
export function globPattern(glob) {
|
|
@@ -44,54 +44,72 @@ function splitArguments(nodes) {
|
|
|
44
44
|
export function createLayoutWidths(tokens, { themes, layout }) {
|
|
45
45
|
const values = contextValues(tokens, { theme: themes[0].name, themes });
|
|
46
46
|
const widthToken = globMatcher(layout.widthTokens);
|
|
47
|
-
const
|
|
48
|
-
/** A named width token is allowed; only a fixed --container-* cap is limited to max sizes. */
|
|
49
|
-
const cap = name => capToken.test(name) && values.has(name) && !isFluid(name, values.get(name).value);
|
|
47
|
+
const declaredUses = new Map();
|
|
50
48
|
|
|
51
49
|
function variable(node, scope) {
|
|
52
50
|
const [name, fallback = []] = splitArguments(node.nodes).map(meaningful);
|
|
53
51
|
const token = name?.find(child => child.type === "word")?.value;
|
|
54
52
|
if (!token?.startsWith("--")) return unknown;
|
|
55
|
-
if (widthToken(token)) return cap(token) ? { cap: token } : neutral;
|
|
56
|
-
if (sizeFamilies.test(token)) return neutral;
|
|
57
53
|
if (scope.seen.has(token)) return unknown;
|
|
58
54
|
const seen = new Set([...scope.seen, token]);
|
|
59
55
|
// Component variables declared in the same template are read through, so a width cannot hide in one.
|
|
60
56
|
const local = scope.locals.get(token);
|
|
61
|
-
if (local)
|
|
57
|
+
if (local) {
|
|
58
|
+
const results = local.map(value => sequence(valueParser(value).nodes, { ...scope, seen })).filter(isLength);
|
|
59
|
+
return results.length ? results.reduce((worst, result) => result.low > worst.low ? result : worst) : unknown;
|
|
60
|
+
}
|
|
62
61
|
const value = values.get(token)?.value;
|
|
63
62
|
if (value === undefined) return fallback.length ? sequence(fallback, { ...scope, seen }) : unknown;
|
|
64
63
|
const result = sequence(valueParser(value).nodes, { ...scope, seen });
|
|
65
|
-
|
|
64
|
+
if (!widthToken(token)) return result;
|
|
65
|
+
scope.declared?.add(token);
|
|
66
|
+
return { ...(isLength(result) ? result : neutral), declared: token };
|
|
66
67
|
}
|
|
67
|
-
/** One value part: {
|
|
68
|
+
/** One value part: { neutral } | { unknown } | { number } | { low, high, declared? }, the length
|
|
69
|
+
* it resolves to in the smallest and the largest container. */
|
|
68
70
|
function measure(node, scope) {
|
|
69
71
|
if (node.type === "word") {
|
|
70
72
|
const parsed = valueParser.unit(node.value);
|
|
71
73
|
if (!parsed) return keywords.test(node.value) ? neutral : unknown;
|
|
72
74
|
const number = Number(parsed.number), unit = parsed.unit.toLowerCase();
|
|
73
|
-
if (!unit) return { number };
|
|
74
|
-
if (number === 0
|
|
75
|
-
|
|
75
|
+
if (!unit) return number === 0 ? fixedAt(0) : { number };
|
|
76
|
+
if (number === 0) return fixedAt(0);
|
|
77
|
+
if (fluidUnits.test(unit)) return fluid;
|
|
78
|
+
const size = absoluteUnits[unit] ?? fontUnits[unit];
|
|
79
|
+
return size ? fixedAt(number * size) : unknown;
|
|
76
80
|
}
|
|
77
81
|
if (node.type !== "function") return unknown;
|
|
78
82
|
const name = node.value.toLowerCase();
|
|
79
83
|
if (name === "var") return variable(node, scope);
|
|
80
84
|
if (name === "calc" || name === "") return calculation(node.nodes, scope);
|
|
81
85
|
if (name === "fit-content") return neutral;
|
|
82
|
-
if (
|
|
83
|
-
|
|
84
|
-
if (
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
86
|
+
if (name === "min") return smallest(splitArguments(node.nodes).map(part => sequence(part, scope)));
|
|
87
|
+
if (name === "max") return largest(splitArguments(node.nodes).map(part => sequence(part, scope)));
|
|
88
|
+
if (name !== "clamp") return unknown;
|
|
89
|
+
const [floor, preferred, ceiling] = splitArguments(node.nodes).map(part => sequence(part, scope));
|
|
90
|
+
if (floor?.neutral) return ceiling?.neutral || !ceiling ? preferred ?? unknown : smallest([preferred, ceiling]);
|
|
91
|
+
return largest([floor, !ceiling || ceiling.neutral ? preferred : smallest([preferred, ceiling])]);
|
|
92
|
+
}
|
|
93
|
+
/** min(): a part that reaches zero lets the whole shrink, whatever the others are. */
|
|
94
|
+
function smallest(parts) {
|
|
95
|
+
const lengths = parts.filter(isLength), open = lengths.length !== parts.length;
|
|
96
|
+
if (!lengths.length || open && !lengths.some(part => part.low === 0)) return unknown;
|
|
97
|
+
return { low: Math.min(...lengths.map(part => part.low)), high: open ? Infinity : Math.min(...lengths.map(part => part.high)) };
|
|
98
|
+
}
|
|
99
|
+
/** max(): it cannot shrink below any part, so a part that cannot be read leaves it unread. */
|
|
100
|
+
function largest(parts) {
|
|
101
|
+
if (!parts.every(isLength)) return unknown;
|
|
102
|
+
return { low: Math.max(...parts.map(part => part.low)), high: Math.max(...parts.map(part => part.high)) };
|
|
89
103
|
}
|
|
90
104
|
function sequence(nodes, scope) {
|
|
91
105
|
const items = meaningful(nodes);
|
|
92
106
|
return items.length === 1 ? measure(items[0], scope) : unknown;
|
|
93
107
|
}
|
|
94
|
-
|
|
108
|
+
const scaled = (length, factor) => {
|
|
109
|
+
const [low, high] = [length.low, length.high].map(size => factor === 0 ? 0 : size * factor);
|
|
110
|
+
return factor < 0 ? { low: high, high: low } : { low, high };
|
|
111
|
+
};
|
|
112
|
+
/** calc(): evaluated at both ends, so 100% - 200px reaches zero and 100% + 200px does not. */
|
|
95
113
|
function calculation(nodes, scope) {
|
|
96
114
|
const operands = [], operators = [];
|
|
97
115
|
for (const item of meaningful(nodes)) {
|
|
@@ -101,83 +119,109 @@ export function createLayoutWidths(tokens, { themes, layout }) {
|
|
|
101
119
|
// valueParser keeps * and calc()'s / in a word, spaced or not.
|
|
102
120
|
for (const part of item.value.split(/([*/])/).filter(Boolean)) { if (part === "*" || part === "/") operators.push(part); else operands.push(measure({ type: "word", value: part }, scope)); }
|
|
103
121
|
}
|
|
104
|
-
if (operands.some(operand => operand.
|
|
105
|
-
if (operands.length !== operators.length + 1 || operands.some(operand => operand.px === undefined && operand.number === undefined)) return unknown;
|
|
122
|
+
if (operands.length !== operators.length + 1 || operands.some(operand => !isLength(operand) && operand.number === undefined)) return unknown;
|
|
106
123
|
// Multiplication and division bind first.
|
|
107
124
|
const terms = [operands[0]], signs = [];
|
|
108
125
|
operators.forEach((operator, index) => {
|
|
109
126
|
const next = operands[index + 1];
|
|
110
127
|
if (operator !== "*" && operator !== "/") { terms.push(next); signs.push(operator); return; }
|
|
111
|
-
const last = terms.pop(), length = last
|
|
112
|
-
if (length
|
|
113
|
-
else
|
|
128
|
+
const last = terms.pop(), length = isLength(last) ? last : next, factor = isLength(last) ? next.number : last.number;
|
|
129
|
+
if (!isLength(length)) terms.push({ number: operator === "*" ? last.number * next.number : last.number / next.number });
|
|
130
|
+
else if (factor === undefined) terms.push(unknown);
|
|
131
|
+
else terms.push(scaled(length, operator === "*" ? factor : 1 / factor));
|
|
132
|
+
});
|
|
133
|
+
if (!terms.every(isLength)) return unknown;
|
|
134
|
+
let { low, high } = terms[0];
|
|
135
|
+
terms.slice(1).forEach((term, index) => {
|
|
136
|
+
if (signs[index] === "+") { low += term.low; high += term.high; } else { low -= term.high; high -= term.low; }
|
|
114
137
|
});
|
|
115
|
-
|
|
116
|
-
const px = terms.slice(1).reduce((sum, term, index) => signs[index] === "+" ? sum + term.px : sum - term.px, terms[0].px);
|
|
117
|
-
return { px, space: operands.some(operand => operand.space), math: operators.length > 0 };
|
|
138
|
+
return { low: Math.max(low, 0), high: Math.max(high, 0) };
|
|
118
139
|
}
|
|
119
|
-
/** The sizes of a grid-template-columns value
|
|
140
|
+
/** The sizes of a grid-template-columns value. minmax() can shrink to its minimum, and a track
|
|
141
|
+
* repeated with auto-fill or auto-fit wraps instead of forcing overflow. */
|
|
120
142
|
function tracks(nodes, scope) {
|
|
121
143
|
const sizes = [];
|
|
122
144
|
for (const node of meaningful(nodes)) {
|
|
123
145
|
const name = node.type === "function" ? node.value.toLowerCase() : "";
|
|
124
146
|
if (node.type === "word" && node.value.startsWith("[")) continue;
|
|
125
|
-
if (name === "repeat")
|
|
126
|
-
|
|
127
|
-
|
|
147
|
+
if (name === "repeat") {
|
|
148
|
+
const [count, ...rest] = splitArguments(node.nodes);
|
|
149
|
+
if (!/^auto-(?:fill|fit)$/i.test(meaningful(count)[0]?.value ?? "")) sizes.push(...tracks(rest.flat(), scope));
|
|
150
|
+
} else if (name === "minmax") {
|
|
151
|
+
const floor = sequence(splitArguments(node.nodes)[0] ?? [], scope);
|
|
152
|
+
sizes.push(isLength(floor) ? { ...floor, high: Infinity } : neutral);
|
|
153
|
+
} else sizes.push(measure(node, scope));
|
|
128
154
|
}
|
|
129
155
|
return sizes;
|
|
130
156
|
}
|
|
131
|
-
/**
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
157
|
+
/** What a width that can give way looks like, in the terms of the property it is set on. */
|
|
158
|
+
const fix = (property, value, px) => property === "grid-template-columns" ? `a track of minmax(0, ${px}px)` : property === "flex" || property === "flex-basis" ? `flex: 1 1 ${px}px` : `${property}: min(100%, ${value})`;
|
|
159
|
+
/** What is wrong with a resolved width: { error } | { review } | null when it is fluid or allowed. */
|
|
160
|
+
function verdict(result, property, value) {
|
|
161
|
+
if (!isLength(result) || result.declared) return null;
|
|
162
|
+
if (result.low > smallPartLimitPx) {
|
|
163
|
+
const px = Math.round(result.low);
|
|
164
|
+
return { error: result.low === result.high ? `fixed at about ${px}px` : `unable to shrink below about ${px}px`, fix: fix(property, value, px) };
|
|
165
|
+
}
|
|
166
|
+
return result.low !== result.high && result.high <= smallPartLimitPx ? { review: Math.round(result.high) } : null;
|
|
167
|
+
}
|
|
168
|
+
function judge(property, value, scope) {
|
|
139
169
|
const nodes = valueParser(value).nodes;
|
|
140
170
|
if (property === "grid-template-columns") {
|
|
141
|
-
for (const track of tracks(nodes, scope)) { const
|
|
171
|
+
for (const track of tracks(nodes, scope)) { const found = verdict(track, property, value); if (found?.error) return { ...found, error: `a track ${found.error}` }; }
|
|
142
172
|
return null;
|
|
143
173
|
}
|
|
144
174
|
if (property === "flex") {
|
|
145
175
|
const parts = meaningful(nodes);
|
|
146
176
|
if (parts.length < 2) return null;
|
|
147
177
|
const basis = parts.at(-1), shrink = parts.length === 3 ? Number(parts[1].value) : 1;
|
|
148
|
-
return Number(parts[0].value) > 0 && shrink > 0 ? null : verdict(measure(basis, scope));
|
|
178
|
+
return Number(parts[0].value) > 0 && shrink > 0 ? null : verdict(measure(basis, scope), property, value);
|
|
149
179
|
}
|
|
150
|
-
return verdict(sequence(nodes, scope));
|
|
180
|
+
return verdict(sequence(nodes, scope), property, value);
|
|
151
181
|
}
|
|
152
182
|
|
|
153
183
|
return {
|
|
154
|
-
/** layout-fixed-width findings for one parsed style sheet or Linaria template. */
|
|
184
|
+
/** layout-fixed-width and layout-width-noop findings for one parsed style sheet or Linaria template. */
|
|
155
185
|
inspect(css, file, offset = { line: 1, column: 1 }) {
|
|
156
186
|
const findings = [], locals = new Map();
|
|
157
187
|
css.walkDecls(/^--/, decl => { locals.set(decl.prop, [...(locals.get(decl.prop) ?? []), decl.value]); });
|
|
158
188
|
css.walkDecls(decl => {
|
|
159
189
|
const property = decl.prop.toLowerCase();
|
|
160
190
|
if (!widthProperties.has(property) || decl.value.includes("__ds_expression__")) return;
|
|
161
|
-
const
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
191
|
+
const declared = new Set(), scope = { seen: new Set(), locals, declared }, found = judge(property, decl.value, scope);
|
|
192
|
+
for (const token of declared) declaredUses.set(token, (declaredUses.get(token) ?? 0) + 1);
|
|
193
|
+
if (!found) return;
|
|
194
|
+
// width: 280px with max-width: 100% in the same rule is min(100%, 280px).
|
|
195
|
+
if (found.error && /^(?:width|inline-size)$/.test(property) && decl.parent.nodes.some(sibling => sibling.type === "decl" && /^max-(?:width|inline-size)$/i.test(sibling.prop) && sequence(valueParser(sibling.value).nodes, scope).low === 0)) return;
|
|
196
|
+
const line = offset.line + decl.source.start.line - 1, column = decl.source.start.column + (decl.source.start.line === 1 ? offset.column - 1 : 0);
|
|
197
|
+
if (found.review !== undefined) {
|
|
198
|
+
findings.push({ rule: "layout-width-noop", severity: findingSeverity("layout-width-noop"), file, line, column, property, value: decl.value, guidanceUri: "ads://guides/tokens",
|
|
199
|
+
message: `${file}:${line} sets ${property}: ${decl.value}. It never exceeds ${found.review}px, within the ${smallPartLimitPx}px a small part may use plainly, so the fluid part does nothing. Write the plain size.` });
|
|
200
|
+
return;
|
|
201
|
+
}
|
|
202
|
+
findings.push({ rule: "layout-fixed-width", severity: findingSeverity("layout-fixed-width"), file, line, column, property, value: decl.value, guidanceUri: "ads://guides/tokens",
|
|
203
|
+
message: `${file}:${line} sets ${property}: ${decl.value}, ${found.error}, above the ${smallPartLimitPx}px a small part may use. The fix depends on what this is. A small part: size it at ${smallPartLimitPx}px or less, plainly, and leave it. A panel, column or anything else that can give way: ${found.fix}. A part that truly stays this wide: give it a token, list the token in layout.widthTokens in ds.config.json, and use the token plainly; ads check lists it for review. These do not fix it: another unit (ch, em and rem are fixed too), max() or a min() that stays under ${smallPartLimitPx}px, or a token name such as --control-*, since no name is exempt.` });
|
|
166
204
|
});
|
|
167
205
|
return findings;
|
|
168
206
|
},
|
|
169
|
-
/** Every
|
|
170
|
-
|
|
207
|
+
/** Every fixed width the project declared, for review, so that it stays visible: tokens named by
|
|
208
|
+
* layout.widthTokens with how many widths use them, and what fixedWidthUnits owners set. Call
|
|
209
|
+
* it after inspect has seen every style. */
|
|
210
|
+
declaredWidths(ownerFindings = []) {
|
|
171
211
|
const findings = [];
|
|
172
212
|
for (const token of tokens) {
|
|
173
|
-
if (!widthToken(token.name)
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
213
|
+
if (!widthToken(token.name)) continue;
|
|
214
|
+
const value = values.get(token.name)?.value;
|
|
215
|
+
const result = value === undefined ? unknown : sequence(valueParser(value).nodes, { seen: new Set([token.name]), locals: new Map() });
|
|
216
|
+
if (!isLength(result) || result.low <= smallPartLimitPx) continue;
|
|
217
|
+
const definition = token.definitions[0], uses = declaredUses.get(token.name) ?? 0;
|
|
218
|
+
findings.push({ rule: "layout-declared-width", severity: findingSeverity("layout-declared-width"), file: definition.file, line: definition.line, column: definition.column, tokens: [token.name], guidanceUri: "ads://guides/tokens",
|
|
219
|
+
message: `${token.name} is ${value}, declared in layout.widthTokens: it cannot shrink below about ${Math.round(result.low)}px. ${uses ? `${uses} width declaration${uses === 1 ? " uses" : "s use"} it. Confirm it must stay fixed.` : "No width uses it, and a maximum needs no declaration: remove it from layout.widthTokens."}` });
|
|
180
220
|
}
|
|
221
|
+
const owners = new Map();
|
|
222
|
+
for (const finding of ownerFindings) owners.set(finding.file, [...(owners.get(finding.file) ?? []), finding]);
|
|
223
|
+
for (const [file, list] of owners) findings.push({ rule: "layout-declared-width", severity: findingSeverity("layout-declared-width"), file, line: list[0].line, column: list[0].column, guidanceUri: "ads://guides/tokens",
|
|
224
|
+
message: `${file} is in layout.fixedWidthUnits, so its widths are not checked: ${list.map(finding => `${finding.property}: ${finding.value} (line ${finding.line})`).join(", ")}. Confirm it floats above the layout.` });
|
|
181
225
|
return findings;
|
|
182
226
|
},
|
|
183
227
|
};
|
|
@@ -41,7 +41,8 @@ request already identifies the target.
|
|
|
41
41
|
|
|
42
42
|
Run `ads audit` on the stressed scenario. `layout-overflow` fails it when the page overflows
|
|
43
43
|
horizontally, an element reaches past the viewport or content is clipped at 390, 768 or 1280
|
|
44
|
-
px. `overflow-x: auto` scrollers and
|
|
44
|
+
px, or a set width above 96 px overflows a 240 px container. `overflow-x: auto` scrollers and
|
|
45
|
+
`text-overflow: ellipsis` are exempt. Fix a failure with
|
|
45
46
|
fluid widths (`%`, `fr`, a `--grid-span-N` token in a container query), `min-width: 0` on flex
|
|
46
47
|
and grid children, and wrapping, not with `overflow: hidden`.
|
|
47
48
|
|
|
@@ -134,7 +134,7 @@ container width (768 and 1024 px) with container queries, since CSS variables ca
|
|
|
134
134
|
breakpoints. The showcase's grid overlay draws these tokens over every preview at the same
|
|
135
135
|
widths; a project without them shows no overlay. Align text to a cell's edge, not its gutter.
|
|
136
136
|
|
|
137
|
-
### Widths are fluid on the grid
|
|
137
|
+
### Widths are fluid on the grid
|
|
138
138
|
|
|
139
139
|
`--grid-span-1` to `--grid-span-16` are widths of N of 16 columns, fluid in their container.
|
|
140
140
|
Set one inside a container query, under a `Grid` or another `container-type: inline-size`
|
|
@@ -155,23 +155,36 @@ Atomic CSS does not keep rule order, so two queries on one property need exclusi
|
|
|
155
155
|
Use `%` or `fr` for a share of the parent and a `ch` measure for running text
|
|
156
156
|
(`max-inline-size: 65ch`).
|
|
157
157
|
|
|
158
|
-
`layout-fixed-width` is an error for `width`, `min-width`,
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
158
|
+
`layout-fixed-width` is an error for `width`, `min-width`, the logical inline sizes, `flex-basis`,
|
|
159
|
+
`flex`'s basis and `grid-template-columns` tracks that cannot shrink below 96 px, in any unit, raw,
|
|
160
|
+
through a token or by arithmetic. `max-width` and `max-inline-size` are not read: a maximum cannot
|
|
161
|
+
force overflow, so cap with them freely.
|
|
162
162
|
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
A
|
|
169
|
-
|
|
170
|
-
|
|
163
|
+
When it fires, pick the fix by what the element is:
|
|
164
|
+
|
|
165
|
+
| The element | Do |
|
|
166
|
+
|---|---|
|
|
167
|
+
| A small part: an icon, control, handle or thumbnail | Size it at 96 px or less, plainly: `width: 64px`, `width: var(--control-height-lg)` |
|
|
168
|
+
| A panel, column or anything that can give way | `width: min(100%, 280px)`, `flex: 1 1 280px` or a `minmax(0, 280px)` track |
|
|
169
|
+
| A part that truly stays that wide | A token listed in `layout.widthTokens` in `ds.config.json`, used plainly: `width: var(--side-pane-width)` |
|
|
170
|
+
| An overlay: dialog, menu, popover, tooltip | Its owner in `layout.fixedWidthUnits`, by unit id or file glob |
|
|
171
|
+
|
|
172
|
+
These do not fix it:
|
|
173
|
+
|
|
174
|
+
- Another unit. `32.5ch`, `20em` and `20rem` are as fixed as `280px`, and depend on the font too.
|
|
175
|
+
- `max(100%, 280px)`, `clamp(200px, 50%, 400px)`, `calc(100% + 200px)`: they cannot shrink below
|
|
176
|
+
their fixed part.
|
|
177
|
+
- `min(100%, 64px)` around a small part: `layout-width-noop` asks for the plain size.
|
|
178
|
+
- A token name. `--control-*`, `--side-pane-*` and every other name are read for their value.
|
|
179
|
+
|
|
180
|
+
`ads check` lists every declared fixed width for review (`layout-declared-width`). There is no
|
|
181
|
+
per-declaration exception.
|
|
171
182
|
|
|
172
183
|
`layout-overflow` (`ads audit`) renders every UI scenario at 390, 768 and 1280 px and fails on
|
|
173
184
|
horizontal page overflow, elements past the viewport and clipped content. `overflow-x: auto`
|
|
174
|
-
scrollers and `text-overflow: ellipsis` are exempt.
|
|
185
|
+
scrollers and `text-overflow: ellipsis` are exempt. It also renders components and patterns in a
|
|
186
|
+
240 px container, and fails when a set width above 96 px overflows it. Make that width fluid, or
|
|
187
|
+
scroll it. Only an overlay's owner, listed in `layout.fixedWidthUnits`, stays out of this render.
|
|
175
188
|
|
|
176
189
|
## Color roles and states
|
|
177
190
|
|
|
@@ -43,7 +43,7 @@ implicitly requiring them at acceptance.
|
|
|
43
43
|
owners while project scripts and core gates retain full scope.
|
|
44
44
|
- Both policies run the axe-core audit of every rendered UI scenario in every brand
|
|
45
45
|
and theme (`browser-accessibility-audit`); `browserAudit: false` turns it off for
|
|
46
|
-
that policy. Its `a11y-axe`, `a11y-non-text-contrast` and `layout-overflow` findings are errors that fail the policy, and an audit
|
|
46
|
+
that policy. An `a11y-incomplete` info item means axe could not decide that rule on those elements: check it by hand, using the reason it names (`bgGradient` is text over a gradient). Its `a11y-axe`, `a11y-non-text-contrast` and `layout-overflow` findings are errors that fail the policy, and an audit
|
|
47
47
|
that cannot run (no project Playwright or browser) fails it with a `browser-audit`
|
|
48
48
|
error naming what to install. Under the acceptance policy, draft
|
|
49
49
|
acceptance and guarded patches/transactions audit the candidate's affected UI
|
|
@@ -327,12 +327,14 @@ brand artwork, icon outputs or glyphs.
|
|
|
327
327
|
|
|
328
328
|
## Layout widths
|
|
329
329
|
|
|
330
|
-
Widths are fluid on the grid
|
|
331
|
-
|
|
332
|
-
|
|
330
|
+
Widths are fluid on the grid. Span columns with a `--grid-span-N` token in a container query, or
|
|
331
|
+
use `%` or `fr`. `layout-fixed-width` fails a width that cannot shrink below 96 px, in any unit.
|
|
332
|
+
Small parts use plain sizes up to 96 px. A panel takes `width: min(100%, 280px)`. A part that truly
|
|
333
|
+
stays wider takes a token listed in `layout.widthTokens`, and an overlay's owner goes in
|
|
334
|
+
`layout.fixedWidthUnits`. `max-width` is not read. Atomic CSS
|
|
333
335
|
does not keep rule order: give queries on one property exclusive ranges, such as
|
|
334
336
|
`(min-width: 768px) and (max-width: 1023.98px)`. `ads audit` fails horizontal overflow at 390,
|
|
335
|
-
768 and 1280 px (`layout-overflow`). See the Grid section of
|
|
337
|
+
768 and 1280 px, and reports a set width above 96 px that overflows a 240 px container as a review item (`layout-overflow-narrow`). See the Grid section of
|
|
336
338
|
[design-data.md](references/design-data.md) (`ads://guides/tokens`).
|
|
337
339
|
|
|
338
340
|
## Web performance
|
|
@@ -134,7 +134,7 @@ container width (768 and 1024 px) with container queries, since CSS variables ca
|
|
|
134
134
|
breakpoints. The showcase's grid overlay draws these tokens over every preview at the same
|
|
135
135
|
widths; a project without them shows no overlay. Align text to a cell's edge, not its gutter.
|
|
136
136
|
|
|
137
|
-
### Widths are fluid on the grid
|
|
137
|
+
### Widths are fluid on the grid
|
|
138
138
|
|
|
139
139
|
`--grid-span-1` to `--grid-span-16` are widths of N of 16 columns, fluid in their container.
|
|
140
140
|
Set one inside a container query, under a `Grid` or another `container-type: inline-size`
|
|
@@ -155,23 +155,36 @@ Atomic CSS does not keep rule order, so two queries on one property need exclusi
|
|
|
155
155
|
Use `%` or `fr` for a share of the parent and a `ch` measure for running text
|
|
156
156
|
(`max-inline-size: 65ch`).
|
|
157
157
|
|
|
158
|
-
`layout-fixed-width` is an error for `width`, `min-width`,
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
158
|
+
`layout-fixed-width` is an error for `width`, `min-width`, the logical inline sizes, `flex-basis`,
|
|
159
|
+
`flex`'s basis and `grid-template-columns` tracks that cannot shrink below 96 px, in any unit, raw,
|
|
160
|
+
through a token or by arithmetic. `max-width` and `max-inline-size` are not read: a maximum cannot
|
|
161
|
+
force overflow, so cap with them freely.
|
|
162
162
|
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
A
|
|
169
|
-
|
|
170
|
-
|
|
163
|
+
When it fires, pick the fix by what the element is:
|
|
164
|
+
|
|
165
|
+
| The element | Do |
|
|
166
|
+
|---|---|
|
|
167
|
+
| A small part: an icon, control, handle or thumbnail | Size it at 96 px or less, plainly: `width: 64px`, `width: var(--control-height-lg)` |
|
|
168
|
+
| A panel, column or anything that can give way | `width: min(100%, 280px)`, `flex: 1 1 280px` or a `minmax(0, 280px)` track |
|
|
169
|
+
| A part that truly stays that wide | A token listed in `layout.widthTokens` in `ds.config.json`, used plainly: `width: var(--side-pane-width)` |
|
|
170
|
+
| An overlay: dialog, menu, popover, tooltip | Its owner in `layout.fixedWidthUnits`, by unit id or file glob |
|
|
171
|
+
|
|
172
|
+
These do not fix it:
|
|
173
|
+
|
|
174
|
+
- Another unit. `32.5ch`, `20em` and `20rem` are as fixed as `280px`, and depend on the font too.
|
|
175
|
+
- `max(100%, 280px)`, `clamp(200px, 50%, 400px)`, `calc(100% + 200px)`: they cannot shrink below
|
|
176
|
+
their fixed part.
|
|
177
|
+
- `min(100%, 64px)` around a small part: `layout-width-noop` asks for the plain size.
|
|
178
|
+
- A token name. `--control-*`, `--side-pane-*` and every other name are read for their value.
|
|
179
|
+
|
|
180
|
+
`ads check` lists every declared fixed width for review (`layout-declared-width`). There is no
|
|
181
|
+
per-declaration exception.
|
|
171
182
|
|
|
172
183
|
`layout-overflow` (`ads audit`) renders every UI scenario at 390, 768 and 1280 px and fails on
|
|
173
184
|
horizontal page overflow, elements past the viewport and clipped content. `overflow-x: auto`
|
|
174
|
-
scrollers and `text-overflow: ellipsis` are exempt.
|
|
185
|
+
scrollers and `text-overflow: ellipsis` are exempt. It also renders components and patterns in a
|
|
186
|
+
240 px container, and fails when a set width above 96 px overflows it. Make that width fluid, or
|
|
187
|
+
scroll it. Only an overlay's owner, listed in `layout.fixedWidthUnits`, stays out of this render.
|
|
175
188
|
|
|
176
189
|
## Color roles and states
|
|
177
190
|
|
|
@@ -43,7 +43,7 @@ implicitly requiring them at acceptance.
|
|
|
43
43
|
owners while project scripts and core gates retain full scope.
|
|
44
44
|
- Both policies run the axe-core audit of every rendered UI scenario in every brand
|
|
45
45
|
and theme (`browser-accessibility-audit`); `browserAudit: false` turns it off for
|
|
46
|
-
that policy. Its `a11y-axe`, `a11y-non-text-contrast` and `layout-overflow` findings are errors that fail the policy, and an audit
|
|
46
|
+
that policy. An `a11y-incomplete` info item means axe could not decide that rule on those elements: check it by hand, using the reason it names (`bgGradient` is text over a gradient). Its `a11y-axe`, `a11y-non-text-contrast` and `layout-overflow` findings are errors that fail the policy, and an audit
|
|
47
47
|
that cannot run (no project Playwright or browser) fails it with a `browser-audit`
|
|
48
48
|
error naming what to install. Under the acceptance policy, draft
|
|
49
49
|
acceptance and guarded patches/transactions audit the candidate's affected UI
|
|
@@ -134,7 +134,7 @@ container width (768 and 1024 px) with container queries, since CSS variables ca
|
|
|
134
134
|
breakpoints. The showcase's grid overlay draws these tokens over every preview at the same
|
|
135
135
|
widths; a project without them shows no overlay. Align text to a cell's edge, not its gutter.
|
|
136
136
|
|
|
137
|
-
### Widths are fluid on the grid
|
|
137
|
+
### Widths are fluid on the grid
|
|
138
138
|
|
|
139
139
|
`--grid-span-1` to `--grid-span-16` are widths of N of 16 columns, fluid in their container.
|
|
140
140
|
Set one inside a container query, under a `Grid` or another `container-type: inline-size`
|
|
@@ -155,23 +155,36 @@ Atomic CSS does not keep rule order, so two queries on one property need exclusi
|
|
|
155
155
|
Use `%` or `fr` for a share of the parent and a `ch` measure for running text
|
|
156
156
|
(`max-inline-size: 65ch`).
|
|
157
157
|
|
|
158
|
-
`layout-fixed-width` is an error for `width`, `min-width`,
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
158
|
+
`layout-fixed-width` is an error for `width`, `min-width`, the logical inline sizes, `flex-basis`,
|
|
159
|
+
`flex`'s basis and `grid-template-columns` tracks that cannot shrink below 96 px, in any unit, raw,
|
|
160
|
+
through a token or by arithmetic. `max-width` and `max-inline-size` are not read: a maximum cannot
|
|
161
|
+
force overflow, so cap with them freely.
|
|
162
162
|
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
A
|
|
169
|
-
|
|
170
|
-
|
|
163
|
+
When it fires, pick the fix by what the element is:
|
|
164
|
+
|
|
165
|
+
| The element | Do |
|
|
166
|
+
|---|---|
|
|
167
|
+
| A small part: an icon, control, handle or thumbnail | Size it at 96 px or less, plainly: `width: 64px`, `width: var(--control-height-lg)` |
|
|
168
|
+
| A panel, column or anything that can give way | `width: min(100%, 280px)`, `flex: 1 1 280px` or a `minmax(0, 280px)` track |
|
|
169
|
+
| A part that truly stays that wide | A token listed in `layout.widthTokens` in `ds.config.json`, used plainly: `width: var(--side-pane-width)` |
|
|
170
|
+
| An overlay: dialog, menu, popover, tooltip | Its owner in `layout.fixedWidthUnits`, by unit id or file glob |
|
|
171
|
+
|
|
172
|
+
These do not fix it:
|
|
173
|
+
|
|
174
|
+
- Another unit. `32.5ch`, `20em` and `20rem` are as fixed as `280px`, and depend on the font too.
|
|
175
|
+
- `max(100%, 280px)`, `clamp(200px, 50%, 400px)`, `calc(100% + 200px)`: they cannot shrink below
|
|
176
|
+
their fixed part.
|
|
177
|
+
- `min(100%, 64px)` around a small part: `layout-width-noop` asks for the plain size.
|
|
178
|
+
- A token name. `--control-*`, `--side-pane-*` and every other name are read for their value.
|
|
179
|
+
|
|
180
|
+
`ads check` lists every declared fixed width for review (`layout-declared-width`). There is no
|
|
181
|
+
per-declaration exception.
|
|
171
182
|
|
|
172
183
|
`layout-overflow` (`ads audit`) renders every UI scenario at 390, 768 and 1280 px and fails on
|
|
173
184
|
horizontal page overflow, elements past the viewport and clipped content. `overflow-x: auto`
|
|
174
|
-
scrollers and `text-overflow: ellipsis` are exempt.
|
|
185
|
+
scrollers and `text-overflow: ellipsis` are exempt. It also renders components and patterns in a
|
|
186
|
+
240 px container, and fails when a set width above 96 px overflows it. Make that width fluid, or
|
|
187
|
+
scroll it. Only an overlay's owner, listed in `layout.fixedWidthUnits`, stays out of this render.
|
|
175
188
|
|
|
176
189
|
## Color roles and states
|
|
177
190
|
|
|
@@ -43,7 +43,7 @@ implicitly requiring them at acceptance.
|
|
|
43
43
|
owners while project scripts and core gates retain full scope.
|
|
44
44
|
- Both policies run the axe-core audit of every rendered UI scenario in every brand
|
|
45
45
|
and theme (`browser-accessibility-audit`); `browserAudit: false` turns it off for
|
|
46
|
-
that policy. Its `a11y-axe`, `a11y-non-text-contrast` and `layout-overflow` findings are errors that fail the policy, and an audit
|
|
46
|
+
that policy. An `a11y-incomplete` info item means axe could not decide that rule on those elements: check it by hand, using the reason it names (`bgGradient` is text over a gradient). Its `a11y-axe`, `a11y-non-text-contrast` and `layout-overflow` findings are errors that fail the policy, and an audit
|
|
47
47
|
that cannot run (no project Playwright or browser) fails it with a `browser-audit`
|
|
48
48
|
error naming what to install. Under the acceptance policy, draft
|
|
49
49
|
acceptance and guarded patches/transactions audit the candidate's affected UI
|