@dloizides/design-tokens 1.13.1 → 1.15.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 +4 -0
- package/dist/index.d.mts +39 -1
- package/dist/index.d.ts +39 -1
- package/dist/index.js +132 -63
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +128 -64
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 1.14.0
|
|
4
|
+
|
|
5
|
+
- One fleet focus ring (FOCUS-RING-1 "One focus ring across the shared kit"): `FOCUS_RING` (2 px solid, 2 px offset), `resolveFocusRingColor` (the mode's `focusRing` token, else the first of primary / a lighter brand step / text reaching 3:1 on the ground), `focusRingOutline` and `isFocusVisible` (keyboard focus only). Consumed by ui-buttons, ui-forms and ui-payments.
|
|
6
|
+
|
|
3
7
|
## 1.13.1
|
|
4
8
|
|
|
5
9
|
- `prepublishOnly` now runs `jest --coverage`, so the 100% coverage threshold blocks a publish (DT-COV-1 "design-tokens coverage threshold failing"). `contrast.ts` shorthand-hex expansion rewritten without unreachable fallbacks; output unchanged.
|
package/dist/index.d.mts
CHANGED
|
@@ -418,6 +418,39 @@ type ZIndexLayer = keyof typeof Z_INDEX;
|
|
|
418
418
|
/** The layers in stacking order, lowest first. */
|
|
419
419
|
declare const Z_INDEX_ORDER: readonly ZIndexLayer[];
|
|
420
420
|
|
|
421
|
+
/** Geometry of the one fleet focus ring: a 2 px solid outline drawn 2 px outside the control. */
|
|
422
|
+
declare const FOCUS_RING: {
|
|
423
|
+
readonly width: 2;
|
|
424
|
+
readonly offset: 2;
|
|
425
|
+
readonly style: "solid";
|
|
426
|
+
};
|
|
427
|
+
/** Colours {@link resolveFocusRingColor} chooses from, all for the current mode. */
|
|
428
|
+
interface FocusRingColorInput {
|
|
429
|
+
/** The mode's explicit `focusRing` token; used as-is when set. */
|
|
430
|
+
focusRing?: string;
|
|
431
|
+
/** Brand primary (main step). */
|
|
432
|
+
primary: string;
|
|
433
|
+
/** A lighter brand step, tried when `primary` is too dark for the ground. */
|
|
434
|
+
primaryLight?: string;
|
|
435
|
+
/** Primary text; the last resort, always readable on `background`. */
|
|
436
|
+
text: string;
|
|
437
|
+
/** The ground the ring is drawn on. */
|
|
438
|
+
background: string;
|
|
439
|
+
}
|
|
440
|
+
/** Outline style keys for the focus ring in `color`. */
|
|
441
|
+
interface FocusRingOutline {
|
|
442
|
+
outlineColor: string;
|
|
443
|
+
outlineOffset: number;
|
|
444
|
+
outlineStyle: typeof FOCUS_RING.style;
|
|
445
|
+
outlineWidth: number;
|
|
446
|
+
}
|
|
447
|
+
/** The focus-ring colour for one mode: the focusRing token, else the first candidate reaching 3:1 on the ground. */
|
|
448
|
+
declare function resolveFocusRingColor(input: FocusRingColorInput): string;
|
|
449
|
+
/** The outline style object for the focus ring in `color`. */
|
|
450
|
+
declare function focusRingOutline(color: string): FocusRingOutline;
|
|
451
|
+
/** True when a focus target is keyboard focus; targets that cannot answer count as visible. */
|
|
452
|
+
declare function isFocusVisible(target: unknown): boolean;
|
|
453
|
+
|
|
421
454
|
/**
|
|
422
455
|
* CSS custom-property NAME MAPS — the cross-stack naming contract.
|
|
423
456
|
*
|
|
@@ -1056,4 +1089,9 @@ declare function onBrandRatio(background: string, explicit?: string): number | n
|
|
|
1056
1089
|
*/
|
|
1057
1090
|
declare function canCarryAccessibleInk(background: string): boolean;
|
|
1058
1091
|
|
|
1059
|
-
|
|
1092
|
+
/** A colour scale keyed by step ('50'…'900'); a theme only guarantees some steps. */
|
|
1093
|
+
type ColorStepScale = Readonly<Record<string, string | undefined>>;
|
|
1094
|
+
/** The first scale step that clears 4.5:1 on the ground (light or dark step order), else the highest-contrast one. */
|
|
1095
|
+
declare function readableScaleInk(scale: ColorStepScale, ground: string, lightSteps: readonly string[], darkSteps: readonly string[]): string;
|
|
1096
|
+
|
|
1097
|
+
export { AA_LARGE_TEXT_RATIO, AA_NON_TEXT_RATIO, AA_NORMAL_TEXT_RATIO, AML_CSS_VAR_NAMES, AML_TOKENS, type BrandExtras, type Branding, type ColorStepScale, type ContrastMoreOverrides, type CssVarNames, DEFAULT_CSS_VAR_NAMES, DEFAULT_MOTION, DIGITALKIN_TOKENS, type DesignTokens, EREVNA_TOKENS, FINREG_MODULE_COLORS, FINREG_SURFACE_COLORS, FOCUS_RING, type FinregModuleColor, type FinregModuleColors, type FinregSurfaceColors, type FocusRingColorInput, type FocusRingOutline, INTERVIEWPREP_CSS_VAR_NAMES, INTERVIEWPREP_TOKENS, type InkScale, KATALOGOS_TOKENS, type ModeColors, type Motion, type MotionDurations, type MotionEasing, type MotionEasings, type MotionSpring, type MotionSprings, NEXTGAME_TOKENS, ON_BRAND_DARK_INK, ON_BRAND_LIGHT_INK, PRESETS, RN_WEB_MODAL_Z_INDEX, type Radii, type RnThemeConfig, type SemanticColors, type Shadows, type ShellColors, type TailwindColors, type TailwindPreset, type ToCssVarsOptions, type TokenExtensions, type Typography, UI_DEEP_STEP, UI_MAIN_STEP, UI_TINT_STEP, type UiColorScale, type UiThemeColors, type UiThemeConfig, type UiThemeMode, type UiThemePalette, type UiThemeSemantic, type VerdictColors, type WorkspaceExtras, type ZIndexLayer, Z_INDEX, Z_INDEX_ORDER, canCarryAccessibleInk, contrastRatio, focusRingOutline, isFocusVisible, isHexColor, meetsContrast, onBrandRatio, readableScaleInk, relativeLuminance, resolveFocusRingColor, resolveOnBrand, toCssVars, toRnTheme, toTailwindPreset, toUiTheme };
|
package/dist/index.d.ts
CHANGED
|
@@ -418,6 +418,39 @@ type ZIndexLayer = keyof typeof Z_INDEX;
|
|
|
418
418
|
/** The layers in stacking order, lowest first. */
|
|
419
419
|
declare const Z_INDEX_ORDER: readonly ZIndexLayer[];
|
|
420
420
|
|
|
421
|
+
/** Geometry of the one fleet focus ring: a 2 px solid outline drawn 2 px outside the control. */
|
|
422
|
+
declare const FOCUS_RING: {
|
|
423
|
+
readonly width: 2;
|
|
424
|
+
readonly offset: 2;
|
|
425
|
+
readonly style: "solid";
|
|
426
|
+
};
|
|
427
|
+
/** Colours {@link resolveFocusRingColor} chooses from, all for the current mode. */
|
|
428
|
+
interface FocusRingColorInput {
|
|
429
|
+
/** The mode's explicit `focusRing` token; used as-is when set. */
|
|
430
|
+
focusRing?: string;
|
|
431
|
+
/** Brand primary (main step). */
|
|
432
|
+
primary: string;
|
|
433
|
+
/** A lighter brand step, tried when `primary` is too dark for the ground. */
|
|
434
|
+
primaryLight?: string;
|
|
435
|
+
/** Primary text; the last resort, always readable on `background`. */
|
|
436
|
+
text: string;
|
|
437
|
+
/** The ground the ring is drawn on. */
|
|
438
|
+
background: string;
|
|
439
|
+
}
|
|
440
|
+
/** Outline style keys for the focus ring in `color`. */
|
|
441
|
+
interface FocusRingOutline {
|
|
442
|
+
outlineColor: string;
|
|
443
|
+
outlineOffset: number;
|
|
444
|
+
outlineStyle: typeof FOCUS_RING.style;
|
|
445
|
+
outlineWidth: number;
|
|
446
|
+
}
|
|
447
|
+
/** The focus-ring colour for one mode: the focusRing token, else the first candidate reaching 3:1 on the ground. */
|
|
448
|
+
declare function resolveFocusRingColor(input: FocusRingColorInput): string;
|
|
449
|
+
/** The outline style object for the focus ring in `color`. */
|
|
450
|
+
declare function focusRingOutline(color: string): FocusRingOutline;
|
|
451
|
+
/** True when a focus target is keyboard focus; targets that cannot answer count as visible. */
|
|
452
|
+
declare function isFocusVisible(target: unknown): boolean;
|
|
453
|
+
|
|
421
454
|
/**
|
|
422
455
|
* CSS custom-property NAME MAPS — the cross-stack naming contract.
|
|
423
456
|
*
|
|
@@ -1056,4 +1089,9 @@ declare function onBrandRatio(background: string, explicit?: string): number | n
|
|
|
1056
1089
|
*/
|
|
1057
1090
|
declare function canCarryAccessibleInk(background: string): boolean;
|
|
1058
1091
|
|
|
1059
|
-
|
|
1092
|
+
/** A colour scale keyed by step ('50'…'900'); a theme only guarantees some steps. */
|
|
1093
|
+
type ColorStepScale = Readonly<Record<string, string | undefined>>;
|
|
1094
|
+
/** The first scale step that clears 4.5:1 on the ground (light or dark step order), else the highest-contrast one. */
|
|
1095
|
+
declare function readableScaleInk(scale: ColorStepScale, ground: string, lightSteps: readonly string[], darkSteps: readonly string[]): string;
|
|
1096
|
+
|
|
1097
|
+
export { AA_LARGE_TEXT_RATIO, AA_NON_TEXT_RATIO, AA_NORMAL_TEXT_RATIO, AML_CSS_VAR_NAMES, AML_TOKENS, type BrandExtras, type Branding, type ColorStepScale, type ContrastMoreOverrides, type CssVarNames, DEFAULT_CSS_VAR_NAMES, DEFAULT_MOTION, DIGITALKIN_TOKENS, type DesignTokens, EREVNA_TOKENS, FINREG_MODULE_COLORS, FINREG_SURFACE_COLORS, FOCUS_RING, type FinregModuleColor, type FinregModuleColors, type FinregSurfaceColors, type FocusRingColorInput, type FocusRingOutline, INTERVIEWPREP_CSS_VAR_NAMES, INTERVIEWPREP_TOKENS, type InkScale, KATALOGOS_TOKENS, type ModeColors, type Motion, type MotionDurations, type MotionEasing, type MotionEasings, type MotionSpring, type MotionSprings, NEXTGAME_TOKENS, ON_BRAND_DARK_INK, ON_BRAND_LIGHT_INK, PRESETS, RN_WEB_MODAL_Z_INDEX, type Radii, type RnThemeConfig, type SemanticColors, type Shadows, type ShellColors, type TailwindColors, type TailwindPreset, type ToCssVarsOptions, type TokenExtensions, type Typography, UI_DEEP_STEP, UI_MAIN_STEP, UI_TINT_STEP, type UiColorScale, type UiThemeColors, type UiThemeConfig, type UiThemeMode, type UiThemePalette, type UiThemeSemantic, type VerdictColors, type WorkspaceExtras, type ZIndexLayer, Z_INDEX, Z_INDEX_ORDER, canCarryAccessibleInk, contrastRatio, focusRingOutline, isFocusVisible, isHexColor, meetsContrast, onBrandRatio, readableScaleInk, relativeLuminance, resolveFocusRingColor, resolveOnBrand, toCssVars, toRnTheme, toTailwindPreset, toUiTheme };
|
package/dist/index.js
CHANGED
|
@@ -68,6 +68,110 @@ var Z_INDEX_ORDER = [
|
|
|
68
68
|
"blocking"
|
|
69
69
|
];
|
|
70
70
|
|
|
71
|
+
// src/contrast.ts
|
|
72
|
+
var AA_NORMAL_TEXT_RATIO = 4.5;
|
|
73
|
+
var AA_LARGE_TEXT_RATIO = 3;
|
|
74
|
+
var AA_NON_TEXT_RATIO = 3;
|
|
75
|
+
var SRGB_CHANNEL_MAX = 255;
|
|
76
|
+
var GAMMA_LINEAR_THRESHOLD = 0.03928;
|
|
77
|
+
var GAMMA_LINEAR_DIVISOR = 12.92;
|
|
78
|
+
var GAMMA_OFFSET = 0.055;
|
|
79
|
+
var GAMMA_DIVISOR = 1.055;
|
|
80
|
+
var GAMMA_EXPONENT = 2.4;
|
|
81
|
+
var LUMA_COEFFICIENT_RED = 0.2126;
|
|
82
|
+
var LUMA_COEFFICIENT_GREEN = 0.7152;
|
|
83
|
+
var LUMA_COEFFICIENT_BLUE = 0.0722;
|
|
84
|
+
var CONTRAST_FLARE = 0.05;
|
|
85
|
+
var HEX_RADIX = 16;
|
|
86
|
+
var HEX_PAIR_LENGTH = 2;
|
|
87
|
+
var HEX_SHORTHAND_LENGTH = 3;
|
|
88
|
+
var HEX_FULL_LENGTH = 6;
|
|
89
|
+
var CHANNEL_OFFSET_RED = 0;
|
|
90
|
+
var CHANNEL_OFFSET_GREEN = 2;
|
|
91
|
+
var CHANNEL_OFFSET_BLUE = 4;
|
|
92
|
+
function normalizeHexDigits(hex) {
|
|
93
|
+
const clean = hex.trim().replace("#", "").toLowerCase();
|
|
94
|
+
if (clean.length === HEX_SHORTHAND_LENGTH) {
|
|
95
|
+
return [...clean].map((digit) => digit + digit).join("");
|
|
96
|
+
}
|
|
97
|
+
return clean;
|
|
98
|
+
}
|
|
99
|
+
function parseChannel(digits, offset) {
|
|
100
|
+
const pair = digits.slice(offset, offset + HEX_PAIR_LENGTH);
|
|
101
|
+
return parseInt(pair, HEX_RADIX) / SRGB_CHANNEL_MAX;
|
|
102
|
+
}
|
|
103
|
+
function linearizeChannel(channel) {
|
|
104
|
+
if (channel <= GAMMA_LINEAR_THRESHOLD) {
|
|
105
|
+
return channel / GAMMA_LINEAR_DIVISOR;
|
|
106
|
+
}
|
|
107
|
+
return Math.pow((channel + GAMMA_OFFSET) / GAMMA_DIVISOR, GAMMA_EXPONENT);
|
|
108
|
+
}
|
|
109
|
+
function isHexColor(value) {
|
|
110
|
+
const digits = normalizeHexDigits(value);
|
|
111
|
+
return digits.length === HEX_FULL_LENGTH && /^[0-9a-f]{6}$/.test(digits);
|
|
112
|
+
}
|
|
113
|
+
function relativeLuminance(hex) {
|
|
114
|
+
if (!isHexColor(hex)) {
|
|
115
|
+
throw new Error(`relativeLuminance: not a hex colour: ${hex}`);
|
|
116
|
+
}
|
|
117
|
+
const digits = normalizeHexDigits(hex);
|
|
118
|
+
const red = linearizeChannel(parseChannel(digits, CHANNEL_OFFSET_RED));
|
|
119
|
+
const green = linearizeChannel(parseChannel(digits, CHANNEL_OFFSET_GREEN));
|
|
120
|
+
const blue = linearizeChannel(parseChannel(digits, CHANNEL_OFFSET_BLUE));
|
|
121
|
+
return LUMA_COEFFICIENT_RED * red + LUMA_COEFFICIENT_GREEN * green + LUMA_COEFFICIENT_BLUE * blue;
|
|
122
|
+
}
|
|
123
|
+
function contrastRatio(foreground, background) {
|
|
124
|
+
const first = relativeLuminance(foreground);
|
|
125
|
+
const second = relativeLuminance(background);
|
|
126
|
+
const lighter = Math.max(first, second);
|
|
127
|
+
const darker = Math.min(first, second);
|
|
128
|
+
return (lighter + CONTRAST_FLARE) / (darker + CONTRAST_FLARE);
|
|
129
|
+
}
|
|
130
|
+
function meetsContrast(foreground, background, requiredRatio) {
|
|
131
|
+
return contrastRatio(foreground, background) >= requiredRatio;
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
// src/focusRing.ts
|
|
135
|
+
var RING_WIDTH_PX = 2;
|
|
136
|
+
var RING_OFFSET_PX = 2;
|
|
137
|
+
var FOCUS_RING = {
|
|
138
|
+
width: RING_WIDTH_PX,
|
|
139
|
+
offset: RING_OFFSET_PX,
|
|
140
|
+
style: "solid"
|
|
141
|
+
};
|
|
142
|
+
function passesOnGround(color, background) {
|
|
143
|
+
return color !== void 0 && isHexColor(color) && contrastRatio(color, background) >= AA_NON_TEXT_RATIO;
|
|
144
|
+
}
|
|
145
|
+
function resolveFocusRingColor(input) {
|
|
146
|
+
if (input.focusRing) {
|
|
147
|
+
return input.focusRing;
|
|
148
|
+
}
|
|
149
|
+
if (!isHexColor(input.background)) {
|
|
150
|
+
return input.primary;
|
|
151
|
+
}
|
|
152
|
+
const candidates = [input.primary, input.primaryLight];
|
|
153
|
+
return candidates.find((color) => passesOnGround(color, input.background)) ?? input.text;
|
|
154
|
+
}
|
|
155
|
+
function focusRingOutline(color) {
|
|
156
|
+
return {
|
|
157
|
+
outlineColor: color,
|
|
158
|
+
outlineOffset: FOCUS_RING.offset,
|
|
159
|
+
outlineStyle: FOCUS_RING.style,
|
|
160
|
+
outlineWidth: FOCUS_RING.width
|
|
161
|
+
};
|
|
162
|
+
}
|
|
163
|
+
function isFocusVisible(target) {
|
|
164
|
+
const candidate = target;
|
|
165
|
+
if (typeof candidate?.matches !== "function") {
|
|
166
|
+
return true;
|
|
167
|
+
}
|
|
168
|
+
try {
|
|
169
|
+
return candidate.matches(":focus-visible");
|
|
170
|
+
} catch {
|
|
171
|
+
return true;
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
|
|
71
175
|
// src/varNames.ts
|
|
72
176
|
var DEFAULT_CSS_VAR_NAMES = {
|
|
73
177
|
primary: "--primary",
|
|
@@ -195,69 +299,6 @@ var INTERVIEWPREP_CSS_VAR_NAMES = {
|
|
|
195
299
|
monoFamily: "--font-mono"
|
|
196
300
|
};
|
|
197
301
|
|
|
198
|
-
// src/contrast.ts
|
|
199
|
-
var AA_NORMAL_TEXT_RATIO = 4.5;
|
|
200
|
-
var AA_LARGE_TEXT_RATIO = 3;
|
|
201
|
-
var AA_NON_TEXT_RATIO = 3;
|
|
202
|
-
var SRGB_CHANNEL_MAX = 255;
|
|
203
|
-
var GAMMA_LINEAR_THRESHOLD = 0.03928;
|
|
204
|
-
var GAMMA_LINEAR_DIVISOR = 12.92;
|
|
205
|
-
var GAMMA_OFFSET = 0.055;
|
|
206
|
-
var GAMMA_DIVISOR = 1.055;
|
|
207
|
-
var GAMMA_EXPONENT = 2.4;
|
|
208
|
-
var LUMA_COEFFICIENT_RED = 0.2126;
|
|
209
|
-
var LUMA_COEFFICIENT_GREEN = 0.7152;
|
|
210
|
-
var LUMA_COEFFICIENT_BLUE = 0.0722;
|
|
211
|
-
var CONTRAST_FLARE = 0.05;
|
|
212
|
-
var HEX_RADIX = 16;
|
|
213
|
-
var HEX_PAIR_LENGTH = 2;
|
|
214
|
-
var HEX_SHORTHAND_LENGTH = 3;
|
|
215
|
-
var HEX_FULL_LENGTH = 6;
|
|
216
|
-
var CHANNEL_OFFSET_RED = 0;
|
|
217
|
-
var CHANNEL_OFFSET_GREEN = 2;
|
|
218
|
-
var CHANNEL_OFFSET_BLUE = 4;
|
|
219
|
-
function normalizeHexDigits(hex) {
|
|
220
|
-
const clean = hex.trim().replace("#", "").toLowerCase();
|
|
221
|
-
if (clean.length === HEX_SHORTHAND_LENGTH) {
|
|
222
|
-
return [...clean].map((digit) => digit + digit).join("");
|
|
223
|
-
}
|
|
224
|
-
return clean;
|
|
225
|
-
}
|
|
226
|
-
function parseChannel(digits, offset) {
|
|
227
|
-
const pair = digits.slice(offset, offset + HEX_PAIR_LENGTH);
|
|
228
|
-
return parseInt(pair, HEX_RADIX) / SRGB_CHANNEL_MAX;
|
|
229
|
-
}
|
|
230
|
-
function linearizeChannel(channel) {
|
|
231
|
-
if (channel <= GAMMA_LINEAR_THRESHOLD) {
|
|
232
|
-
return channel / GAMMA_LINEAR_DIVISOR;
|
|
233
|
-
}
|
|
234
|
-
return Math.pow((channel + GAMMA_OFFSET) / GAMMA_DIVISOR, GAMMA_EXPONENT);
|
|
235
|
-
}
|
|
236
|
-
function isHexColor(value) {
|
|
237
|
-
const digits = normalizeHexDigits(value);
|
|
238
|
-
return digits.length === HEX_FULL_LENGTH && /^[0-9a-f]{6}$/.test(digits);
|
|
239
|
-
}
|
|
240
|
-
function relativeLuminance(hex) {
|
|
241
|
-
if (!isHexColor(hex)) {
|
|
242
|
-
throw new Error(`relativeLuminance: not a hex colour: ${hex}`);
|
|
243
|
-
}
|
|
244
|
-
const digits = normalizeHexDigits(hex);
|
|
245
|
-
const red = linearizeChannel(parseChannel(digits, CHANNEL_OFFSET_RED));
|
|
246
|
-
const green = linearizeChannel(parseChannel(digits, CHANNEL_OFFSET_GREEN));
|
|
247
|
-
const blue = linearizeChannel(parseChannel(digits, CHANNEL_OFFSET_BLUE));
|
|
248
|
-
return LUMA_COEFFICIENT_RED * red + LUMA_COEFFICIENT_GREEN * green + LUMA_COEFFICIENT_BLUE * blue;
|
|
249
|
-
}
|
|
250
|
-
function contrastRatio(foreground, background) {
|
|
251
|
-
const first = relativeLuminance(foreground);
|
|
252
|
-
const second = relativeLuminance(background);
|
|
253
|
-
const lighter = Math.max(first, second);
|
|
254
|
-
const darker = Math.min(first, second);
|
|
255
|
-
return (lighter + CONTRAST_FLARE) / (darker + CONTRAST_FLARE);
|
|
256
|
-
}
|
|
257
|
-
function meetsContrast(foreground, background, requiredRatio) {
|
|
258
|
-
return contrastRatio(foreground, background) >= requiredRatio;
|
|
259
|
-
}
|
|
260
|
-
|
|
261
302
|
// src/onBrand.ts
|
|
262
303
|
var ON_BRAND_LIGHT_INK = "#ffffff";
|
|
263
304
|
var ON_BRAND_DARK_INK = "#03121f";
|
|
@@ -957,6 +998,29 @@ var FINREG_SURFACE_COLORS = {
|
|
|
957
998
|
deepest: "#071526"
|
|
958
999
|
};
|
|
959
1000
|
|
|
1001
|
+
// src/readableScaleInk.ts
|
|
1002
|
+
var DARK_GROUND_LUMINANCE = 0.179;
|
|
1003
|
+
function definedSteps(scale, steps) {
|
|
1004
|
+
return steps.map((step) => scale[step]).filter((ink) => ink !== void 0);
|
|
1005
|
+
}
|
|
1006
|
+
function highestContrast(inks, ground) {
|
|
1007
|
+
return inks.reduce(
|
|
1008
|
+
(top, ink) => top === void 0 || contrastRatio(ink, ground) > contrastRatio(top, ground) ? ink : top,
|
|
1009
|
+
void 0
|
|
1010
|
+
);
|
|
1011
|
+
}
|
|
1012
|
+
function readableScaleInk(scale, ground, lightSteps, darkSteps) {
|
|
1013
|
+
const lightInks = definedSteps(scale, lightSteps);
|
|
1014
|
+
const fallback = lightInks[0] ?? scale["500"] ?? "";
|
|
1015
|
+
if (!isHexColor(ground)) {
|
|
1016
|
+
return fallback;
|
|
1017
|
+
}
|
|
1018
|
+
const isDarkGround = relativeLuminance(ground) < DARK_GROUND_LUMINANCE;
|
|
1019
|
+
const inks = (isDarkGround ? definedSteps(scale, darkSteps) : lightInks).filter(isHexColor);
|
|
1020
|
+
const passing = inks.find((ink) => contrastRatio(ink, ground) >= AA_NORMAL_TEXT_RATIO);
|
|
1021
|
+
return passing ?? highestContrast(inks, ground) ?? fallback;
|
|
1022
|
+
}
|
|
1023
|
+
|
|
960
1024
|
exports.AA_LARGE_TEXT_RATIO = AA_LARGE_TEXT_RATIO;
|
|
961
1025
|
exports.AA_NON_TEXT_RATIO = AA_NON_TEXT_RATIO;
|
|
962
1026
|
exports.AA_NORMAL_TEXT_RATIO = AA_NORMAL_TEXT_RATIO;
|
|
@@ -968,6 +1032,7 @@ exports.DIGITALKIN_TOKENS = DIGITALKIN_TOKENS;
|
|
|
968
1032
|
exports.EREVNA_TOKENS = EREVNA_TOKENS;
|
|
969
1033
|
exports.FINREG_MODULE_COLORS = FINREG_MODULE_COLORS;
|
|
970
1034
|
exports.FINREG_SURFACE_COLORS = FINREG_SURFACE_COLORS;
|
|
1035
|
+
exports.FOCUS_RING = FOCUS_RING;
|
|
971
1036
|
exports.INTERVIEWPREP_CSS_VAR_NAMES = INTERVIEWPREP_CSS_VAR_NAMES;
|
|
972
1037
|
exports.INTERVIEWPREP_TOKENS = INTERVIEWPREP_TOKENS;
|
|
973
1038
|
exports.KATALOGOS_TOKENS = KATALOGOS_TOKENS;
|
|
@@ -983,10 +1048,14 @@ exports.Z_INDEX = Z_INDEX;
|
|
|
983
1048
|
exports.Z_INDEX_ORDER = Z_INDEX_ORDER;
|
|
984
1049
|
exports.canCarryAccessibleInk = canCarryAccessibleInk;
|
|
985
1050
|
exports.contrastRatio = contrastRatio;
|
|
1051
|
+
exports.focusRingOutline = focusRingOutline;
|
|
1052
|
+
exports.isFocusVisible = isFocusVisible;
|
|
986
1053
|
exports.isHexColor = isHexColor;
|
|
987
1054
|
exports.meetsContrast = meetsContrast;
|
|
988
1055
|
exports.onBrandRatio = onBrandRatio;
|
|
1056
|
+
exports.readableScaleInk = readableScaleInk;
|
|
989
1057
|
exports.relativeLuminance = relativeLuminance;
|
|
1058
|
+
exports.resolveFocusRingColor = resolveFocusRingColor;
|
|
990
1059
|
exports.resolveOnBrand = resolveOnBrand;
|
|
991
1060
|
exports.toCssVars = toCssVars;
|
|
992
1061
|
exports.toRnTheme = toRnTheme;
|