@autoguru/overdrive 4.58.0 → 4.60.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/dist/components/Alert/Alert.js +4 -4
- package/dist/components/AutoSuggest/AutoSuggest.css.d.ts.map +1 -1
- package/dist/components/AutoSuggest/AutoSuggest.css.js +9 -1
- package/dist/components/AutoSuggest/AutoSuggest.js +4 -4
- package/dist/components/Badge/Badge.css.js +1 -1
- package/dist/components/Box/useBox/useBox.d.ts +3 -3
- package/dist/components/BulletList/Bullet.css.js +3 -3
- package/dist/components/BulletText/BulletText.css.d.ts.map +1 -1
- package/dist/components/BulletText/BulletText.css.js +4 -1
- package/dist/components/Button/Button.css.js +7 -7
- package/dist/components/Calendar/Calendar.css.js +16 -16
- package/dist/components/CheckBox/CheckBox.css.js +2 -2
- package/dist/components/ColourInput/ColourInput.css.js +2 -2
- package/dist/components/DataTable/DataTable.css.d.ts.map +1 -1
- package/dist/components/DataTable/DataTable.css.js +2 -1
- package/dist/components/DateInput/DateInput.js +1 -1
- package/dist/components/DateTimeField/DateTimeField.css.js +2 -2
- package/dist/components/EditableText/EditableText.css.js +1 -1
- package/dist/components/EditableText/EditableText.d.ts.map +1 -1
- package/dist/components/EditableText/EditableText.js +3 -1
- package/dist/components/Flex/flex.d.ts +23 -23
- package/dist/components/Flyout/Flyout.js +2 -2
- package/dist/components/Heading/Heading.js +1 -1
- package/dist/components/LinearProgressIndicator/LinearProgressIndicator.js +2 -2
- package/dist/components/MarkdownRenderer/components/MarkdownHeading.js +3 -3
- package/dist/components/Meta/Meta.css.d.ts.map +1 -1
- package/dist/components/Meta/Meta.css.js +2 -1
- package/dist/components/Modal/Modal.d.ts.map +1 -1
- package/dist/components/Modal/Modal.js +3 -1
- package/dist/components/OptionGrid/OptionGrid.css.js +20 -20
- package/dist/components/OptionList/OptionList.css.js +11 -11
- package/dist/components/OrderedList/OrderedList.js +1 -1
- package/dist/components/Pagination/Bubble.js +3 -3
- package/dist/components/Pagination/Pagination.css.js +2 -2
- package/dist/components/Popover/Popover.css.js +3 -3
- package/dist/components/ProgressBar/ProgressBar.js +2 -2
- package/dist/components/ProgressBarGroup/ProgressBarGroup.js +2 -2
- package/dist/components/ProgressSpinner/ProgressSpinner.css.d.ts +1 -1
- package/dist/components/ProgressSpinner/ProgressSpinner.css.js +2 -2
- package/dist/components/Radio/Radio.css.js +2 -2
- package/dist/components/ScrollPane/ScrollPane.css.js +3 -3
- package/dist/components/SearchBar/SearchBar.css.js +6 -6
- package/dist/components/SelectInput/SelectInput.css.js +1 -1
- package/dist/components/Slider/Slider.css.js +6 -6
- package/dist/components/SliderProgress/ProgressStep.d.ts.map +1 -1
- package/dist/components/SliderProgress/ProgressStep.js +6 -2
- package/dist/components/SliderProgress/SliderProgress.d.ts.map +1 -1
- package/dist/components/SliderProgress/SliderProgress.js +3 -1
- package/dist/components/Stack/Stack.css.d.ts.map +1 -1
- package/dist/components/Stack/Stack.css.js +1 -0
- package/dist/components/StandardModal/StandardModal.css.js +4 -4
- package/dist/components/StandardModal/StandardModal.js +4 -4
- package/dist/components/Stepper/Stepper.js +3 -3
- package/dist/components/Switch/Switch.css.js +2 -2
- package/dist/components/Table/TableCell.css.js +2 -2
- package/dist/components/Table/TableCell.js +1 -1
- package/dist/components/Table/TableHeadCell.css.js +2 -2
- package/dist/components/Tabs/Tab.css.js +6 -6
- package/dist/components/Tabs/Tab.js +2 -2
- package/dist/components/Tabs/TabList.css.js +1 -1
- package/dist/components/Text/Text.d.ts.map +1 -1
- package/dist/components/Text/Text.js +3 -3
- package/dist/components/TextLink/TextLink.js +1 -1
- package/dist/components/Tooltip/useTooltip/useTooltip.js +2 -2
- package/dist/components/private/CheckableBase/CheckableBase.css.js +2 -2
- package/dist/components/private/InputBase/HintText.js +1 -1
- package/dist/components/private/InputBase/InputState.css.js +16 -16
- package/dist/components/private/InputBase/NotchedBase.css.js +2 -2
- package/dist/components/private/InputBase/withEnhancedInput.css.js +4 -4
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/styles/focusOutline.css.d.ts.map +1 -1
- package/dist/styles/focusOutline.css.js +2 -0
- package/dist/styles/index.d.ts +1 -1
- package/dist/styles/index.d.ts.map +1 -1
- package/dist/styles/index.js +1 -1
- package/dist/styles/intentColorset.css.d.ts +3 -3
- package/dist/styles/intentColorset.css.d.ts.map +1 -1
- package/dist/styles/intentColorset.css.js +8 -2
- package/dist/styles/sprinkles.css.d.ts +290 -275
- package/dist/styles/sprinkles.css.d.ts.map +1 -1
- package/dist/styles/sprinkles.css.js +87 -10
- package/dist/styles/sprinkles.spec.d.ts +2 -0
- package/dist/styles/sprinkles.spec.d.ts.map +1 -0
- package/dist/styles/sprinkles.spec.js +8 -0
- package/dist/styles/typography.css.d.ts +1 -1
- package/dist/styles/typography.d.ts +44 -3
- package/dist/styles/typography.d.ts.map +1 -1
- package/dist/styles/typography.js +74 -17
- package/dist/themes/base/colours.d.ts +0 -22
- package/dist/themes/base/colours.d.ts.map +1 -1
- package/dist/themes/base/colours.js +6 -17
- package/dist/themes/base/contrastGuide.d.ts +31 -0
- package/dist/themes/base/contrastGuide.d.ts.map +1 -0
- package/dist/themes/base/contrastGuide.js +43 -0
- package/dist/themes/base/contrastGuide.spec.d.ts +2 -0
- package/dist/themes/base/contrastGuide.spec.d.ts.map +1 -0
- package/dist/themes/base/contrastGuide.spec.js +51 -0
- package/dist/themes/base/index.d.ts +258 -86
- package/dist/themes/base/index.d.ts.map +1 -1
- package/dist/themes/base/space.spec.d.ts +2 -0
- package/dist/themes/base/space.spec.d.ts.map +1 -0
- package/dist/themes/base/space.spec.js +41 -0
- package/dist/themes/base/tokens.d.ts +163 -66
- package/dist/themes/base/tokens.d.ts.map +1 -1
- package/dist/themes/base/tokens.js +210 -9
- package/dist/themes/flat_red/index.d.ts +264 -95
- package/dist/themes/flat_red/index.d.ts.map +1 -1
- package/dist/themes/flat_red/tokens.d.ts +158 -75
- package/dist/themes/flat_red/tokens.d.ts.map +1 -1
- package/dist/themes/flat_red/tokens.js +8 -13
- package/dist/themes/index.d.ts +259 -86
- package/dist/themes/index.d.ts.map +1 -1
- package/dist/themes/index.js +1 -0
- package/dist/themes/makeTheme.d.ts +106 -20
- package/dist/themes/makeTheme.d.ts.map +1 -1
- package/dist/themes/neutral/index.d.ts +258 -107
- package/dist/themes/neutral/index.d.ts.map +1 -1
- package/dist/themes/neutral/tokens.d.ts +153 -88
- package/dist/themes/neutral/tokens.d.ts.map +1 -1
- package/dist/themes/neutral/tokens.js +12 -33
- package/dist/themes/theme.css.d.ts +106 -31
- package/dist/themes/theme.css.d.ts.map +1 -1
- package/dist/themes/theme.css.js +130 -12
- package/package.json +16 -16
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sprinkles.css.d.ts","sourceRoot":"","sources":["../../lib/styles/sprinkles.css.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"sprinkles.css.d.ts","sourceRoot":"","sources":["../../lib/styles/sprinkles.css.ts"],"names":[],"mappings":"AAiDA;;;;;GAKG;AACH,eAAO,MAAM,mCAAmC;IAC/C;;;;;OAKG;;CAEH,CAAC;AAuMF,eAAO,MAAM,oBAAoB;;;;;;;;;;;CAOhC,CAAC;AA2IF,eAAO,MAAM,SAAS;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAAwD,CAAC;AAC/E,MAAM,MAAM,SAAS,GAAG,UAAU,CAAC,OAAO,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC;AAExD;;;GAGG;AACH,MAAM,MAAM,sBAAsB,GAAG,IAAI,CACxC,SAAS,EACP,kBAAkB,GAClB,cAAc,GACd,oBAAoB,GACpB,kBAAkB,GAClB,mBAAmB,GACnB,iBAAiB,GACjB,QAAQ,CACV,CAAC;AAIF,eAAO,MAAM,WAAW;;;;;;;;;;CAcvB,CAAC"}
|
|
@@ -7,7 +7,7 @@ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t =
|
|
|
7
7
|
/* eslint-disable sonarjs/no-duplicate-string */
|
|
8
8
|
import { createSprinkles, defineProperties } from '@vanilla-extract/sprinkles';
|
|
9
9
|
import { mapValues } from 'es-toolkit';
|
|
10
|
-
import { breakpoints } from "../themes/makeTheme.js";
|
|
10
|
+
import { breakpoints, buildColourGamut } from "../themes/makeTheme.js";
|
|
11
11
|
import { overdriveTokens as tokens } from "../themes/theme.css.js";
|
|
12
12
|
import { arrayFromKeys } from "../utils/object.js";
|
|
13
13
|
import { cssLayerStyleprops } from "./layers.css.js";
|
|
@@ -45,7 +45,23 @@ const intentBackgroundColoursStandard = mapValues(tokens.colours.intent, ({
|
|
|
45
45
|
const intentBorderColours = mapValues(tokens.colours.intent, ({
|
|
46
46
|
border
|
|
47
47
|
}) => border);
|
|
48
|
-
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* Test-only: deprecated colour-value aliases retained until the DS-2026 major.
|
|
51
|
+
* Exported so the R12 guard spec can assert the alias resolves to its real
|
|
52
|
+
* token value; spread into `backgroundColours` so the alias and the tested
|
|
53
|
+
* value are the same object.
|
|
54
|
+
*/
|
|
55
|
+
export const __deprecatedBackgroundColourAliases = {
|
|
56
|
+
/**
|
|
57
|
+
* @deprecated Use `gray900`. `black900` is retained only as an alias of
|
|
58
|
+
* `gray900` (#212338 — the DS-2026 "Tarmac Black") so existing
|
|
59
|
+
* `backgroundColour="black900"` usages keep resolving after the black ramp
|
|
60
|
+
* was removed. Scheduled for removal in the DS-2026 major (W4-P4).
|
|
61
|
+
*/
|
|
62
|
+
black900: tokens.colours.gamut.gray900
|
|
63
|
+
};
|
|
64
|
+
const backgroundColours = _objectSpread(_objectSpread(_objectSpread(_objectSpread({}, intentBackgroundColoursStandard), tokens.colours.gamut), __deprecatedBackgroundColourAliases), {}, {
|
|
49
65
|
transparent: 'transparent'
|
|
50
66
|
});
|
|
51
67
|
const borderColors = _objectSpread({
|
|
@@ -54,6 +70,60 @@ const borderColors = _objectSpread({
|
|
|
54
70
|
disabled: tokens.color.interactive.borderDisabled
|
|
55
71
|
}, tokens.color.surface);
|
|
56
72
|
const borderColours = _objectSpread(_objectSpread({}, tokens.border.colours), intentBorderColours);
|
|
73
|
+
|
|
74
|
+
// --- SEMANTIC COLOUR PARITY (C-P1) ---
|
|
75
|
+
// Flat semantic ramp: every legacy gamut key (gray900, green300, …) gets a
|
|
76
|
+
// semantic equivalent at the IDENTICAL base value (color.gamut === colours.gamut).
|
|
77
|
+
const semanticGamut = buildColourGamut({
|
|
78
|
+
gray: tokens.color.gamut.gray,
|
|
79
|
+
green: tokens.color.gamut.green,
|
|
80
|
+
blue: tokens.color.gamut.blue,
|
|
81
|
+
yellow: tokens.color.gamut.yellow,
|
|
82
|
+
red: tokens.color.gamut.red
|
|
83
|
+
});
|
|
84
|
+
|
|
85
|
+
// `color` (text/foreground) semantic value space
|
|
86
|
+
const semanticColor = _objectSpread(_objectSpread(_objectSpread(_objectSpread({}, tokens.color.content), tokens.color.foreground), {}, {
|
|
87
|
+
// primary, secondary, reverse, tertiaryInactive, tertiaryInactiveLight (W1-P1)
|
|
88
|
+
infoText: tokens.color.info.text,
|
|
89
|
+
infoForeground: tokens.color.info.foreground,
|
|
90
|
+
successText: tokens.color.success.text,
|
|
91
|
+
successForeground: tokens.color.success.foreground,
|
|
92
|
+
warningText: tokens.color.warning.text,
|
|
93
|
+
warningForeground: tokens.color.warning.foreground,
|
|
94
|
+
alertText: tokens.color.alert.text,
|
|
95
|
+
alertForeground: tokens.color.alert.foreground
|
|
96
|
+
}, semanticGamut), {}, {
|
|
97
|
+
// gray900 … red100
|
|
98
|
+
white: tokens.color.gamut.white,
|
|
99
|
+
unset: 'unset'
|
|
100
|
+
});
|
|
101
|
+
|
|
102
|
+
// `backgroundColor` semantic value space
|
|
103
|
+
const semanticBackgroundColor = _objectSpread(_objectSpread(_objectSpread(_objectSpread({}, tokens.color.surface), tokens.color.background), {}, {
|
|
104
|
+
// default, reverse, inactive, emphasisInactive (W1-P1)
|
|
105
|
+
infoBackground: tokens.color.info.background,
|
|
106
|
+
successBackgroundDark: tokens.color.success.backgroundDark,
|
|
107
|
+
successBackgroundLight: tokens.color.success.backgroundLight,
|
|
108
|
+
warningBackgroundDark: tokens.color.warning.backgroundDark,
|
|
109
|
+
warningBackgroundLight: tokens.color.warning.backgroundLight,
|
|
110
|
+
alertBackground: tokens.color.alert.background
|
|
111
|
+
}, semanticGamut), {}, {
|
|
112
|
+
white: tokens.color.gamut.white,
|
|
113
|
+
transparent: 'transparent'
|
|
114
|
+
});
|
|
115
|
+
|
|
116
|
+
// `border*Color` semantic value space
|
|
117
|
+
const semanticBorderColor = _objectSpread(_objectSpread(_objectSpread(_objectSpread({}, tokens.color.border), {}, {
|
|
118
|
+
default: tokens.color.interactive.border,
|
|
119
|
+
// existing (gray300)
|
|
120
|
+
muted: tokens.color.interactive.borderMuted,
|
|
121
|
+
// existing (gray200)
|
|
122
|
+
disabled: tokens.color.interactive.borderDisabled
|
|
123
|
+
}, tokens.color.surface), semanticGamut), {}, {
|
|
124
|
+
white: tokens.color.gamut.white,
|
|
125
|
+
transparent: 'transparent'
|
|
126
|
+
});
|
|
57
127
|
const colours = _objectSpread(_objectSpread(_objectSpread(_objectSpread({}, tokens.colours.foreground), tokens.typography.colour), intentForegroundColours), {}, {
|
|
58
128
|
unset: 'unset',
|
|
59
129
|
white: tokens.colours.gamut.white
|
|
@@ -90,24 +160,28 @@ const baseProperties = defineProperties({
|
|
|
90
160
|
'@layer': cssLayerStyleprops,
|
|
91
161
|
properties: {
|
|
92
162
|
// Borders
|
|
93
|
-
borderBottomColor:
|
|
94
|
-
borderLeftColor:
|
|
95
|
-
borderRightColor:
|
|
96
|
-
borderTopColor:
|
|
163
|
+
borderBottomColor: semanticBorderColor,
|
|
164
|
+
borderLeftColor: semanticBorderColor,
|
|
165
|
+
borderRightColor: semanticBorderColor,
|
|
166
|
+
borderTopColor: semanticBorderColor,
|
|
167
|
+
/** @deprecated Use borderBottomColor — removed in v5 (DS-2026 major). */
|
|
97
168
|
borderBottomColour: mappedBorderBottomColours,
|
|
169
|
+
/** @deprecated Use borderLeftColor — removed in v5 (DS-2026 major). */
|
|
98
170
|
borderLeftColour: mappedBorderLeftColours,
|
|
171
|
+
/** @deprecated Use borderRightColor — removed in v5 (DS-2026 major). */
|
|
99
172
|
borderRightColour: mappedBorderRightColours,
|
|
173
|
+
/** @deprecated Use borderTopColor — removed in v5 (DS-2026 major). */
|
|
100
174
|
borderTopColour: mappedBorderTopColours,
|
|
101
175
|
borderLeftStyle: ['none', 'solid'],
|
|
102
176
|
borderBottomStyle: ['none', 'solid'],
|
|
103
177
|
borderRightStyle: ['none', 'solid'],
|
|
104
178
|
borderTopStyle: ['none', 'solid'],
|
|
105
179
|
// Color
|
|
106
|
-
color:
|
|
180
|
+
color: semanticColor,
|
|
181
|
+
/** @deprecated Use color — removed in v5 (DS-2026 major). */
|
|
107
182
|
colour: mappedColours,
|
|
108
|
-
backgroundColor:
|
|
109
|
-
|
|
110
|
-
}),
|
|
183
|
+
backgroundColor: semanticBackgroundColor,
|
|
184
|
+
/** @deprecated Use backgroundColor — removed in v5 (DS-2026 major). */
|
|
111
185
|
backgroundColour: mappedBackgroundColours,
|
|
112
186
|
opacity: [0, '1', '0'],
|
|
113
187
|
// Typography
|
|
@@ -132,8 +206,11 @@ const baseProperties = defineProperties({
|
|
|
132
206
|
borderColor: ['borderBottomColor', 'borderLeftColor', 'borderRightColor', 'borderTopColor'],
|
|
133
207
|
borderColorX: ['borderLeftColor', 'borderRightColor'],
|
|
134
208
|
borderColorY: ['borderBottomColor', 'borderTopColor'],
|
|
209
|
+
/** @deprecated Use borderColor — removed in v5 (DS-2026 major). */
|
|
135
210
|
borderColour: ['borderBottomColour', 'borderLeftColour', 'borderRightColour', 'borderTopColour'],
|
|
211
|
+
/** @deprecated Use borderColorX — removed in v5 (DS-2026 major). */
|
|
136
212
|
borderColourX: ['borderLeftColour', 'borderRightColour'],
|
|
213
|
+
/** @deprecated Use borderColorY — removed in v5 (DS-2026 major). */
|
|
137
214
|
borderColourY: ['borderBottomColour', 'borderTopColour'],
|
|
138
215
|
borderStyle: ['borderBottomStyle', 'borderLeftStyle', 'borderRightStyle', 'borderTopStyle'],
|
|
139
216
|
borderStyleBottom: ['borderBottomStyle'],
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sprinkles.spec.d.ts","sourceRoot":"","sources":["../../lib/styles/sprinkles.spec.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { describe, expect, it } from 'vitest';
|
|
2
|
+
import { overdriveTokens } from "../themes/theme.css.js";
|
|
3
|
+
import { __deprecatedBackgroundColourAliases } from "./sprinkles.css.js";
|
|
4
|
+
describe('deprecated backgroundColour aliases (R12 guard)', () => {
|
|
5
|
+
it('black900 resolves to the gray900 token value', () => {
|
|
6
|
+
expect(__deprecatedBackgroundColourAliases.black900).toBe(overdriveTokens.colours.gamut.gray900);
|
|
7
|
+
});
|
|
8
|
+
});
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export declare const sprinklesLegacyText: ((props: {
|
|
2
|
-
color?: "link" | "white" | "success" | "danger" | "warning" | "
|
|
2
|
+
color?: "link" | "white" | "success" | "danger" | "warning" | "primary" | "secondary" | "light" | "neutral" | "brand" | "shine" | "information" | "dark" | "muted" | "unset" | undefined;
|
|
3
3
|
}) => string) & {
|
|
4
4
|
properties: Set<"color">;
|
|
5
5
|
};
|
|
@@ -8,6 +8,47 @@ export declare const DEFAULT_TEXT_SIZE: Sprinkles["text"];
|
|
|
8
8
|
export declare const DEFAULT_TEXT_WEIGHT: Sprinkles["fontWeight"];
|
|
9
9
|
export type TextTags = (typeof TEXT_TAGS)[number];
|
|
10
10
|
export type HeadingTags = (typeof HEADING_TAGS)[number];
|
|
11
|
+
export declare const TEXT_STYLES: readonly ["h1", "h2", "h3", "h4", "p1", "p2", "p3", "p4"];
|
|
12
|
+
export type NamedTextStyle = (typeof TEXT_STYLES)[number];
|
|
13
|
+
/**
|
|
14
|
+
* Design System 2026 named text styles (opt-in). Each has its own size
|
|
15
|
+
* token — headings use a 1.25 line-height ratio, paragraphs 1.4 — and a
|
|
16
|
+
* default weight applied when no `weight` or `strong` is set.
|
|
17
|
+
*/
|
|
18
|
+
export declare const namedTextStyleMap: {
|
|
19
|
+
readonly h1: {
|
|
20
|
+
readonly size: "h1";
|
|
21
|
+
readonly weight: "bold";
|
|
22
|
+
};
|
|
23
|
+
readonly h2: {
|
|
24
|
+
readonly size: "h2";
|
|
25
|
+
readonly weight: "bold";
|
|
26
|
+
};
|
|
27
|
+
readonly h3: {
|
|
28
|
+
readonly size: "h3";
|
|
29
|
+
readonly weight: "bold";
|
|
30
|
+
};
|
|
31
|
+
readonly h4: {
|
|
32
|
+
readonly size: "h4";
|
|
33
|
+
readonly weight: "bold";
|
|
34
|
+
};
|
|
35
|
+
readonly p1: {
|
|
36
|
+
readonly size: "p1";
|
|
37
|
+
readonly weight: "normal";
|
|
38
|
+
};
|
|
39
|
+
readonly p2: {
|
|
40
|
+
readonly size: "p2";
|
|
41
|
+
readonly weight: "normal";
|
|
42
|
+
};
|
|
43
|
+
readonly p3: {
|
|
44
|
+
readonly size: "p3";
|
|
45
|
+
readonly weight: "normal";
|
|
46
|
+
};
|
|
47
|
+
readonly p4: {
|
|
48
|
+
readonly size: "p4";
|
|
49
|
+
readonly weight: "normal";
|
|
50
|
+
};
|
|
51
|
+
};
|
|
11
52
|
export interface TypographyProps {
|
|
12
53
|
/** Aligns text horizontally */
|
|
13
54
|
align?: Sprinkles['textAlign'];
|
|
@@ -19,8 +60,8 @@ export interface TypographyProps {
|
|
|
19
60
|
colour?: LegacyTextColours;
|
|
20
61
|
/** @deprecated prefer `wrap` prop as it supports all wrapping values */
|
|
21
62
|
noWrap?: boolean;
|
|
22
|
-
/** Font size of the text */
|
|
23
|
-
size?: Sprinkles['text'];
|
|
63
|
+
/** Font size of the text, a size scale value or a named text style (`h1`-`h4`, `p1`-`p4`) */
|
|
64
|
+
size?: Sprinkles['text'] | NamedTextStyle;
|
|
24
65
|
/** Bold font weight */
|
|
25
66
|
strong?: boolean;
|
|
26
67
|
/** Applies text capitalisation style */
|
|
@@ -35,7 +76,7 @@ export interface TypographyProps {
|
|
|
35
76
|
/**
|
|
36
77
|
* Applies typography-related styling including font size and weight, has opinionated defaults.
|
|
37
78
|
*/
|
|
38
|
-
export declare const typography: ({ align: textAlign, breakWord, color, colour, noWrap, size
|
|
79
|
+
export declare const typography: ({ align: textAlign, breakWord, color, colour, noWrap, size, strong, transform: textTransform, weight, wrap, wordBreak, }: TypographyProps) => string;
|
|
39
80
|
export interface TextStylesProps extends TypographyProps {
|
|
40
81
|
as?: TextTags | HeadingTags;
|
|
41
82
|
className?: ClassName;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"typography.d.ts","sourceRoot":"","sources":["../../lib/styles/typography.ts"],"names":[],"mappings":"AAAA,OAAa,EAAE,KAAK,UAAU,IAAI,SAAS,EAAE,MAAM,MAAM,CAAC;AAG1D,OAAO,EAAa,KAAK,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC5D,OAAO,EAEN,KAAK,iBAAiB,
|
|
1
|
+
{"version":3,"file":"typography.d.ts","sourceRoot":"","sources":["../../lib/styles/typography.ts"],"names":[],"mappings":"AAAA,OAAa,EAAE,KAAK,UAAU,IAAI,SAAS,EAAE,MAAM,MAAM,CAAC;AAG1D,OAAO,EAAa,KAAK,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC5D,OAAO,EAEN,KAAK,iBAAiB,EAGtB,MAAM,kBAAkB,CAAC;AAE1B,eAAO,MAAM,SAAS,iCAAkC,CAAC;AACzD,eAAO,MAAM,YAAY,+CAAgD,CAAC;AAC1E,eAAO,MAAM,mBAAmB,EAAgB,iBAAiB,CAAC;AAClE,eAAO,MAAM,iBAAiB,EAAU,SAAS,CAAC,MAAM,CAAC,CAAC;AAC1D,eAAO,MAAM,mBAAmB,EAAe,SAAS,CAAC,YAAY,CAAC,CAAC;AAEvE,MAAM,MAAM,QAAQ,GAAG,CAAC,OAAO,SAAS,CAAC,CAAC,MAAM,CAAC,CAAC;AAClD,MAAM,MAAM,WAAW,GAAG,CAAC,OAAO,YAAY,CAAC,CAAC,MAAM,CAAC,CAAC;AAExD,eAAO,MAAM,WAAW,2DASd,CAAC;AACX,MAAM,MAAM,cAAc,GAAG,CAAC,OAAO,WAAW,CAAC,CAAC,MAAM,CAAC,CAAC;AAE1D;;;;GAIG;AACH,eAAO,MAAM,iBAAiB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAe7B,CAAC;AAkBF,MAAM,WAAW,eAAe;IAC/B,+BAA+B;IAC/B,KAAK,CAAC,EAAE,SAAS,CAAC,WAAW,CAAC,CAAC;IAC/B,iCAAiC;IACjC,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,0BAA0B;IAC1B,KAAK,CAAC,EAAE,SAAS,CAAC,OAAO,CAAC,CAAC;IAC3B,sCAAsC;IACtC,MAAM,CAAC,EAAE,iBAAiB,CAAC;IAC3B,wEAAwE;IACxE,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,6FAA6F;IAC7F,IAAI,CAAC,EAAE,SAAS,CAAC,MAAM,CAAC,GAAG,cAAc,CAAC;IAC1C,uBAAuB;IACvB,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,wCAAwC;IACxC,SAAS,CAAC,EAAE,SAAS,CAAC,eAAe,CAAC,CAAC;IACvC,sBAAsB;IACtB,MAAM,CAAC,EAAE,SAAS,CAAC,YAAY,CAAC,CAAC;IACjC,gCAAgC;IAChC,IAAI,CAAC,EAAE,SAAS,CAAC,UAAU,CAAC,CAAC;IAC7B,yCAAyC;IACzC,SAAS,CAAC,EAAE,SAAS,CAAC,WAAW,CAAC,CAAC;CACnC;AAED;;GAEG;AACH,eAAO,MAAM,UAAU,GAAI,0HAYxB,eAAe,WA6BjB,CAAC;AAEF,MAAM,WAAW,eAAgB,SAAQ,eAAe;IACvD,EAAE,CAAC,EAAE,QAAQ,GAAG,WAAW,CAAC;IAC5B,SAAS,CAAC,EAAE,SAAS,CAAC;CACtB;AAED;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAgB,UAAU,CAAC,EAC1B,EAAW,EACX,SAAS,EAET,MAA8C,EAC9C,IAAwD,EACxD,MAA8C,EAE9C,GAAG,KAAK,EACR,EAAE,eAAe,UAMjB"}
|
|
@@ -6,13 +6,63 @@ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t =
|
|
|
6
6
|
import clsx from 'clsx';
|
|
7
7
|
import { resetStyles } from "./elementStyles.js";
|
|
8
8
|
import { sprinkles } from "./sprinkles.css.js";
|
|
9
|
-
import { common,
|
|
9
|
+
import { common,
|
|
10
|
+
// eslint-disable-next-line no-restricted-imports -- RETAINED: the legacy text-colour sprinkle stays until the DS-2026 major (Track C).
|
|
11
|
+
sprinklesLegacyText } from "./typography.css.js";
|
|
10
12
|
export const TEXT_TAGS = ['p', 'span', 'label'];
|
|
11
13
|
export const HEADING_TAGS = ['h1', 'h2', 'h3', 'h4', 'h5', 'h6'];
|
|
12
14
|
export const DEFAULT_TEXT_COLOUR = 'neutral';
|
|
13
15
|
export const DEFAULT_TEXT_SIZE = '4';
|
|
14
16
|
export const DEFAULT_TEXT_WEIGHT = 'normal';
|
|
17
|
+
export const TEXT_STYLES = ['h1', 'h2', 'h3', 'h4', 'p1', 'p2', 'p3', 'p4'];
|
|
18
|
+
/**
|
|
19
|
+
* Design System 2026 named text styles (opt-in). Each has its own size
|
|
20
|
+
* token — headings use a 1.25 line-height ratio, paragraphs 1.4 — and a
|
|
21
|
+
* default weight applied when no `weight` or `strong` is set.
|
|
22
|
+
*/
|
|
23
|
+
export const namedTextStyleMap = {
|
|
24
|
+
h1: {
|
|
25
|
+
size: 'h1',
|
|
26
|
+
weight: 'bold'
|
|
27
|
+
},
|
|
28
|
+
// 40/50
|
|
29
|
+
h2: {
|
|
30
|
+
size: 'h2',
|
|
31
|
+
weight: 'bold'
|
|
32
|
+
},
|
|
33
|
+
// 32/40
|
|
34
|
+
h3: {
|
|
35
|
+
size: 'h3',
|
|
36
|
+
weight: 'bold'
|
|
37
|
+
},
|
|
38
|
+
// 24/30
|
|
39
|
+
h4: {
|
|
40
|
+
size: 'h4',
|
|
41
|
+
weight: 'bold'
|
|
42
|
+
},
|
|
43
|
+
// 20/25
|
|
44
|
+
p1: {
|
|
45
|
+
size: 'p1',
|
|
46
|
+
weight: 'normal'
|
|
47
|
+
},
|
|
48
|
+
// 16/22.4
|
|
49
|
+
p2: {
|
|
50
|
+
size: 'p2',
|
|
51
|
+
weight: 'normal'
|
|
52
|
+
},
|
|
53
|
+
// 14/19.6
|
|
54
|
+
p3: {
|
|
55
|
+
size: 'p3',
|
|
56
|
+
weight: 'normal'
|
|
57
|
+
},
|
|
58
|
+
// 12/16.8
|
|
59
|
+
p4: {
|
|
60
|
+
size: 'p4',
|
|
61
|
+
weight: 'normal'
|
|
62
|
+
} // 10/14 — no semibold per spec
|
|
63
|
+
};
|
|
15
64
|
const isHeadingTag = tag => HEADING_TAGS.includes(tag);
|
|
65
|
+
const isNamedTextStyle = size => typeof size === 'string' && TEXT_STYLES.includes(size);
|
|
16
66
|
const headingSizeMap = {
|
|
17
67
|
h1: '8',
|
|
18
68
|
h2: '7',
|
|
@@ -32,23 +82,30 @@ export const typography = ({
|
|
|
32
82
|
colour,
|
|
33
83
|
// legacy colours
|
|
34
84
|
noWrap = false,
|
|
35
|
-
size
|
|
85
|
+
size,
|
|
36
86
|
strong = false,
|
|
37
87
|
transform: textTransform,
|
|
38
|
-
weight
|
|
88
|
+
weight,
|
|
39
89
|
wrap,
|
|
40
90
|
wordBreak
|
|
41
|
-
}) =>
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
text
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
91
|
+
}) => {
|
|
92
|
+
var _ref, _namedStyle$size, _namedStyle$weight;
|
|
93
|
+
const namedStyle = size && isNamedTextStyle(size) ? namedTextStyleMap[size] : undefined;
|
|
94
|
+
const text = (_ref = (_namedStyle$size = namedStyle === null || namedStyle === void 0 ? void 0 : namedStyle.size) !== null && _namedStyle$size !== void 0 ? _namedStyle$size : size) !== null && _ref !== void 0 ? _ref : DEFAULT_TEXT_SIZE;
|
|
95
|
+
// precedence: explicit weight > strong > named-style weight > default
|
|
96
|
+
const fontWeight = weight !== null && weight !== void 0 ? weight : strong === true ? 'bold' : (_namedStyle$weight = namedStyle === null || namedStyle === void 0 ? void 0 : namedStyle.weight) !== null && _namedStyle$weight !== void 0 ? _namedStyle$weight : DEFAULT_TEXT_WEIGHT;
|
|
97
|
+
return clsx(common, sprinkles({
|
|
98
|
+
color,
|
|
99
|
+
fontWeight,
|
|
100
|
+
text,
|
|
101
|
+
textAlign,
|
|
102
|
+
textTransform,
|
|
103
|
+
textWrap: noWrap === true ? 'nowrap' : wrap,
|
|
104
|
+
wordBreak: breakWord === true ? 'break-word' : wordBreak
|
|
105
|
+
}), !color && sprinklesLegacyText({
|
|
106
|
+
color: colour !== null && colour !== void 0 ? colour : strong === true ? 'dark' : DEFAULT_TEXT_COLOUR
|
|
107
|
+
}));
|
|
108
|
+
};
|
|
52
109
|
/**
|
|
53
110
|
* Primary utility for styling typography, combines reset styles, style props and element props.
|
|
54
111
|
* Also accepts a heading tag which will apply colour, font weight and size defaults.
|
|
@@ -70,7 +127,7 @@ export const typography = ({
|
|
|
70
127
|
* breakWord: true
|
|
71
128
|
* })
|
|
72
129
|
*/
|
|
73
|
-
export function textStyles(
|
|
130
|
+
export function textStyles(_ref2) {
|
|
74
131
|
let {
|
|
75
132
|
as = 'span',
|
|
76
133
|
className,
|
|
@@ -78,8 +135,8 @@ export function textStyles(_ref) {
|
|
|
78
135
|
size = isHeadingTag(as) ? headingSizeMap[as] : undefined,
|
|
79
136
|
weight = isHeadingTag(as) ? 'bold' : undefined
|
|
80
137
|
// remaining style props
|
|
81
|
-
} =
|
|
82
|
-
props = _objectWithoutProperties(
|
|
138
|
+
} = _ref2,
|
|
139
|
+
props = _objectWithoutProperties(_ref2, _excluded);
|
|
83
140
|
return clsx(resetStyles(as), typography(_objectSpread({
|
|
84
141
|
colour,
|
|
85
142
|
size,
|
|
@@ -1,15 +1,4 @@
|
|
|
1
1
|
export declare const colourMapWithoutWhite: {
|
|
2
|
-
black: {
|
|
3
|
-
'900': string;
|
|
4
|
-
'800': string;
|
|
5
|
-
'700': string;
|
|
6
|
-
'600': string;
|
|
7
|
-
'500': string;
|
|
8
|
-
'400': string;
|
|
9
|
-
'300': string;
|
|
10
|
-
'200': string;
|
|
11
|
-
'100': string;
|
|
12
|
-
};
|
|
13
2
|
gray: {
|
|
14
3
|
'900': string;
|
|
15
4
|
'800': string;
|
|
@@ -68,17 +57,6 @@ export declare const colourMapWithoutWhite: {
|
|
|
68
57
|
};
|
|
69
58
|
export declare const colourMap: {
|
|
70
59
|
white: string;
|
|
71
|
-
black: {
|
|
72
|
-
'900': string;
|
|
73
|
-
'800': string;
|
|
74
|
-
'700': string;
|
|
75
|
-
'600': string;
|
|
76
|
-
'500': string;
|
|
77
|
-
'400': string;
|
|
78
|
-
'300': string;
|
|
79
|
-
'200': string;
|
|
80
|
-
'100': string;
|
|
81
|
-
};
|
|
82
60
|
gray: {
|
|
83
61
|
'900': string;
|
|
84
62
|
'800': string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"colours.d.ts","sourceRoot":"","sources":["../../../lib/themes/base/colours.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,qBAAqB
|
|
1
|
+
{"version":3,"file":"colours.d.ts","sourceRoot":"","sources":["../../../lib/themes/base/colours.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,qBAAqB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAwDb,CAAC;AAEtB,eAAO,MAAM,SAAS;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAGD,CAAC;AACtB,eAAO,MAAM,mBAAmB,QAAwB,CAAC"}
|
|
@@ -2,17 +2,6 @@ import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
|
|
2
2
|
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
3
3
|
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
4
4
|
export const colourMapWithoutWhite = {
|
|
5
|
-
black: {
|
|
6
|
-
'900': '#222222',
|
|
7
|
-
'800': '#2A2C2A',
|
|
8
|
-
'700': '#444644',
|
|
9
|
-
'600': '#626262',
|
|
10
|
-
'500': '#808080',
|
|
11
|
-
'400': '#ADB1B5',
|
|
12
|
-
'300': '#D4D9DD',
|
|
13
|
-
'200': '#DDE0E3',
|
|
14
|
-
'100': '#E4E4E4'
|
|
15
|
-
},
|
|
16
5
|
gray: {
|
|
17
6
|
'900': '#212338',
|
|
18
7
|
'800': '#34384c',
|
|
@@ -25,11 +14,11 @@ export const colourMapWithoutWhite = {
|
|
|
25
14
|
'100': '#fafbfc'
|
|
26
15
|
},
|
|
27
16
|
green: {
|
|
28
|
-
'900': '#
|
|
29
|
-
'800': '#
|
|
17
|
+
'900': '#00574c',
|
|
18
|
+
'800': '#18856f',
|
|
30
19
|
'700': '#03af83',
|
|
31
20
|
'600': '#01c68c',
|
|
32
|
-
'500': '#
|
|
21
|
+
'500': '#00dda5',
|
|
33
22
|
'400': '#36e5aa',
|
|
34
23
|
'300': '#71edc2',
|
|
35
24
|
'200': '#e3f8f0',
|
|
@@ -41,9 +30,9 @@ export const colourMapWithoutWhite = {
|
|
|
41
30
|
'700': '#0d50ce',
|
|
42
31
|
'600': '#0d54e5',
|
|
43
32
|
'500': '#0d59fc',
|
|
44
|
-
'400': '#
|
|
45
|
-
'300': '#
|
|
46
|
-
'200': '#
|
|
33
|
+
'400': '#4a86ff',
|
|
34
|
+
'300': '#81afff',
|
|
35
|
+
'200': '#bad4ff',
|
|
47
36
|
'100': '#f3f8ff'
|
|
48
37
|
},
|
|
49
38
|
yellow: {
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The AutoGuru Design System 2026 contrast guide.
|
|
3
|
+
*
|
|
4
|
+
* Encodes the Figma "Contrast guide" frame: the only foreground-on-background
|
|
5
|
+
* colour combinations approved by design. Text combos meet WCAG AA (4.5:1);
|
|
6
|
+
* `icon-only` and `inactive-only` combos are conditional exceptions and must
|
|
7
|
+
* not be used for regular text.
|
|
8
|
+
*
|
|
9
|
+
* Do not use any colour combination that is not listed here.
|
|
10
|
+
*
|
|
11
|
+
* @see https://www.figma.com/design/ZkQlQcJkF7NTnZomVrPRN5/AutoGuru-Design-System-2026?node-id=360-12804
|
|
12
|
+
*/
|
|
13
|
+
export type ContrastUsage = 'text' | 'icon-only' | 'inactive-only';
|
|
14
|
+
type Hue = 'gray' | 'green' | 'blue' | 'yellow' | 'red';
|
|
15
|
+
type Step = '100' | '200' | '300' | '400' | '500' | '600' | '700' | '800' | '900';
|
|
16
|
+
/** A palette reference in design notation, e.g. `green-900`. */
|
|
17
|
+
export type ContrastColourToken = `${Hue}-${Step}` | 'white';
|
|
18
|
+
export interface ContrastCombo {
|
|
19
|
+
foreground: ContrastColourToken;
|
|
20
|
+
background: ContrastColourToken;
|
|
21
|
+
usage: ContrastUsage;
|
|
22
|
+
}
|
|
23
|
+
/** Resolves a contrast-guide token to its hex value in `colourMap`. */
|
|
24
|
+
export declare const contrastGuideColour: (token: ContrastColourToken) => string;
|
|
25
|
+
/**
|
|
26
|
+
* Every approved combination, grouped by the background's ramp. Order within
|
|
27
|
+
* each group follows the Figma chart (darkest background first).
|
|
28
|
+
*/
|
|
29
|
+
export declare const contrastGuide: Record<Hue, ContrastCombo[]>;
|
|
30
|
+
export {};
|
|
31
|
+
//# sourceMappingURL=contrastGuide.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"contrastGuide.d.ts","sourceRoot":"","sources":["../../../lib/themes/base/contrastGuide.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;GAWG;AAEH,MAAM,MAAM,aAAa,GAAG,MAAM,GAAG,WAAW,GAAG,eAAe,CAAC;AAEnE,KAAK,GAAG,GAAG,MAAM,GAAG,OAAO,GAAG,MAAM,GAAG,QAAQ,GAAG,KAAK,CAAC;AACxD,KAAK,IAAI,GACN,KAAK,GACL,KAAK,GACL,KAAK,GACL,KAAK,GACL,KAAK,GACL,KAAK,GACL,KAAK,GACL,KAAK,GACL,KAAK,CAAC;AAET,gEAAgE;AAChE,MAAM,MAAM,mBAAmB,GAAG,GAAG,GAAG,IAAI,IAAI,EAAE,GAAG,OAAO,CAAC;AAE7D,MAAM,WAAW,aAAa;IAC7B,UAAU,EAAE,mBAAmB,CAAC;IAChC,UAAU,EAAE,mBAAmB,CAAC;IAChC,KAAK,EAAE,aAAa,CAAC;CACrB;AAED,uEAAuE;AACvE,eAAO,MAAM,mBAAmB,GAAI,OAAO,mBAAmB,KAAG,MAIhE,CAAC;AAmBF;;;GAGG;AACH,eAAO,MAAM,aAAa,EAAE,MAAM,CAAC,GAAG,EAAE,aAAa,EAAE,CA4EtD,CAAC"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
|
|
2
|
+
import { colourMap } from "./colours.js";
|
|
3
|
+
/**
|
|
4
|
+
* The AutoGuru Design System 2026 contrast guide.
|
|
5
|
+
*
|
|
6
|
+
* Encodes the Figma "Contrast guide" frame: the only foreground-on-background
|
|
7
|
+
* colour combinations approved by design. Text combos meet WCAG AA (4.5:1);
|
|
8
|
+
* `icon-only` and `inactive-only` combos are conditional exceptions and must
|
|
9
|
+
* not be used for regular text.
|
|
10
|
+
*
|
|
11
|
+
* Do not use any colour combination that is not listed here.
|
|
12
|
+
*
|
|
13
|
+
* @see https://www.figma.com/design/ZkQlQcJkF7NTnZomVrPRN5/AutoGuru-Design-System-2026?node-id=360-12804
|
|
14
|
+
*/
|
|
15
|
+
/** A palette reference in design notation, e.g. `green-900`. */
|
|
16
|
+
/** Resolves a contrast-guide token to its hex value in `colourMap`. */
|
|
17
|
+
export const contrastGuideColour = token => {
|
|
18
|
+
if (token === 'white') return colourMap.white;
|
|
19
|
+
const [hue, step] = token.split('-');
|
|
20
|
+
return colourMap[hue][step];
|
|
21
|
+
};
|
|
22
|
+
const combos = (foreground, backgrounds, usage = 'text') => backgrounds.map(background => ({
|
|
23
|
+
foreground,
|
|
24
|
+
background,
|
|
25
|
+
usage
|
|
26
|
+
}));
|
|
27
|
+
const onWhite = (foregrounds, usage = 'text') => foregrounds.map(foreground => ({
|
|
28
|
+
foreground,
|
|
29
|
+
background: 'white',
|
|
30
|
+
usage
|
|
31
|
+
}));
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Every approved combination, grouped by the background's ramp. Order within
|
|
35
|
+
* each group follows the Figma chart (darkest background first).
|
|
36
|
+
*/
|
|
37
|
+
export const contrastGuide = {
|
|
38
|
+
green: [].concat(_toConsumableArray(combos('white', ['green-900', 'green-800'])), _toConsumableArray(onWhite(['green-900', 'green-800'])), _toConsumableArray(combos('gray-900', ['green-600', 'green-500', 'green-400', 'green-300'])), _toConsumableArray(onWhite(['green-600'], 'icon-only')), _toConsumableArray(combos('green-900', ['green-200', 'green-100']))),
|
|
39
|
+
yellow: [].concat(_toConsumableArray(combos('gray-900', ['yellow-900', 'yellow-800', 'yellow-700', 'yellow-600', 'yellow-500', 'yellow-400', 'yellow-300', 'yellow-200', 'yellow-100'])), _toConsumableArray(combos('red-900', ['yellow-500', 'yellow-400', 'yellow-300', 'yellow-200', 'yellow-100']))),
|
|
40
|
+
gray: [].concat(_toConsumableArray(combos('white', ['gray-900', 'gray-800', 'gray-700', 'gray-600', 'gray-500'])), _toConsumableArray(onWhite(['gray-900', 'gray-800', 'gray-700', 'gray-600', 'gray-500'])), _toConsumableArray(onWhite(['gray-400'], 'inactive-only')), _toConsumableArray(combos('gray-900', ['gray-300', 'gray-200', 'gray-100']))),
|
|
41
|
+
blue: [].concat(_toConsumableArray(combos('white', ['blue-900', 'blue-800', 'blue-700', 'blue-600', 'blue-500'])), _toConsumableArray(onWhite(['blue-900', 'blue-800', 'blue-700', 'blue-600'])), _toConsumableArray(combos('gray-900', ['blue-200', 'blue-100'])), _toConsumableArray(combos('blue-900', ['blue-200', 'blue-100']))),
|
|
42
|
+
red: [].concat(_toConsumableArray(combos('white', ['red-900', 'red-800', 'red-700', 'red-600', 'red-500'])), _toConsumableArray(onWhite(['red-900', 'red-800', 'red-700'])), _toConsumableArray(onWhite(['red-600'], 'icon-only')), _toConsumableArray(combos('gray-900', ['red-200', 'red-100'])), _toConsumableArray(combos('red-900', ['red-200', 'red-100'])))
|
|
43
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"contrastGuide.spec.d.ts","sourceRoot":"","sources":["../../../lib/themes/base/contrastGuide.spec.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
|
|
2
|
+
import { describe, expect, it } from 'vitest';
|
|
3
|
+
import { tokens as flatRedTokens } from "../flat_red/tokens.js";
|
|
4
|
+
import { getContrastRatio } from "../helpers.js";
|
|
5
|
+
import { tokens as neutralTokens } from "../neutral/tokens.js";
|
|
6
|
+
import { contrastGuide, contrastGuideColour } from "./contrastGuide.js";
|
|
7
|
+
import { tokens as baseTokens } from "./tokens.js";
|
|
8
|
+
const ratio = (foreground, background) => 1 / getContrastRatio(foreground, background);
|
|
9
|
+
const allCombos = Object.values(contrastGuide).flat();
|
|
10
|
+
const label = ({
|
|
11
|
+
foreground,
|
|
12
|
+
background
|
|
13
|
+
}) => `${foreground} on ${background}`;
|
|
14
|
+
const KNOWN_BELOW_ICON_THRESHOLD = new Set(['green-600 on white']);
|
|
15
|
+
describe('contrast guide', () => {
|
|
16
|
+
describe.each(allCombos.filter(combo => combo.usage === 'text'))('text combo $foreground on $background', combo => {
|
|
17
|
+
it('passes WCAG AA for normal text (4.5:1)', () => {
|
|
18
|
+
expect(ratio(contrastGuideColour(combo.foreground), contrastGuideColour(combo.background))).toBeGreaterThanOrEqual(4.5);
|
|
19
|
+
});
|
|
20
|
+
});
|
|
21
|
+
describe.each(allCombos.filter(combo => combo.usage !== 'text'))('conditional combo $foreground on $background ($usage)', combo => {
|
|
22
|
+
it('meets the 3:1 non-text threshold (or is a documented exception)', () => {
|
|
23
|
+
const value = ratio(contrastGuideColour(combo.foreground), contrastGuideColour(combo.background));
|
|
24
|
+
if (KNOWN_BELOW_ICON_THRESHOLD.has(label(combo))) {
|
|
25
|
+
expect(value).toBeLessThan(3);
|
|
26
|
+
} else {
|
|
27
|
+
expect(value).toBeGreaterThanOrEqual(3);
|
|
28
|
+
}
|
|
29
|
+
});
|
|
30
|
+
});
|
|
31
|
+
});
|
|
32
|
+
const tokenPairs = tokens => {
|
|
33
|
+
const {
|
|
34
|
+
surface,
|
|
35
|
+
content
|
|
36
|
+
} = tokens.color;
|
|
37
|
+
return [['content.normal on surface.page', content.normal, surface.page], ['content.soft on surface.page', content.soft, surface.page], ['content.inverse on surface.hard', content.inverse, surface.hard], ['content.inverse on surface.soft', content.inverse, surface.soft], ['content.info on surface.page', content.info, surface.page], ['content.danger on surface.page', content.danger, surface.page], ['content.success on surface.page', content.success, surface.page], ['content.warning on surface.page', content.warning, surface.page]].concat(_toConsumableArray(Object.entries(tokens.colours.intent).flatMap(([name, intent]) => [[`intent.${name} foreground on background.standard`, intent.foreground, intent.background.standard], [`intent.${name} foreground on background.strong`, intent.foreground, intent.background.strong]])));
|
|
38
|
+
};
|
|
39
|
+
const KNOWN_AA_FAILURES = {
|
|
40
|
+
base: ['content.warning on surface.page', 'intent.brand foreground on background.standard', 'intent.primary foreground on background.standard', 'intent.primary foreground on background.strong', 'intent.shine foreground on background.standard', 'intent.shine foreground on background.strong', 'intent.success foreground on background.standard', 'intent.warning foreground on background.standard', 'intent.warning foreground on background.strong'],
|
|
41
|
+
flat_red: ['content.warning on surface.page', 'intent.brand foreground on background.standard', 'intent.primary foreground on background.standard', 'intent.shine foreground on background.standard', 'intent.shine foreground on background.strong', 'intent.success foreground on background.standard', 'intent.warning foreground on background.standard', 'intent.warning foreground on background.strong'],
|
|
42
|
+
neutral: ['content.warning on surface.page', 'intent.brand foreground on background.standard', 'intent.shine foreground on background.standard', 'intent.shine foreground on background.strong', 'intent.success foreground on background.standard', 'intent.warning foreground on background.standard', 'intent.warning foreground on background.strong']
|
|
43
|
+
};
|
|
44
|
+
describe.each([['base', baseTokens], ['flat_red', flatRedTokens], ['neutral', neutralTokens]])('theme token audit: %s', (themeName, tokens) => {
|
|
45
|
+
it('has no undocumented AA failures in intended pairings', () => {
|
|
46
|
+
const failures = tokenPairs(tokens).filter(([, foreground, background]) => {
|
|
47
|
+
return ratio(foreground, background) < 4.5;
|
|
48
|
+
}).map(([name]) => name).sort();
|
|
49
|
+
expect(failures).toEqual(_toConsumableArray(KNOWN_AA_FAILURES[themeName]).sort());
|
|
50
|
+
});
|
|
51
|
+
});
|