@kya-os/consent 0.4.0 → 0.4.2
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 +186 -22
- package/dist/bundle/index.d.ts +9 -0
- package/dist/bundle/index.d.ts.map +1 -1
- package/dist/bundle/index.js +13 -0
- package/dist/bundle/index.js.map +1 -1
- package/dist/bundle/inline.d.ts.map +1 -1
- package/dist/bundle/inline.js +4 -4
- package/dist/bundle/inline.js.map +1 -1
- package/dist/cjs/bundle/index.js +36 -1
- package/dist/cjs/bundle/index.js.map +1 -1
- package/dist/cjs/bundle/inline.js +4 -4
- package/dist/cjs/bundle/inline.js.map +1 -1
- package/dist/cjs/components/consent-action-bar.js +97 -25
- package/dist/cjs/components/consent-action-bar.js.map +1 -1
- package/dist/cjs/components/consent-agent-header.js +7 -105
- package/dist/cjs/components/consent-agent-header.js.map +1 -1
- package/dist/cjs/components/consent-button.js +6 -1
- package/dist/cjs/components/consent-button.js.map +1 -1
- package/dist/cjs/components/consent-capabilities-screen.js +456 -117
- package/dist/cjs/components/consent-capabilities-screen.js.map +1 -1
- package/dist/cjs/components/consent-capability-card.js +159 -32
- package/dist/cjs/components/consent-capability-card.js.map +1 -1
- package/dist/cjs/components/consent-checkbox.js +7 -0
- package/dist/cjs/components/consent-checkbox.js.map +1 -1
- package/dist/cjs/components/consent-connector-header.js +262 -45
- package/dist/cjs/components/consent-connector-header.js.map +1 -1
- package/dist/cjs/components/consent-duration.js +1 -1
- package/dist/cjs/components/consent-flow-timeline.js +177 -0
- package/dist/cjs/components/consent-flow-timeline.js.map +1 -0
- package/dist/cjs/components/consent-flow.js +540 -0
- package/dist/cjs/components/consent-flow.js.map +1 -0
- package/dist/cjs/components/consent-footer.js +22 -14
- package/dist/cjs/components/consent-footer.js.map +1 -1
- package/dist/cjs/components/consent-headline.js +353 -33
- package/dist/cjs/components/consent-headline.js.map +1 -1
- package/dist/cjs/components/consent-oauth-button.js +68 -138
- package/dist/cjs/components/consent-oauth-button.js.map +1 -1
- package/dist/cjs/components/consent-otp-input.js +5 -0
- package/dist/cjs/components/consent-otp-input.js.map +1 -1
- package/dist/cjs/components/consent-phone-handoff.js +3 -3
- package/dist/cjs/components/consent-request-expiry.js +1 -1
- package/dist/cjs/components/consent-revocation-notice.js +29 -18
- package/dist/cjs/components/consent-revocation-notice.js.map +1 -1
- package/dist/cjs/components/consent-revoke.js +9 -4
- package/dist/cjs/components/consent-revoke.js.map +1 -1
- package/dist/cjs/components/consent-secured-by.js +106 -0
- package/dist/cjs/components/consent-secured-by.js.map +1 -0
- package/dist/cjs/components/consent-shell.js +1 -1
- package/dist/cjs/components/consent-terms.js +7 -0
- package/dist/cjs/components/consent-terms.js.map +1 -1
- package/dist/cjs/components/consent-wallet-check.js +26 -2
- package/dist/cjs/components/consent-wallet-check.js.map +1 -1
- package/dist/cjs/components/consent-wallet-notice.js +1 -1
- package/dist/cjs/components/consent-wallet-orb.js +1 -1
- package/dist/cjs/components/consent-wallet-signature.js +1 -1
- package/dist/cjs/components/decision-icons.js +37 -0
- package/dist/cjs/components/decision-icons.js.map +1 -0
- package/dist/cjs/components/edit-region.js +309 -0
- package/dist/cjs/components/edit-region.js.map +1 -0
- package/dist/cjs/components/flow-blocks.js +762 -0
- package/dist/cjs/components/flow-blocks.js.map +1 -0
- package/dist/cjs/components/flow-motion.js +177 -0
- package/dist/cjs/components/flow-motion.js.map +1 -0
- package/dist/cjs/components/grant-details.js +143 -0
- package/dist/cjs/components/grant-details.js.map +1 -0
- package/dist/cjs/components/grant-field-styles.js +2 -2
- package/dist/cjs/components/index.js +13 -1
- package/dist/cjs/components/index.js.map +1 -1
- package/dist/cjs/components/mcp-consent.js +93 -36
- package/dist/cjs/components/mcp-consent.js.map +1 -1
- package/dist/cjs/components/preview.js +67 -0
- package/dist/cjs/components/preview.js.map +1 -0
- package/dist/cjs/components/provider-icons.js +92 -0
- package/dist/cjs/components/provider-icons.js.map +1 -0
- package/dist/cjs/constants/capabilities.js +17 -2
- package/dist/cjs/constants/capabilities.js.map +1 -1
- package/dist/cjs/copy/tokens.js +67 -24
- package/dist/cjs/copy/tokens.js.map +1 -1
- package/dist/cjs/flow/copy.js +146 -0
- package/dist/cjs/flow/copy.js.map +1 -0
- package/dist/cjs/flow/index.js +31 -0
- package/dist/cjs/flow/index.js.map +1 -0
- package/dist/cjs/flow/model.js +107 -0
- package/dist/cjs/flow/model.js.map +1 -0
- package/dist/cjs/flow/presets.js +157 -0
- package/dist/cjs/flow/presets.js.map +1 -0
- package/dist/cjs/flow/schema.js +76 -0
- package/dist/cjs/flow/schema.js.map +1 -0
- package/dist/cjs/identity/agent-identity.js +3 -2
- package/dist/cjs/identity/agent-identity.js.map +1 -1
- package/dist/cjs/mcp-app/inline.js +2 -2
- package/dist/cjs/mcp-app/inline.js.map +1 -1
- package/dist/cjs/react/index.js +40 -2
- package/dist/cjs/react/index.js.map +1 -1
- package/dist/cjs/styles/brand.js +385 -0
- package/dist/cjs/styles/brand.js.map +1 -0
- package/dist/cjs/styles/index.js +1 -0
- package/dist/cjs/styles/index.js.map +1 -1
- package/dist/cjs/styles/theme.js +102 -30
- package/dist/cjs/styles/theme.js.map +1 -1
- package/dist/cjs/types/capabilities.types.js +1 -2
- package/dist/cjs/types/capabilities.types.js.map +1 -1
- package/dist/cjs/types/decision.types.js +13 -0
- package/dist/cjs/types/decision.types.js.map +1 -0
- package/dist/cjs/types/edit.types.js +80 -0
- package/dist/cjs/types/edit.types.js.map +1 -0
- package/dist/cjs/types/index.js +2 -0
- package/dist/cjs/types/index.js.map +1 -1
- package/dist/components/consent-action-bar.d.ts +20 -1
- package/dist/components/consent-action-bar.d.ts.map +1 -1
- package/dist/components/consent-action-bar.js +97 -25
- package/dist/components/consent-action-bar.js.map +1 -1
- package/dist/components/consent-agent-header.d.ts +4 -17
- package/dist/components/consent-agent-header.d.ts.map +1 -1
- package/dist/components/consent-agent-header.js +7 -105
- package/dist/components/consent-agent-header.js.map +1 -1
- package/dist/components/consent-button.d.ts +2 -0
- package/dist/components/consent-button.d.ts.map +1 -1
- package/dist/components/consent-button.js +6 -1
- package/dist/components/consent-button.js.map +1 -1
- package/dist/components/consent-capabilities-screen.d.ts +101 -17
- package/dist/components/consent-capabilities-screen.d.ts.map +1 -1
- package/dist/components/consent-capabilities-screen.js +457 -118
- package/dist/components/consent-capabilities-screen.js.map +1 -1
- package/dist/components/consent-capability-card.d.ts +32 -3
- package/dist/components/consent-capability-card.d.ts.map +1 -1
- package/dist/components/consent-capability-card.js +159 -32
- package/dist/components/consent-capability-card.js.map +1 -1
- package/dist/components/consent-checkbox.d.ts +2 -0
- package/dist/components/consent-checkbox.d.ts.map +1 -1
- package/dist/components/consent-checkbox.js +7 -0
- package/dist/components/consent-checkbox.js.map +1 -1
- package/dist/components/consent-connector-header.d.ts +52 -7
- package/dist/components/consent-connector-header.d.ts.map +1 -1
- package/dist/components/consent-connector-header.js +262 -45
- package/dist/components/consent-connector-header.js.map +1 -1
- package/dist/components/consent-duration.js +1 -1
- package/dist/components/consent-flow-timeline.d.ts +49 -0
- package/dist/components/consent-flow-timeline.d.ts.map +1 -0
- package/dist/components/consent-flow-timeline.js +174 -0
- package/dist/components/consent-flow-timeline.js.map +1 -0
- package/dist/components/consent-flow.d.ts +101 -0
- package/dist/components/consent-flow.d.ts.map +1 -0
- package/dist/components/consent-flow.js +504 -0
- package/dist/components/consent-flow.js.map +1 -0
- package/dist/components/consent-footer.d.ts +6 -4
- package/dist/components/consent-footer.d.ts.map +1 -1
- package/dist/components/consent-footer.js +22 -14
- package/dist/components/consent-footer.js.map +1 -1
- package/dist/components/consent-headline.d.ts +62 -16
- package/dist/components/consent-headline.d.ts.map +1 -1
- package/dist/components/consent-headline.js +352 -34
- package/dist/components/consent-headline.js.map +1 -1
- package/dist/components/consent-oauth-button.d.ts +9 -6
- package/dist/components/consent-oauth-button.d.ts.map +1 -1
- package/dist/components/consent-oauth-button.js +71 -141
- package/dist/components/consent-oauth-button.js.map +1 -1
- package/dist/components/consent-otp-input.d.ts.map +1 -1
- package/dist/components/consent-otp-input.js +5 -0
- package/dist/components/consent-otp-input.js.map +1 -1
- package/dist/components/consent-passkey.d.ts +6 -0
- package/dist/components/consent-passkey.d.ts.map +1 -1
- package/dist/components/consent-passkey.js +67 -9
- package/dist/components/consent-passkey.js.map +1 -1
- package/dist/components/consent-phone-handoff.js +3 -3
- package/dist/components/consent-request-expiry.js +1 -1
- package/dist/components/consent-revocation-notice.d.ts.map +1 -1
- package/dist/components/consent-revocation-notice.js +29 -18
- package/dist/components/consent-revocation-notice.js.map +1 -1
- package/dist/components/consent-revoke.d.ts +2 -0
- package/dist/components/consent-revoke.d.ts.map +1 -1
- package/dist/components/consent-revoke.js +9 -4
- package/dist/components/consent-revoke.js.map +1 -1
- package/dist/components/consent-secured-by.d.ts +25 -0
- package/dist/components/consent-secured-by.d.ts.map +1 -0
- package/dist/components/consent-secured-by.js +103 -0
- package/dist/components/consent-secured-by.js.map +1 -0
- package/dist/components/consent-shell.js +1 -1
- package/dist/components/consent-terms.d.ts +2 -0
- package/dist/components/consent-terms.d.ts.map +1 -1
- package/dist/components/consent-terms.js +7 -0
- package/dist/components/consent-terms.js.map +1 -1
- package/dist/components/consent-wallet-check.d.ts +8 -0
- package/dist/components/consent-wallet-check.d.ts.map +1 -1
- package/dist/components/consent-wallet-check.js +27 -3
- package/dist/components/consent-wallet-check.js.map +1 -1
- package/dist/components/consent-wallet-notice.js +1 -1
- package/dist/components/consent-wallet-orb.js +1 -1
- package/dist/components/consent-wallet-signature.js +1 -1
- package/dist/components/decision-icons.d.ts +26 -0
- package/dist/components/decision-icons.d.ts.map +1 -0
- package/dist/components/decision-icons.js +34 -0
- package/dist/components/decision-icons.js.map +1 -0
- package/dist/components/edit-region.d.ts +50 -0
- package/dist/components/edit-region.d.ts.map +1 -0
- package/dist/components/edit-region.js +305 -0
- package/dist/components/edit-region.js.map +1 -0
- package/dist/components/flow-blocks.d.ts +45 -0
- package/dist/components/flow-blocks.d.ts.map +1 -0
- package/dist/components/flow-blocks.js +755 -0
- package/dist/components/flow-blocks.js.map +1 -0
- package/dist/components/flow-motion.d.ts +41 -0
- package/dist/components/flow-motion.d.ts.map +1 -0
- package/dist/components/flow-motion.js +164 -0
- package/dist/components/flow-motion.js.map +1 -0
- package/dist/components/grant-details.d.ts +28 -0
- package/dist/components/grant-details.d.ts.map +1 -0
- package/dist/components/grant-details.js +138 -0
- package/dist/components/grant-details.js.map +1 -0
- package/dist/components/grant-field-styles.js +2 -2
- package/dist/components/index.d.ts +5 -1
- package/dist/components/index.d.ts.map +1 -1
- package/dist/components/index.js +5 -1
- package/dist/components/index.js.map +1 -1
- package/dist/components/mcp-consent.d.ts +19 -0
- package/dist/components/mcp-consent.d.ts.map +1 -1
- package/dist/components/mcp-consent.js +93 -36
- package/dist/components/mcp-consent.js.map +1 -1
- package/dist/components/preview.d.ts +38 -0
- package/dist/components/preview.d.ts.map +1 -0
- package/dist/components/preview.js +61 -0
- package/dist/components/preview.js.map +1 -0
- package/dist/components/provider-icons.d.ts +16 -0
- package/dist/components/provider-icons.d.ts.map +1 -0
- package/dist/components/provider-icons.js +88 -0
- package/dist/components/provider-icons.js.map +1 -0
- package/dist/consent.js +4875 -1178
- package/dist/consent.min.js +2367 -814
- package/dist/constants/capabilities.d.ts +16 -3
- package/dist/constants/capabilities.d.ts.map +1 -1
- package/dist/constants/capabilities.js +17 -2
- package/dist/constants/capabilities.js.map +1 -1
- package/dist/copy/tokens.d.ts +67 -24
- package/dist/copy/tokens.d.ts.map +1 -1
- package/dist/copy/tokens.js +67 -24
- package/dist/copy/tokens.js.map +1 -1
- package/dist/flow/copy.d.ts +31 -0
- package/dist/flow/copy.d.ts.map +1 -0
- package/dist/flow/copy.js +137 -0
- package/dist/flow/copy.js.map +1 -0
- package/dist/flow/index.d.ts +15 -0
- package/dist/flow/index.d.ts.map +1 -0
- package/dist/flow/index.js +15 -0
- package/dist/flow/index.js.map +1 -0
- package/dist/flow/model.d.ts +209 -0
- package/dist/flow/model.d.ts.map +1 -0
- package/dist/flow/model.js +103 -0
- package/dist/flow/model.js.map +1 -0
- package/dist/flow/presets.d.ts +29 -0
- package/dist/flow/presets.d.ts.map +1 -0
- package/dist/flow/presets.js +153 -0
- package/dist/flow/presets.js.map +1 -0
- package/dist/flow/schema.d.ts +127 -0
- package/dist/flow/schema.d.ts.map +1 -0
- package/dist/flow/schema.js +72 -0
- package/dist/flow/schema.js.map +1 -0
- package/dist/identity/agent-identity.d.ts +3 -2
- package/dist/identity/agent-identity.d.ts.map +1 -1
- package/dist/identity/agent-identity.js +3 -2
- package/dist/identity/agent-identity.js.map +1 -1
- package/dist/mcp-app/inline.d.ts.map +1 -1
- package/dist/mcp-app/inline.js +2 -2
- package/dist/mcp-app/inline.js.map +1 -1
- package/dist/react/index.d.ts +27 -1
- package/dist/react/index.d.ts.map +1 -1
- package/dist/react/index.js +39 -1
- package/dist/react/index.js.map +1 -1
- package/dist/styles/brand.d.ts +184 -0
- package/dist/styles/brand.d.ts.map +1 -0
- package/dist/styles/brand.js +372 -0
- package/dist/styles/brand.js.map +1 -0
- package/dist/styles/index.d.ts +1 -0
- package/dist/styles/index.d.ts.map +1 -1
- package/dist/styles/index.js +1 -0
- package/dist/styles/index.js.map +1 -1
- package/dist/styles/theme.d.ts +76 -13
- package/dist/styles/theme.d.ts.map +1 -1
- package/dist/styles/theme.js +98 -29
- package/dist/styles/theme.js.map +1 -1
- package/dist/types/capabilities.types.d.ts +12 -14
- package/dist/types/capabilities.types.d.ts.map +1 -1
- package/dist/types/capabilities.types.js +1 -2
- package/dist/types/capabilities.types.js.map +1 -1
- package/dist/types/decision.types.d.ts +57 -0
- package/dist/types/decision.types.d.ts.map +1 -0
- package/dist/types/decision.types.js +12 -0
- package/dist/types/decision.types.js.map +1 -0
- package/dist/types/edit.types.d.ts +73 -0
- package/dist/types/edit.types.d.ts.map +1 -0
- package/dist/types/edit.types.js +76 -0
- package/dist/types/edit.types.js.map +1 -0
- package/dist/types/index.d.ts +2 -0
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/index.js +2 -0
- package/dist/types/index.js.map +1 -1
- package/package.json +10 -5
|
@@ -0,0 +1,372 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Brand Colors on the Consent Screens
|
|
3
|
+
*
|
|
4
|
+
* A host's brand is operator data: a primary color, maybe a secondary, and
|
|
5
|
+
* maybe the page's own colors (card, panel, border, text, quieter text, focus
|
|
6
|
+
* ring). These turn it into the `--cs-*` properties the screens read, each
|
|
7
|
+
* one checked so it reads:
|
|
8
|
+
*
|
|
9
|
+
* - a word in the brand (an action) reaches 4.5:1 (WCAG 1.4.3) on the card
|
|
10
|
+
* and on the brand's tint, else it is drawn in the text color;
|
|
11
|
+
* - a mark or focus ring in the brand reaches 3:1 (WCAG 1.4.11), else the
|
|
12
|
+
* text color;
|
|
13
|
+
* - an icon in the secondary keeps its hue and moves darker or lighter,
|
|
14
|
+
* whichever is nearer, until it reaches 3:1 on every surface an icon sits on;
|
|
15
|
+
* - a page color that would not read is dropped, and the theme's is drawn.
|
|
16
|
+
*
|
|
17
|
+
* `brandTokens(brand)` returns the properties; set them on any element above
|
|
18
|
+
* the screens (a style attribute is enough) and the screens take them.
|
|
19
|
+
* Everything here is pure: importing it defines no element.
|
|
20
|
+
*
|
|
21
|
+
* Unless a brand chooses its own page colors, these judge against the light
|
|
22
|
+
* theme's surfaces.
|
|
23
|
+
*
|
|
24
|
+
* @module @kya-os/consent/styles/brand
|
|
25
|
+
*/
|
|
26
|
+
import { contrastRatio, isHexColor, relativeLuminance } from "./contrast.js";
|
|
27
|
+
import { TINT_LINE_PERCENT, TINT_PERCENT, lightTheme } from "./theme.js";
|
|
28
|
+
/** WCAG 1.4.11's ratio for a graphic or a focus indicator. */
|
|
29
|
+
export const AA_GRAPHIC_CONTRAST = 3;
|
|
30
|
+
/** WCAG 1.4.3's ratio for text at body size. */
|
|
31
|
+
const TEXT_CONTRAST = 4.5;
|
|
32
|
+
/** The share of the primary in an icon's tile. */
|
|
33
|
+
export const ICON_TILE_PERCENT = 8;
|
|
34
|
+
/** The share of the primary in a hovered row under that tile. */
|
|
35
|
+
export const HOVERED_ROW_PERCENT = 4;
|
|
36
|
+
/** The share of the text in the quieter text the page draws from it. */
|
|
37
|
+
export const MUTED_TEXT_PERCENT = 64;
|
|
38
|
+
/** The share of the text in a panel made for a chosen card with no panel chosen. */
|
|
39
|
+
export const PANEL_TINT_PERCENT = 4;
|
|
40
|
+
/** How far each try lowers an icon's lightness: about 0.03 of contrast. */
|
|
41
|
+
const LIGHTNESS_STEP = 0.005;
|
|
42
|
+
/** The light theme's own colors, all `#rrggbb`. */
|
|
43
|
+
export const LIGHT_DRAWN_COLORS = Object.freeze({
|
|
44
|
+
surface: lightTheme.surfaceCard,
|
|
45
|
+
panel: lightTheme.surfaceInset,
|
|
46
|
+
text: lightTheme.textPrimary,
|
|
47
|
+
mutedText: lightTheme.textTertiary,
|
|
48
|
+
});
|
|
49
|
+
/** The page colors a brand may choose, one color per field. */
|
|
50
|
+
export const PALETTE_FIELDS = [
|
|
51
|
+
"surfaceColor",
|
|
52
|
+
"panelColor",
|
|
53
|
+
"borderColor",
|
|
54
|
+
"textColor",
|
|
55
|
+
"mutedTextColor",
|
|
56
|
+
"focusColor",
|
|
57
|
+
];
|
|
58
|
+
function rgbOf(hex) {
|
|
59
|
+
return [1, 3, 5].map((at) => Number.parseInt(hex.slice(at, at + 2), 16));
|
|
60
|
+
}
|
|
61
|
+
function hexOf(channels) {
|
|
62
|
+
return `#${channels
|
|
63
|
+
.map((value) => Math.round(value).toString(16).padStart(2, "0"))
|
|
64
|
+
.join("")}`;
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* `top` at `percent` over the opaque `under`, as a browser composites it
|
|
68
|
+
* (both `#rrggbb`).
|
|
69
|
+
*
|
|
70
|
+
* @example
|
|
71
|
+
* mixOver("#000000", 50, "#ffffff"); // "#808080"
|
|
72
|
+
*/
|
|
73
|
+
export function mixOver(top, percent, under) {
|
|
74
|
+
const share = percent / 100;
|
|
75
|
+
const below = rgbOf(under);
|
|
76
|
+
return hexOf(rgbOf(top).map((above, i) => above * share + below[i] * (1 - share)));
|
|
77
|
+
}
|
|
78
|
+
function hslOf(hex) {
|
|
79
|
+
const [red, green, blue] = rgbOf(hex).map((value) => value / 255);
|
|
80
|
+
const high = Math.max(red, green, blue);
|
|
81
|
+
const low = Math.min(red, green, blue);
|
|
82
|
+
const spread = high - low;
|
|
83
|
+
const lightness = (high + low) / 2;
|
|
84
|
+
if (spread === 0)
|
|
85
|
+
return { hue: 0, saturation: 0, lightness };
|
|
86
|
+
const saturation = spread / (1 - Math.abs(2 * lightness - 1));
|
|
87
|
+
const sector = high === red
|
|
88
|
+
? (green - blue) / spread
|
|
89
|
+
: high === green
|
|
90
|
+
? (blue - red) / spread + 2
|
|
91
|
+
: (red - green) / spread + 4;
|
|
92
|
+
return { hue: (sector * 60 + 360) % 360, saturation, lightness };
|
|
93
|
+
}
|
|
94
|
+
function hexFromHsl({ hue, saturation, lightness }) {
|
|
95
|
+
const reach = saturation * Math.min(lightness, 1 - lightness);
|
|
96
|
+
const channel = (offset) => {
|
|
97
|
+
const turn = (offset + hue / 30) % 12;
|
|
98
|
+
return ((lightness - reach * Math.max(-1, Math.min(turn - 3, 9 - turn, 1))) * 255);
|
|
99
|
+
};
|
|
100
|
+
return hexOf([channel(0), channel(8), channel(4)]);
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* What an icon is drawn in, for a chosen secondary (`hex`) under a primary:
|
|
104
|
+
* the secondary itself when it shows at 3:1 on everything an icon sits on
|
|
105
|
+
* (the card, the panel, and the primary's icon tile at rest and on a hovered
|
|
106
|
+
* row), else the same hue and saturation at the nearest lightness that does,
|
|
107
|
+
* darker or lighter. Light surfaces push it darker and dark ones lighter, so a
|
|
108
|
+
* dark palette gets a light icon. When no lightness shows on all of them, the
|
|
109
|
+
* icon is black or white, whichever reads better on the worst of them.
|
|
110
|
+
*
|
|
111
|
+
* @example
|
|
112
|
+
* iconColorFor("#1e3a5f", "#111111"); // "#1e3a5f", it already shows
|
|
113
|
+
* iconColorFor("#b08d57", "#111111"); // a darker gold
|
|
114
|
+
* iconColorFor("#333344", "#2563eb", { surface: "#1b1d24", panel: "#25272e" });
|
|
115
|
+
* // a lighter slate
|
|
116
|
+
*/
|
|
117
|
+
export function iconColorFor(hex, primary, drawn = LIGHT_DRAWN_COLORS) {
|
|
118
|
+
const hoveredRow = mixOver(primary, HOVERED_ROW_PERCENT, drawn.surface);
|
|
119
|
+
const surfaces = [
|
|
120
|
+
drawn.surface,
|
|
121
|
+
drawn.panel,
|
|
122
|
+
mixOver(primary, ICON_TILE_PERCENT, drawn.surface),
|
|
123
|
+
mixOver(primary, ICON_TILE_PERCENT, hoveredRow),
|
|
124
|
+
];
|
|
125
|
+
const worstRatio = (candidate) => Math.min(...surfaces.map((surface) => contrastRatio(candidate, surface)));
|
|
126
|
+
if (worstRatio(hex) >= AA_GRAPHIC_CONTRAST)
|
|
127
|
+
return hex;
|
|
128
|
+
// Step away from the chosen lightness both ways at once, darker first, so
|
|
129
|
+
// the first lightness that shows is the nearest one.
|
|
130
|
+
const start = hslOf(hex);
|
|
131
|
+
for (let steps = 1; steps * LIGHTNESS_STEP <= 1; steps++) {
|
|
132
|
+
for (const lightness of [
|
|
133
|
+
start.lightness - steps * LIGHTNESS_STEP,
|
|
134
|
+
start.lightness + steps * LIGHTNESS_STEP,
|
|
135
|
+
]) {
|
|
136
|
+
if (lightness < 0 || lightness > 1)
|
|
137
|
+
continue;
|
|
138
|
+
const candidate = hexFromHsl({ ...start, lightness });
|
|
139
|
+
if (worstRatio(candidate) >= AA_GRAPHIC_CONTRAST)
|
|
140
|
+
return candidate;
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
return worstRatio("#000000") >= worstRatio("#ffffff") ? "#000000" : "#ffffff";
|
|
144
|
+
}
|
|
145
|
+
/**
|
|
146
|
+
* What a focus ring on the card is drawn in: the brand when it shows on the
|
|
147
|
+
* card at 3:1, else the text color. A light brand (#ffd23f is 1.44:1 on
|
|
148
|
+
* white) gets the text color.
|
|
149
|
+
*
|
|
150
|
+
* @example
|
|
151
|
+
* focusRingFor("#1e3a5f"); // "brand"
|
|
152
|
+
* focusRingFor("#ffd23f"); // "ink"
|
|
153
|
+
*/
|
|
154
|
+
export function focusRingFor(hex, surface = LIGHT_DRAWN_COLORS.surface) {
|
|
155
|
+
return contrastRatio(hex, surface) >= AA_GRAPHIC_CONTRAST ? "brand" : "ink";
|
|
156
|
+
}
|
|
157
|
+
/** Whether `hex` reaches `ratio` on the card and on its own tint over the card. */
|
|
158
|
+
function readsOnCardAndTint(hex, ratio, surface) {
|
|
159
|
+
const tint = mixOver(hex, TINT_PERCENT, surface);
|
|
160
|
+
return (contrastRatio(hex, surface) >= ratio && contrastRatio(hex, tint) >= ratio);
|
|
161
|
+
}
|
|
162
|
+
/**
|
|
163
|
+
* What words in the brand are drawn in (a link, the agent's name): the brand
|
|
164
|
+
* when it reads at 4.5:1 on the card and on its tint, else the text color.
|
|
165
|
+
*
|
|
166
|
+
* @example
|
|
167
|
+
* actionColorFor("#1e3a5f"); // "brand"
|
|
168
|
+
* actionColorFor("#2b9348"); // "ink", 3.91:1 on white
|
|
169
|
+
*/
|
|
170
|
+
export function actionColorFor(hex, surface = LIGHT_DRAWN_COLORS.surface) {
|
|
171
|
+
return readsOnCardAndTint(hex, TEXT_CONTRAST, surface) ? "brand" : "ink";
|
|
172
|
+
}
|
|
173
|
+
/**
|
|
174
|
+
* What marks in the brand are drawn in (a shield, the icons in the details):
|
|
175
|
+
* the brand when it shows at 3:1 on the card and on its tint, else the text
|
|
176
|
+
* color.
|
|
177
|
+
*
|
|
178
|
+
* @example
|
|
179
|
+
* markColorFor("#2b9348"); // "brand", 3.91:1 on white
|
|
180
|
+
* markColorFor("#ffd23f"); // "ink"
|
|
181
|
+
*/
|
|
182
|
+
export function markColorFor(hex, surface = LIGHT_DRAWN_COLORS.surface) {
|
|
183
|
+
return readsOnCardAndTint(hex, AA_GRAPHIC_CONTRAST, surface)
|
|
184
|
+
? "brand"
|
|
185
|
+
: "ink";
|
|
186
|
+
}
|
|
187
|
+
/** Black or white, whichever reads better on `hex`; a tie gives black. */
|
|
188
|
+
export function onPrimaryFor(hex) {
|
|
189
|
+
const luminance = relativeLuminance(hex);
|
|
190
|
+
const againstWhite = 1.05 / (luminance + 0.05);
|
|
191
|
+
const againstBlack = (luminance + 0.05) / 0.05;
|
|
192
|
+
return againstBlack >= againstWhite ? "black" : "white";
|
|
193
|
+
}
|
|
194
|
+
/**
|
|
195
|
+
* The panel drawn inside the card: a chosen panel as it is; with none, the
|
|
196
|
+
* theme's own when the card is the theme's too, else the text at
|
|
197
|
+
* {@link PANEL_TINT_PERCENT} over the chosen card, so a chosen card never
|
|
198
|
+
* sits around a panel it was not chosen for.
|
|
199
|
+
*/
|
|
200
|
+
function panelOf(palette, text, drawn) {
|
|
201
|
+
if (palette.panelColor)
|
|
202
|
+
return palette.panelColor;
|
|
203
|
+
if (palette.surfaceColor)
|
|
204
|
+
return mixOver(text, PANEL_TINT_PERCENT, palette.surfaceColor);
|
|
205
|
+
return drawn.panel;
|
|
206
|
+
}
|
|
207
|
+
/** The quieter text drawn on `background`. */
|
|
208
|
+
function mutedOn(palette, background, drawn) {
|
|
209
|
+
if (palette.mutedTextColor)
|
|
210
|
+
return palette.mutedTextColor;
|
|
211
|
+
if (palette.textColor)
|
|
212
|
+
return mixOver(palette.textColor, MUTED_TEXT_PERCENT, background);
|
|
213
|
+
return drawn.mutedText;
|
|
214
|
+
}
|
|
215
|
+
/** A ratio rounded down to two places: 4.4995 is 4.49, never 4.50. */
|
|
216
|
+
function floorToHundredths(ratio) {
|
|
217
|
+
return Math.floor(ratio * 100) / 100;
|
|
218
|
+
}
|
|
219
|
+
/**
|
|
220
|
+
* Every pair of the page's colors that would not read: the text and the
|
|
221
|
+
* quieter text at 4.5:1 and the focus ring at 3:1, each on the card and on
|
|
222
|
+
* the panel. A color the brand did not choose is judged as the page draws it
|
|
223
|
+
* (`drawn`, the light theme unless given). The border is decorative and has
|
|
224
|
+
* no ratio to meet.
|
|
225
|
+
*
|
|
226
|
+
* An editor can use the list to refuse a pair before it is saved;
|
|
227
|
+
* `drawablePalette` drops what fails.
|
|
228
|
+
*
|
|
229
|
+
* @example
|
|
230
|
+
* paletteFailures({ surfaceColor: "#f8f5f0", textColor: "#2f3440", mutedTextColor: "#5a5f6a" });
|
|
231
|
+
* // []
|
|
232
|
+
* paletteFailures({ surfaceColor: "#1b1d24" });
|
|
233
|
+
* // [{ foreground: "textColor", background: "surfaceColor", ratio: 1.11, needs: 4.5 }, ...]
|
|
234
|
+
*/
|
|
235
|
+
export function paletteFailures(palette, drawn = {}) {
|
|
236
|
+
const colors = { ...LIGHT_DRAWN_COLORS, ...drawn };
|
|
237
|
+
const text = palette.textColor ?? colors.text;
|
|
238
|
+
const backgrounds = [
|
|
239
|
+
{
|
|
240
|
+
background: "surfaceColor",
|
|
241
|
+
color: palette.surfaceColor ?? colors.surface,
|
|
242
|
+
},
|
|
243
|
+
{ background: "panelColor", color: panelOf(palette, text, colors) },
|
|
244
|
+
];
|
|
245
|
+
return backgrounds.flatMap(({ background, color }) => {
|
|
246
|
+
const pairs = [
|
|
247
|
+
{ foreground: "textColor", color: text, needs: TEXT_CONTRAST },
|
|
248
|
+
{
|
|
249
|
+
foreground: "mutedTextColor",
|
|
250
|
+
color: mutedOn(palette, color, colors),
|
|
251
|
+
needs: TEXT_CONTRAST,
|
|
252
|
+
},
|
|
253
|
+
...(palette.focusColor
|
|
254
|
+
? [
|
|
255
|
+
{
|
|
256
|
+
foreground: "focusColor",
|
|
257
|
+
color: palette.focusColor,
|
|
258
|
+
needs: AA_GRAPHIC_CONTRAST,
|
|
259
|
+
},
|
|
260
|
+
]
|
|
261
|
+
: []),
|
|
262
|
+
];
|
|
263
|
+
return pairs.flatMap(({ foreground, color: ink, needs }) => {
|
|
264
|
+
const ratio = contrastRatio(ink, color);
|
|
265
|
+
return ratio >= needs
|
|
266
|
+
? []
|
|
267
|
+
: [{ foreground, background, ratio: floorToHundredths(ratio), needs }];
|
|
268
|
+
});
|
|
269
|
+
});
|
|
270
|
+
}
|
|
271
|
+
/**
|
|
272
|
+
* The part of a chosen palette the page can draw. The card, the panel and the
|
|
273
|
+
* text on them stand or fall together: dropping one alone could leave the
|
|
274
|
+
* rest unreadable (light text kept on a dark card that was dropped), so a
|
|
275
|
+
* failing pair among them leaves the theme's look for all four. The focus
|
|
276
|
+
* ring is then judged on what is kept, and dropped alone. The border needs no
|
|
277
|
+
* ratio.
|
|
278
|
+
*/
|
|
279
|
+
export function drawablePalette(chosen, drawn = {}) {
|
|
280
|
+
const { focusColor, borderColor, ...surfacesAndText } = chosen;
|
|
281
|
+
const kept = paletteFailures(surfacesAndText, drawn).length === 0 ? surfacesAndText : {};
|
|
282
|
+
const focusShows = focusColor !== undefined &&
|
|
283
|
+
paletteFailures({ ...kept, focusColor }, drawn).length === 0;
|
|
284
|
+
return {
|
|
285
|
+
...kept,
|
|
286
|
+
...(borderColor ? { borderColor } : {}),
|
|
287
|
+
...(focusShows ? { focusColor } : {}),
|
|
288
|
+
};
|
|
289
|
+
}
|
|
290
|
+
/**
|
|
291
|
+
* The custom properties that draw a brand on the consent screens. Set them on
|
|
292
|
+
* any element above the screens: the screens take a property the page sets
|
|
293
|
+
* over their theme's own.
|
|
294
|
+
*
|
|
295
|
+
* - The brand fills the primary action and the selected checkboxes, with
|
|
296
|
+
* black or white on it, whichever reads.
|
|
297
|
+
* - The tint (`--cs-tint`, `--cs-tint-line`) is the brand over the card.
|
|
298
|
+
* - Marks, actions (and `--consent-link`, the older primitives' links) and
|
|
299
|
+
* the focus ring are the brand where it reads, else the text color.
|
|
300
|
+
* - Icons are the secondary, made darker or lighter to read, when the brand
|
|
301
|
+
* has one.
|
|
302
|
+
* - The page colors are drawn where they read ({@link drawablePalette}).
|
|
303
|
+
*
|
|
304
|
+
* @throws RangeError when a color is not `#rrggbb`.
|
|
305
|
+
*
|
|
306
|
+
* @example
|
|
307
|
+
* brandTokens({ primaryColor: "#1e3a5f" });
|
|
308
|
+
* // { "--consent-primary": "#1e3a5f", "--cs-surface-accent": "#1e3a5f",
|
|
309
|
+
* // "--cs-tint": "#eef0f3", "--cs-mark": "#1e3a5f", ... }
|
|
310
|
+
*/
|
|
311
|
+
export function brandTokens(brand) {
|
|
312
|
+
for (const [field, value] of Object.entries(brand)) {
|
|
313
|
+
if (value !== undefined && !isHexColor(value)) {
|
|
314
|
+
throw new RangeError(`${field} must be a #rrggbb color, got ${JSON.stringify(value)}`);
|
|
315
|
+
}
|
|
316
|
+
}
|
|
317
|
+
const { primaryColor: primary, secondaryColor, ...chosen } = brand;
|
|
318
|
+
const palette = drawablePalette(chosen);
|
|
319
|
+
const surface = palette.surfaceColor ?? LIGHT_DRAWN_COLORS.surface;
|
|
320
|
+
const panel = panelOf(palette, palette.textColor ?? LIGHT_DRAWN_COLORS.text, LIGHT_DRAWN_COLORS);
|
|
321
|
+
const ink = palette.textColor ?? LIGHT_DRAWN_COLORS.text;
|
|
322
|
+
const onPrimary = onPrimaryFor(primary);
|
|
323
|
+
const inBrand = (pick) => (pick === "brand" ? primary : ink);
|
|
324
|
+
const tokens = {
|
|
325
|
+
"--consent-primary": primary,
|
|
326
|
+
"--consent-on-primary": onPrimary,
|
|
327
|
+
"--consent-link": inBrand(actionColorFor(primary, surface)),
|
|
328
|
+
"--cs-surface-accent": primary,
|
|
329
|
+
"--cs-surface-accent-text": onPrimary,
|
|
330
|
+
"--cs-tint": mixOver(primary, TINT_PERCENT, surface),
|
|
331
|
+
"--cs-tint-line": mixOver(primary, TINT_LINE_PERCENT, surface),
|
|
332
|
+
"--cs-mark": inBrand(markColorFor(primary, surface)),
|
|
333
|
+
"--cs-action": inBrand(actionColorFor(primary, surface)),
|
|
334
|
+
"--cs-focus-ring": palette.focusColor ?? inBrand(focusRingFor(primary, surface)),
|
|
335
|
+
};
|
|
336
|
+
if (secondaryColor) {
|
|
337
|
+
tokens["--cs-icon"] = iconColorFor(secondaryColor, primary, {
|
|
338
|
+
surface,
|
|
339
|
+
panel,
|
|
340
|
+
});
|
|
341
|
+
}
|
|
342
|
+
if (palette.surfaceColor)
|
|
343
|
+
tokens["--cs-surface-card"] = palette.surfaceColor;
|
|
344
|
+
if (palette.surfaceColor || palette.panelColor)
|
|
345
|
+
tokens["--cs-surface-inset"] = panel;
|
|
346
|
+
if (palette.borderColor)
|
|
347
|
+
tokens["--cs-surface-border"] = palette.borderColor;
|
|
348
|
+
if (palette.textColor) {
|
|
349
|
+
tokens["--cs-text-primary"] = palette.textColor;
|
|
350
|
+
tokens["--cs-text-secondary"] = palette.textColor;
|
|
351
|
+
}
|
|
352
|
+
if (palette.mutedTextColor) {
|
|
353
|
+
tokens["--cs-text-tertiary"] = palette.mutedTextColor;
|
|
354
|
+
}
|
|
355
|
+
else if (palette.textColor) {
|
|
356
|
+
tokens["--cs-text-tertiary"] =
|
|
357
|
+
`color-mix(in srgb, ${palette.textColor} ${MUTED_TEXT_PERCENT}%, transparent)`;
|
|
358
|
+
}
|
|
359
|
+
return tokens;
|
|
360
|
+
}
|
|
361
|
+
/**
|
|
362
|
+
* `brandTokens(brand)` as a declaration list for a style attribute.
|
|
363
|
+
*
|
|
364
|
+
* @example
|
|
365
|
+
* `<main style="${brandStyle({ primaryColor: "#1e3a5f" })}">`
|
|
366
|
+
*/
|
|
367
|
+
export function brandStyle(brand) {
|
|
368
|
+
return Object.entries(brandTokens(brand))
|
|
369
|
+
.map(([property, value]) => `${property}: ${value};`)
|
|
370
|
+
.join(" ");
|
|
371
|
+
}
|
|
372
|
+
//# sourceMappingURL=brand.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"brand.js","sourceRoot":"","sources":["../../src/styles/brand.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AAEH,OAAO,E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QAC5C,MAAM,CAAC,oBAAoB,CAAC,GAAG,KAAK,CAAC;IACvC,IAAI,OAAO,CAAC,WAAW;QAAE,MAAM,CAAC,qBAAqB,CAAC,GAAG,OAAO,CAAC,WAAW,CAAC;IAC7E,IAAI,OAAO,CAAC,SAAS,EAAE,CAAC;QACtB,MAAM,CAAC,mBAAmB,CAAC,GAAG,OAAO,CAAC,SAAS,CAAC;QAChD,MAAM,CAAC,qBAAqB,CAAC,GAAG,OAAO,CAAC,SAAS,CAAC;IACpD,CAAC;IACD,IAAI,OAAO,CAAC,cAAc,EAAE,CAAC;QAC3B,MAAM,CAAC,oBAAoB,CAAC,GAAG,OAAO,CAAC,cAAc,CAAC;IACxD,CAAC;SAAM,IAAI,OAAO,CAAC,SAAS,EAAE,CAAC;QAC7B,MAAM,CAAC,oBAAoB,CAAC;YAC1B,sBAAsB,OAAO,CAAC,SAAS,IAAI,kBAAkB,iBAAiB,CAAC;IACnF,CAAC;IACD,OAAO,MAAM,CAAC;AAChB,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,UAAU,CAAC,KAAyB;IAClD,OAAO,MAAM,CAAC,OAAO,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC;SACtC,GAAG,CAAC,CAAC,CAAC,QAAQ,EAAE,KAAK,CAAC,EAAE,EAAE,CAAC,GAAG,QAAQ,KAAK,KAAK,GAAG,CAAC;SACpD,IAAI,CAAC,GAAG,CAAC,CAAC;AACf,CAAC"}
|
package/dist/styles/index.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/styles/index.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,cAAc,aAAa,CAAC;AAC5B,cAAc,eAAe,CAAC;AAC9B,cAAc,oBAAoB,CAAC;AACnC,cAAc,iBAAiB,CAAC;AAChC,cAAc,YAAY,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/styles/index.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,cAAc,aAAa,CAAC;AAC5B,cAAc,eAAe,CAAC;AAC9B,cAAc,oBAAoB,CAAC;AACnC,cAAc,iBAAiB,CAAC;AAChC,cAAc,YAAY,CAAC;AAC3B,cAAc,YAAY,CAAC"}
|
package/dist/styles/index.js
CHANGED
package/dist/styles/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/styles/index.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,cAAc,aAAa,CAAC;AAC5B,cAAc,eAAe,CAAC;AAC9B,cAAc,oBAAoB,CAAC;AACnC,cAAc,iBAAiB,CAAC;AAChC,cAAc,YAAY,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/styles/index.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,cAAc,aAAa,CAAC;AAC5B,cAAc,eAAe,CAAC;AAC9B,cAAc,oBAAoB,CAAC;AACnC,cAAc,iBAAiB,CAAC;AAChC,cAAc,YAAY,CAAC;AAC3B,cAAc,YAAY,CAAC"}
|
package/dist/styles/theme.d.ts
CHANGED
|
@@ -13,8 +13,8 @@
|
|
|
13
13
|
* primary button can adopt operator brand color while the rest of the
|
|
14
14
|
* surface stays in the chosen theme.
|
|
15
15
|
*
|
|
16
|
-
* The
|
|
17
|
-
*
|
|
16
|
+
* The `HIGHER RISK` chip is amber in both themes, whatever the org's brand:
|
|
17
|
+
* a soft warning amber on the light card, and a solid amber on the dark one.
|
|
18
18
|
*
|
|
19
19
|
* The agent logo tile tokens are fixed across themes too: agent artwork is
|
|
20
20
|
* drawn on a white tile with a light border in both themes, so a logo never
|
|
@@ -49,15 +49,7 @@ export interface ConsentThemeTokens {
|
|
|
49
49
|
surfaceAccent: string;
|
|
50
50
|
/** Primary action text color. */
|
|
51
51
|
surfaceAccentText: string;
|
|
52
|
-
/**
|
|
53
|
-
pillVerifiedBg: string;
|
|
54
|
-
/** Verified pill text color. */
|
|
55
|
-
pillVerifiedText: string;
|
|
56
|
-
/** Unverified pill background. */
|
|
57
|
-
pillUnverifiedBg: string;
|
|
58
|
-
/** Unverified pill text color. */
|
|
59
|
-
pillUnverifiedText: string;
|
|
60
|
-
/** HIGHER RISK chip background. Fixed amber across themes. */
|
|
52
|
+
/** HIGHER RISK chip background. Amber in both themes. */
|
|
61
53
|
chipRiskBg: string;
|
|
62
54
|
/** HIGHER RISK chip text color. */
|
|
63
55
|
chipRiskText: string;
|
|
@@ -82,7 +74,47 @@ export interface ConsentThemeTokens {
|
|
|
82
74
|
* Optional: defaults to `#0F172A` when a theme omits it.
|
|
83
75
|
*/
|
|
84
76
|
agentTileText?: string;
|
|
77
|
+
/**
|
|
78
|
+
* A light wash of the brand for tinted boxes and the bridge connector's
|
|
79
|
+
* shield. Optional: defaults to the primary text at 4% over the card, a
|
|
80
|
+
* neutral wash, until a brand sets it (`consentBrandStyle`).
|
|
81
|
+
*/
|
|
82
|
+
tint?: string;
|
|
83
|
+
/** The edge of a tinted box. Optional: the primary text at 11% over the card. */
|
|
84
|
+
tintLine?: string;
|
|
85
|
+
/**
|
|
86
|
+
* Marks drawn in the brand, such as the bridge connector's shield: a graphic,
|
|
87
|
+
* so it needs 3:1 on the card and the tint. Optional: the primary text.
|
|
88
|
+
*/
|
|
89
|
+
mark?: string;
|
|
90
|
+
/**
|
|
91
|
+
* Words drawn in the brand, such as a link that starts a check: text, so it
|
|
92
|
+
* needs 4.5:1 on the card and the tint. Optional: the primary text.
|
|
93
|
+
*/
|
|
94
|
+
action?: string;
|
|
95
|
+
/**
|
|
96
|
+
* The Vouched lockup under the capabilities screen's card. Optional: the
|
|
97
|
+
* primary text; the light theme draws it in Vouched blue.
|
|
98
|
+
*/
|
|
99
|
+
lockup?: string;
|
|
100
|
+
/**
|
|
101
|
+
* Warning words on the card, such as "Unverified agent".
|
|
102
|
+
* Optional: the text color.
|
|
103
|
+
*/
|
|
104
|
+
warningText?: string;
|
|
85
105
|
}
|
|
106
|
+
/**
|
|
107
|
+
* The share of the brand (or the text, with no brand) in a tinted box: light
|
|
108
|
+
* enough that a box reads as a panel, not as something disabled.
|
|
109
|
+
*/
|
|
110
|
+
export declare const TINT_PERCENT = 4;
|
|
111
|
+
/** The share of the brand (or the text) in a tinted box's edge, which carries the box. */
|
|
112
|
+
export declare const TINT_LINE_PERCENT = 11;
|
|
113
|
+
/**
|
|
114
|
+
* The light theme. Its quietest text reaches 4.5:1 on the cream inset panel
|
|
115
|
+
* (4.54:1) as well as on the card, and its focus ring 3:1 on both, the
|
|
116
|
+
* ratios WCAG 1.4.3 and 1.4.11 ask for.
|
|
117
|
+
*/
|
|
86
118
|
export declare const lightTheme: ConsentThemeTokens;
|
|
87
119
|
export declare const darkTheme: ConsentThemeTokens;
|
|
88
120
|
/**
|
|
@@ -92,12 +124,43 @@ export declare function getConsentTheme(theme: ConsentTheme | undefined): Consen
|
|
|
92
124
|
/**
|
|
93
125
|
* Render a theme as a CSS string suitable for injecting into a `<style>` block
|
|
94
126
|
* or `:host { ... }` rule. Each token becomes a `--cs-{kebab}` custom property.
|
|
95
|
-
*
|
|
96
|
-
*
|
|
127
|
+
* Tokens a theme omits (or sets to undefined) are emitted with their fixed or
|
|
128
|
+
* derived values ({@link resolveThemeTokens}), so the output never contains
|
|
129
|
+
* "undefined".
|
|
97
130
|
*
|
|
98
131
|
* @example
|
|
99
132
|
* themeToCssVariables(lightTheme);
|
|
100
133
|
* // " --cs-surface-bg: #F4F1EA;\n ... \n --cs-agent-tile-bg: #FFFFFF;\n ..."
|
|
101
134
|
*/
|
|
102
135
|
export declare function themeToCssVariables(tokens: ConsentThemeTokens): string;
|
|
136
|
+
/**
|
|
137
|
+
* Every token of `tokens`, with the optional ones a theme omits filled in:
|
|
138
|
+
* the fixed agent tile, and a tint, mark and action color made from the
|
|
139
|
+
* theme's own text and card.
|
|
140
|
+
*/
|
|
141
|
+
export declare function resolveThemeTokens(tokens: ConsentThemeTokens): Required<ConsentThemeTokens>;
|
|
142
|
+
/**
|
|
143
|
+
* The CSS that themes an element's shadow tree while letting the page win: a
|
|
144
|
+
* `--cs-*` property the page sets, on the element or on any ancestor, is used
|
|
145
|
+
* as it is, and every other one comes from `tokens`.
|
|
146
|
+
*
|
|
147
|
+
* The element resolves each token once on `:host`, under a private name
|
|
148
|
+
* (`--_cs-*`), then publishes it under its public name on `scope`, the top
|
|
149
|
+
* elements of its shadow tree, so everything inside reads the public name as
|
|
150
|
+
* before. (The private step is what lets the public name take the page's
|
|
151
|
+
* value: a property cannot refer to itself.) A derived token the page does
|
|
152
|
+
* not set, such as the tint, is made from the resolved tokens, so a page that
|
|
153
|
+
* sets only its text and card colors gets a tint of those.
|
|
154
|
+
*
|
|
155
|
+
* @param tokens - The theme the element draws where the page sets nothing.
|
|
156
|
+
* @param scope - A selector list for the top elements of the shadow tree.
|
|
157
|
+
*
|
|
158
|
+
* @example
|
|
159
|
+
* themeScopeStyle(lightTheme, ".card");
|
|
160
|
+
* // ":host {\n --_cs-surface-bg: var(--cs-surface-bg, #F4F1EA);\n ... }
|
|
161
|
+
* // .card {\n --cs-surface-bg: var(--_cs-surface-bg);\n ... }"
|
|
162
|
+
*/
|
|
163
|
+
export declare function themeScopeStyle(tokens: ConsentThemeTokens, scope: string): string;
|
|
164
|
+
/** The custom property a theme key is published as: `tintLine` is `--cs-tint-line`. */
|
|
165
|
+
export declare function themeTokenProperty(key: string): `--cs-${string}`;
|
|
103
166
|
//# sourceMappingURL=theme.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"theme.d.ts","sourceRoot":"","sources":["../../src/styles/theme.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AAEH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,gCAAgC,CAAC;AAEnE;;;GAGG;AACH,MAAM,WAAW,kBAAkB;IACjC,mDAAmD;IAC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