@repobit/dex-system-design 2.1.0 → 2.2.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.
Files changed (83) hide show
  1. package/CHANGELOG.md +29 -0
  2. package/package.json +6 -3
  3. package/schemas/component-manifest.json +16 -7
  4. package/src/assets/images/awards/av-comparatives-2025.png +0 -0
  5. package/src/assets/images/awards/av-test-top-product.png +0 -0
  6. package/src/assets/images/awards/gartner-peer-insights.png +0 -0
  7. package/src/assets/images/awards/idc.png +0 -0
  8. package/src/assets/images/awards/pcmag-best-of-2026.png +0 -0
  9. package/src/components/accordion/accordion-bg.css.js +1 -1
  10. package/src/components/accordion/accordion-bg.js +1 -1
  11. package/src/components/accordion/accordion.css.js +2 -2
  12. package/src/components/alert/alert.css.js +1 -1
  13. package/src/components/anchor/anchor-nav.css.js +7 -7
  14. package/src/components/awards/awards-flex.css.js +3 -3
  15. package/src/components/awards/awards-spotlight.css.js +132 -0
  16. package/src/components/awards/awards-spotlight.js +130 -0
  17. package/src/components/awards/awards-spotlight.stories.js +205 -0
  18. package/src/components/awards/awards.css.js +1 -1
  19. package/src/components/back/back.css.js +1 -1
  20. package/src/components/bento-grid/bento-grid.css.js +1 -1
  21. package/src/components/bento-grid/bento-item.css.js +1 -1
  22. package/src/components/breadcrumb/breadcrumb.css.js +1 -1
  23. package/src/components/button/button.css.js +72 -1
  24. package/src/components/button/button.js +3 -2
  25. package/src/components/button/button.stories.js +18 -2
  26. package/src/components/cards/card.css.js +7 -1
  27. package/src/components/checkbox/checkbox.css.js +5 -3
  28. package/src/components/code/code.css.js +2 -2
  29. package/src/components/compare/compare.css.js +2 -2
  30. package/src/components/compatibility-table/compatibility-table.css.js +3 -3
  31. package/src/components/cta-banner/cta-banner.css.js +3 -3
  32. package/src/components/cta-banner/cta-banner.js +1 -1
  33. package/src/components/display/display.stories.js +1 -1
  34. package/src/components/divider/divider.stories.js +2 -2
  35. package/src/components/features/features.css.js +5 -1
  36. package/src/components/features-tab/features-tab.css.js +1 -1
  37. package/src/components/fieldset/fieldset.css.js +1 -1
  38. package/src/components/footer/footer-lp.css.js +1 -1
  39. package/src/components/footer/footer-lp.js +8 -0
  40. package/src/components/footer/footer.css.js +2 -2
  41. package/src/components/footer/footer.js +8 -0
  42. package/src/components/header/header-code.css.js +4 -4
  43. package/src/components/header/header.css.js +24 -34
  44. package/src/components/heading/heading.stories.js +1 -1
  45. package/src/components/highlight/highlight.css.js +2 -2
  46. package/src/components/image/image.css.js +6 -6
  47. package/src/components/install-options/install-options.css.js +7 -7
  48. package/src/components/link/link.css.js +23 -0
  49. package/src/components/link/link.stories.js +16 -1
  50. package/src/components/modal/modal.css.js +3 -3
  51. package/src/components/paragraph/paragraph.css.js +12 -1
  52. package/src/components/paragraph/paragraph.stories.js +4 -4
  53. package/src/components/picture/picture.css.js +6 -6
  54. package/src/components/pricing-cards/new-pricing.css.js +1 -1
  55. package/src/components/pricing-cards/pricing-card-header.css.js +1 -1
  56. package/src/components/pricing-cards/pricing-card.css.js +3 -3
  57. package/src/components/radio/radio.css.js +2 -2
  58. package/src/components/review/review.css.js +1 -1
  59. package/src/components/review/review.js +3 -2
  60. package/src/components/shared/token-scales.js +19 -9
  61. package/src/components/skeleton/skeleton.css.js +1 -1
  62. package/src/components/spinner/spinner.css.js +1 -1
  63. package/src/components/spotlight-section/spotlight-section.css.js +7 -7
  64. package/src/components/spotlight-section/spotlight-section.js +3 -3
  65. package/src/components/switch/switch.css.js +3 -0
  66. package/src/components/tab-list/tab-list.css.js +2 -2
  67. package/src/components/tabs/tabs.css.js +1 -1
  68. package/src/components/terminal/terminal-cursor.js +1 -1
  69. package/src/components/terminal/terminal-message.css.js +4 -4
  70. package/src/components/tooltip/tooltip.css.js +1 -1
  71. package/src/components/video/video.css.js +1 -1
  72. package/src/components/video-player/video-player.css.js +3 -3
  73. package/src/components/video-player/video-player.js +1 -1
  74. package/src/tokens/brand-layer.js +185 -0
  75. package/src/tokens/brands.stories.js +235 -0
  76. package/src/tokens/dark-derivation.js +10 -1
  77. package/src/tokens/dark-findings.js +14 -7
  78. package/src/tokens/shape.stories.js +5 -0
  79. package/src/tokens/themes/bitdefender.js +30 -0
  80. package/src/tokens/themes/contract.js +27 -0
  81. package/src/tokens/themes/index.js +41 -0
  82. package/src/tokens/tokens.css +124 -43
  83. package/src/tokens/tokens.js +133 -44
@@ -9,8 +9,8 @@ export default css`
9
9
 
10
10
  .bd-spotlightsection-container {
11
11
  /* no role: blue-950 is the gradient's far stop, as on bd-cta-banner. */
12
- background: linear-gradient(87.6deg, var(--color-surface-brand) 0%, var(--color-blue-950) 100%);
13
- border-radius: var(--radius-2xl);
12
+ background: linear-gradient(87.6deg, var(--color-surface-brand) 0%, var(--color-brand-950) 100%);
13
+ border-radius: var(--shape-radius-2xl);
14
14
  padding: var(--spacing-48);
15
15
  box-sizing: border-box;
16
16
  display: flex;
@@ -33,13 +33,13 @@ export default css`
33
33
  .bd-spotlightsection-title {
34
34
  display: block;
35
35
  margin: 0;
36
- color: var(--color-text-inverse);
36
+ color: var(--color-brand-on-fill);
37
37
  }
38
38
 
39
39
  .bd-spotlightsection-icon {
40
40
  display: flex;
41
41
  align-items: center;
42
- color: var(--color-text-inverse);
42
+ color: var(--color-brand-on-fill);
43
43
  margin-bottom: var(--spacing-4);
44
44
  }
45
45
 
@@ -63,8 +63,8 @@ export default css`
63
63
  .bd-spotlightsection-description {
64
64
  margin: 0;
65
65
  /* Full inverse ink. White at 65% measured 2.6:1 on the brand end of the
66
- gradient, and bd-p's color="inverse" already painted over it. */
67
- color: var(--color-text-inverse);
66
+ gradient, and bd-p's color="on-brand" already painted over it. */
67
+ color: var(--color-brand-on-fill);
68
68
  }
69
69
 
70
70
  .bd-spotlightsection-buttons {
@@ -101,6 +101,6 @@ export default css`
101
101
  .bd-spotlightsection-description--large {
102
102
  display: block;
103
103
  margin: 0;
104
- color: var(--color-text-inverse);
104
+ color: var(--color-brand-on-fill);
105
105
  }
106
106
  `;
@@ -48,7 +48,7 @@ class BdSpotlightSection extends LitElement {
48
48
 
49
49
  ${flipped
50
50
  ? html`
51
- <bd-p kind="large" color="inverse" class="bd-spotlightsection-title bd-spotlightsection-title--small">
51
+ <bd-p kind="large" color="on-brand" class="bd-spotlightsection-title bd-spotlightsection-title--small">
52
52
  <slot name="title">${this.title}</slot>
53
53
  </bd-p>
54
54
  `
@@ -71,12 +71,12 @@ class BdSpotlightSection extends LitElement {
71
71
  ${this.description
72
72
  ? flipped
73
73
  ? html`
74
- <bd-h as="h2" fontWeight="normal" color="inverse" class="bd-spotlightsection-description bd-spotlightsection-description--large">
74
+ <bd-h as="h2" fontWeight="normal" color="on-brand" class="bd-spotlightsection-description bd-spotlightsection-description--large">
75
75
  <slot name="description">${this.description}</slot>
76
76
  </bd-h>
77
77
  `
78
78
  : html`
79
- <bd-p kind="large" color="inverse" class="bd-spotlightsection-description">
79
+ <bd-p kind="large" color="on-brand" class="bd-spotlightsection-description">
80
80
  <slot name="description">${this.description}</slot>
81
81
  </bd-p>
82
82
  `
@@ -94,6 +94,9 @@ export const switchCSS = css`
94
94
  label:hover .track { background: var(--color-neutral-500); }
95
95
  :host([checked]) label:hover .track { background: var(--color-action-primary-hover); }
96
96
  :host([checked]) .thumb { transform: translateX(var(--bd-switch-travel)); }
97
+ /* On the checked track the thumb sits on the brand fill, so it takes the
98
+ brand's ink; on the off track it stays white, the foundation's own pair. */
99
+ :host([checked]) .thumb { background: var(--color-brand-on-fill); }
97
100
 
98
101
  /* the one focus ring — see Foundations/Focus. On the row rather than the
99
102
  track, so the target and the indicator are the same shape here as on
@@ -208,7 +208,7 @@ export const contentSwitcherCSS = css`
208
208
  /* the action-label step, which is what a button's label carries */
209
209
  --bd-tab-font-weight: var(--typography-control-label-large-fontWeight);
210
210
  --bd-tab-font-weight-selected: var(--typography-control-label-large-fontWeight);
211
- --bd-tab-color: var(--color-text-inverse);
211
+ --bd-tab-color: var(--color-brand-on-fill); /* on the brand track */
212
212
  --bd-tab-color-selected: var(--color-text-primary);
213
213
  --bd-tab-padding: var(--spacing-12) var(--spacing-24);
214
214
  /* held at the same padding below sm: the base sheet drops to 8/12 there,
@@ -241,7 +241,7 @@ export const contentSwitcherCSS = css`
241
241
  pill appearing under it -- white at 12%, which reads on blue-500 without
242
242
  competing with the selected option's solid white. */
243
243
  .bd-tabs-container--switcher .bd-tab-button:hover:not(.bd-selected) {
244
- color: var(--color-text-inverse);
244
+ color: var(--color-brand-on-fill);
245
245
  background: var(--color-border-container-inverse);
246
246
  }
247
247
 
@@ -8,7 +8,7 @@ export default css`
8
8
  }
9
9
 
10
10
  :host([bg-blue]) {
11
- background: var(--color-blue-50);
11
+ background: var(--color-brand-50);
12
12
  --bd-features-padding-bottom: var(--spacing-32);
13
13
  }
14
14
 
@@ -19,7 +19,7 @@ class TerminalCursor extends LitElement {
19
19
  .bd-terminal-cursor {
20
20
  width: 100%;
21
21
  height: 100%;
22
- background: var(--bd-terminal-cursor-color, var(--color-blue-400));
22
+ background: var(--bd-terminal-cursor-color, var(--color-brand-400));
23
23
  animation: bd-terminal-cursor-blink 1s steps(1) infinite;
24
24
  display: block;
25
25
  }
@@ -22,7 +22,7 @@ export default css`
22
22
  The five kinds used four different mechanisms before this -- two semantic
23
23
  roles, one component token, one raw primitive and one literal. Naming them
24
24
  locally puts the palette in one place to read and to change. */
25
- --bd-terminalmsg-ask: var(--color-blue-400);
25
+ --bd-terminalmsg-ask: var(--color-brand-400);
26
26
  --bd-terminalmsg-cmd: var(--color-text-on-media);
27
27
  /* no token: the transcript's success green is the macOS traffic-light green,
28
28
  matched to the dots this panel already draws, and the palette has no step at
@@ -34,14 +34,14 @@ export default css`
34
34
  /* The status badges' two other kinds, on the same mechanism. info is
35
35
  blue-300 rather than the ask line's blue-400: a badge is a label, not the
36
36
  assistant speaking. 7.61 and 12.17:1 on the media frame. */
37
- --bd-terminalmsg-info: var(--color-blue-300);
37
+ --bd-terminalmsg-info: var(--color-brand-300);
38
38
  --bd-terminalmsg-warn: var(--color-yellow-400);
39
39
  /* The media frame, --color-surface-media. A terminal is dark in every theme, and this
40
40
  panel's line palette (blue-400, the traffic-light green) is legible only
41
41
  on a dark ground -- 2.98 and 1.97:1 once an inverse ground turns light.
42
42
  It read --color-surface-inverse until dark mode decision 15. */
43
43
  background: var(--color-surface-media);
44
- border-radius: var(--radius-xl);
44
+ border-radius: var(--shape-radius-xl);
45
45
  padding: var(--spacing-14) var(--spacing-16) var(--spacing-32);
46
46
  box-sizing: border-box;
47
47
  }
@@ -84,7 +84,7 @@ export default css`
84
84
  .bd-terminalmsg-panel {
85
85
  position: relative;
86
86
  border: var(--border-width-1) solid var(--color-border-container-inverse);
87
- border-radius: var(--radius-lg);
87
+ border-radius: var(--shape-radius-lg);
88
88
  padding: var(--spacing-20) var(--spacing-20) calc(var(--spacing-20) + var(--spacing-8));
89
89
  }
90
90
 
@@ -57,7 +57,7 @@ export const tooltipCSS = css`
57
57
  color: var(--color-text-inverse);
58
58
  background: var(--color-surface-inverse);
59
59
  padding: var(--spacing-4) var(--spacing-8);
60
- border-radius: var(--radius-sm);
60
+ border-radius: var(--shape-radius-sm);
61
61
  box-shadow: var(--shadow-md);
62
62
  opacity: 0;
63
63
  pointer-events: none;
@@ -8,7 +8,7 @@ export const videoCSS = css`
8
8
  display: block;
9
9
  width: 100%;
10
10
  height: auto;
11
- border-radius: var(--radius-lg);
11
+ border-radius: var(--shape-radius-lg);
12
12
  /* the frame around media, dark in every theme (dark mode decision 15) */
13
13
  background: var(--color-surface-media);
14
14
  }
@@ -14,7 +14,7 @@ export default css`
14
14
  border: none;
15
15
  background: none;
16
16
  cursor: pointer;
17
- border-radius: var(--radius-lg);
17
+ border-radius: var(--shape-radius-lg);
18
18
  overflow: hidden;
19
19
  }
20
20
 
@@ -22,7 +22,7 @@ export default css`
22
22
  width: 100%;
23
23
  height: auto;
24
24
  display: block;
25
- border-radius: var(--radius-lg);
25
+ border-radius: var(--shape-radius-lg);
26
26
  transition: transform var(--transition-duration-slow) var(--transition-easing-ease);
27
27
  }
28
28
 
@@ -55,7 +55,7 @@ export default css`
55
55
  position: relative;
56
56
  width: 100%;
57
57
  padding-bottom: 56.25%;
58
- border-radius: var(--radius-lg);
58
+ border-radius: var(--shape-radius-lg);
59
59
  overflow: hidden;
60
60
  /* The media frame, --color-surface-media: around a video, dark in every theme.
61
61
  This read --color-surface-inverse until dark mode decision 15 -- the
@@ -113,7 +113,7 @@ class BdVideoPlayer extends LitElement {
113
113
  <span class="bd-video-play-btn" aria-hidden="true">
114
114
  <svg viewBox="0 0 64 64" fill="none" xmlns="http://www.w3.org/2000/svg">
115
115
  <circle cx="32" cy="32" r="32" fill="white" fill-opacity="0.9"/>
116
- <path d="M26 20L46 32L26 44V20Z" fill="var(--color-blue-500)"/>
116
+ <path d="M26 20L46 32L26 44V20Z" fill="var(--color-brand-500)"/>
117
117
  </svg>
118
118
  </span>
119
119
  </button>
@@ -0,0 +1,185 @@
1
+ /**
2
+ * The brand layer: one [data-brand] block per brand theme, generated from the
3
+ * token declarations and the themes in src/tokens/themes/.
4
+ *
5
+ * Why a block per brand has to re-declare tokens, rather than only the values
6
+ * the brand changes:
7
+ *
8
+ * A custom property that reads another one is resolved where it is declared,
9
+ * and every element below inherits the finished value. The tokens are declared
10
+ * on :root, so --color-action-primary is worked out once, there, from
11
+ * --color-brand-500. A wrapper that overrides --color-brand-500 alone changes
12
+ * nothing below it -- every token that reads it was already resolved upstream.
13
+ * This was measured, not assumed: overriding --color-action-primary on a
14
+ * wrapper left a bd-button blue, because the button reads
15
+ * --button-primary-background-default, which :root had already resolved.
16
+ *
17
+ * So a brand's block re-declares the tokens it overrides, and also every token
18
+ * that depends on them, directly or through any number of hops. Those
19
+ * re-declarations re-resolve inside the brand's scope. Tokens that depend on
20
+ * nothing a brand touches are left out: their :root values are already right
21
+ * under every brand.
22
+ *
23
+ * Every block declares the same set of names -- the union of everything any
24
+ * brand overrides, plus all of their dependents -- taking the brand's own value
25
+ * where it has one and the default where it does not. That is what makes nesting
26
+ * safe: an inner brand restates every brandable token, so nothing an outer brand
27
+ * changed can leak through it. data-brand="bitdefender" inside another brand
28
+ * returns to the foundation.
29
+ *
30
+ * This module is plain JavaScript with no imports, because two places call it
31
+ * and they must not disagree: tokens.js, which installs the tokens at runtime
32
+ * when any component is imported, and scripts/build-tokens.mjs, which writes
33
+ * tokens.css. Both pass the same declaration text.
34
+ *
35
+ * With only the Bitdefender theme registered, nothing is overridden, so this
36
+ * returns an empty string and neither output changes.
37
+ */
38
+
39
+ /** A brand name has to be safe inside [data-brand="..."] without escaping. */
40
+ const NAME = /^[a-z][a-z0-9-]*$/;
41
+
42
+ /** Token name -> value, in declaration order, with comments removed. */
43
+ export function parseDeclarations(text) {
44
+ const body = text.replace(/\/\*[\s\S]*?\*\//g, '');
45
+ const map = new Map();
46
+ for (const m of body.matchAll(/(--[A-Za-z0-9-]+)\s*:\s*([^;]+);/g)) {
47
+ map.set(m[1], m[2].trim().replace(/\s+/g, ' '));
48
+ }
49
+ return map;
50
+ }
51
+
52
+ /** The tokens a value reads, e.g. color-mix(... var(--a) ...) -> ['--a']. */
53
+ const reads = value => [...value.matchAll(/var\(\s*(--[A-Za-z0-9-]+)/g)].map(m => m[1]);
54
+
55
+ /**
56
+ * Every token that reads any of `seeds`, directly or through other tokens.
57
+ * Excludes the seeds themselves.
58
+ */
59
+ export function dependentsOf(seeds, declarations) {
60
+ const readers = new Map(); // token -> tokens that read it
61
+ for (const [name, value] of declarations) {
62
+ for (const r of reads(value)) {
63
+ if (!readers.has(r)) readers.set(r, new Set());
64
+ readers.get(r).add(name);
65
+ }
66
+ }
67
+ const out = new Set();
68
+ const queue = [...seeds];
69
+ while (queue.length) {
70
+ for (const reader of readers.get(queue.shift()) ?? []) {
71
+ if (seeds.has(reader) || out.has(reader)) continue;
72
+ out.add(reader);
73
+ queue.push(reader);
74
+ }
75
+ }
76
+ return out;
77
+ }
78
+
79
+ /**
80
+ * The [data-brand] blocks for `brands`, as CSS text to place inside the
81
+ * bd-tokens layer after the :root block. Returns '' when no brand overrides
82
+ * anything.
83
+ *
84
+ * Throws on a brand name that is not a plain lowercase identifier, and on an
85
+ * override of a token that :root does not declare -- a misspelt token would
86
+ * otherwise be a silent no-op, and a brand that quietly renders as blue is the
87
+ * failure this layer exists to prevent.
88
+ */
89
+ export function brandLayer(declarationText, brands) {
90
+ const declarations = parseDeclarations(declarationText);
91
+
92
+ const overridden = new Set();
93
+ for (const [brand, overrides] of Object.entries(brands)) {
94
+ if (!NAME.test(brand)) {
95
+ throw new Error(`brand "${brand}": use lowercase letters, digits and hyphens`);
96
+ }
97
+ for (const token of Object.keys(overrides)) {
98
+ if (!declarations.has(token)) {
99
+ throw new Error(`brand "${brand}" overrides ${token}, which no token declares`);
100
+ }
101
+ overridden.add(token);
102
+ }
103
+ }
104
+ if (overridden.size === 0) return '';
105
+
106
+ const dependents = dependentsOf(overridden, declarations);
107
+ // :root order, so a block reads like the token file it came from
108
+ const names = [...declarations.keys()].filter(n => overridden.has(n) || dependents.has(n));
109
+
110
+ return Object.entries(brands).map(([brand, overrides]) => {
111
+ const lines = names.map(n => ` ${n}: ${overrides[n] ?? declarations.get(n)};`);
112
+ return ` [data-brand="${brand}"] {\n${lines.join('\n')}\n }`;
113
+ })
114
+ .join('\n\n');
115
+ }
116
+
117
+ /* ---------- themes ------------------------------------------------------
118
+
119
+ A theme is { colour: {token: value}, shape: {token: value} }, the groups and
120
+ tokens named in src/tokens/themes/contract.js. The default theme is the
121
+ foundation itself, so it contributes no overrides; every other theme
122
+ contributes the values that differ from the foundation. A value a partner
123
+ inherited from the default by spreading it is equal, so it drops out here
124
+ and the partner's block carries only what it actually changed (and what
125
+ reads that). */
126
+
127
+ /** Flatten one theme to {token: value}, refusing anything outside the contract. */
128
+ export function flattenTheme(name, theme, contract) {
129
+ const flat = {};
130
+ for (const [group, values] of Object.entries(theme ?? {})) {
131
+ if (!(group in contract)) {
132
+ throw new Error(`theme "${name}": "${group}" is not themable -- a theme sets ${Object.keys(contract).join(' and ')} only`);
133
+ }
134
+ for (const [token, value] of Object.entries(values)) {
135
+ if (!contract[group].includes(token)) {
136
+ throw new Error(`theme "${name}" sets ${token}, which the ${group} contract does not list -- see src/tokens/themes/contract.js`);
137
+ }
138
+ flat[token] = String(value);
139
+ }
140
+ }
141
+ return flat;
142
+ }
143
+
144
+ /** The [data-brand] blocks for a set of themes. '' while only the default exists. */
145
+ export function themeLayer(declarationText, themes, contract, defaultTheme) {
146
+ if (!(defaultTheme in themes)) throw new Error(`the default theme "${defaultTheme}" is not registered`);
147
+ const declarations = parseDeclarations(declarationText);
148
+ const same = (a, b) => String(a).trim()
149
+ .replace(/\s+/g, ' ') === String(b).trim()
150
+ .replace(/\s+/g, ' ');
151
+ const brands = {};
152
+ for (const [name, theme] of Object.entries(themes)) {
153
+ const flat = flattenTheme(name, theme, contract);
154
+ brands[name] = name === defaultTheme
155
+ ? {}
156
+ : Object.fromEntries(Object.entries(flat).filter(([t, v]) => !declarations.has(t) || !same(v, declarations.get(t))));
157
+ }
158
+ return brandLayer(declarationText, brands);
159
+ }
160
+
161
+ /** The source of the generated default theme: every contract token at the
162
+ foundation's own value. build-tokens writes it to themes/bitdefender.js. */
163
+ export function defaultThemeSource(declarationText, contract) {
164
+ const declarations = parseDeclarations(declarationText);
165
+ const groups = Object.entries(contract).map(([group, tokens]) => {
166
+ const width = Math.max(...tokens.map(t => t.length + 2));
167
+ const lines = tokens.map((t, i) => {
168
+ if (!declarations.has(t)) throw new Error(`contract lists ${t}, which no token declares`);
169
+ const key = `'${t}'`.padEnd(width);
170
+ const value = declarations.get(t).replace(/'/g, "\\'");
171
+ return ` ${key}: '${value}'${i < tokens.length - 1 ? ',' : ''}`;
172
+ });
173
+ return ` ${group}: {\n${lines.join('\n')}\n }`;
174
+ });
175
+ return `/* AUTO-GENERATED from src/tokens/tokens.js by \`npm run build:tokens\` -- do not edit.
176
+
177
+ The Bitdefender theme: the default, and the one every partner theme starts
178
+ from. It states the foundation's own value for every token the theme
179
+ contract lists. Change Bitdefender in tokens.js; start a partner theme from
180
+ this one as src/tokens/themes/index.js describes. */
181
+ export default {
182
+ ${groups.join(',\n')}
183
+ };
184
+ `;
185
+ }
@@ -0,0 +1,235 @@
1
+ import { html } from 'lit';
2
+ import { contrast, docsPage, refSection, resolve } from './story-chrome.js';
3
+ import { tokenDeclarations } from './tokens.js';
4
+ import { DEFAULT_THEME, THEMES } from './themes/index.js';
5
+ import { THEME_CONTRACT } from './themes/contract.js';
6
+ import bitdefender from './themes/bitdefender.js';
7
+ import { dependentsOf, parseDeclarations, themeLayer } from './brand-layer.js';
8
+
9
+ import '../components/button/button.js';
10
+ import '../components/link/link.js';
11
+ import '../components/checkbox/checkbox.js';
12
+ import '../components/switch/switch.js';
13
+ import '../components/badge/badge.js';
14
+ import '../components/paragraph/paragraph.js';
15
+
16
+ export default {
17
+ title: 'Foundations/Brands',
18
+ tags : ['autodocs']
19
+ };
20
+
21
+ const STEPS = [50, 100, 200, 300, 400, 500, 600, 700, 800, 900, 950];
22
+ const RAMP = STEPS.map(n => `--color-brand-${n}`);
23
+
24
+ /* What follows the brand, computed rather than listed: the same closure the
25
+ generator carries into every [data-brand] block. A count written into this
26
+ page would go stale the first time a token starts reading the ramp. */
27
+ const declarations = parseDeclarations(tokenDeclarations);
28
+ const THEMABLE = Object.values(THEME_CONTRACT).flat();
29
+ const carried = [...dependentsOf(new Set(THEMABLE), declarations)];
30
+ const GROUPS = [
31
+ ['Brand roles', t => /^--color-(action|text|surface|border)-/.test(t)],
32
+ ['Brand status tone', t => t.startsWith('--status-brand-')],
33
+ ['Focus and indicator', t => /^--(focus|shadow-focus|indicator)-/.test(t)],
34
+ ['Component tokens', t => /^--(button|form|layout)-/.test(t)]
35
+ ];
36
+ const grouped = GROUPS.map(([name, test]) => [name, carried.filter(test)]);
37
+ const other = carried.filter(t => !GROUPS.some(([, test]) => test(t)));
38
+ if (other.length) grouped.push(['Other', other]);
39
+
40
+ /* An example partner theme for the demo below, written exactly as a real one
41
+ is -- Bitdefender spread, then what differs. It is defined in this story and
42
+ nowhere else: the registry ships Bitdefender alone. Green ramp; dark ink,
43
+ because white on this green is about 2.4:1 and the brand's ink exists for
44
+ exactly that; and square corners, to show the shape half working. */
45
+ const EXAMPLE = {
46
+ colour: {
47
+ ...bitdefender.colour,
48
+ ...Object.fromEntries(STEPS.map(n => [`--color-brand-${n}`, `var(--color-green-${n})`])),
49
+ '--color-brand-on-fill': 'var(--color-neutral-1000)'
50
+ },
51
+ shape: Object.fromEntries(THEME_CONTRACT.shape.map(t => [t, '0px']))
52
+ };
53
+ const installExample = () => {
54
+ if (document.adoptedStyleSheets.some(s => s.__bdBrandExample)) return;
55
+ const sheet = new CSSStyleSheet();
56
+ sheet.replaceSync(`@layer bd-tokens { ${themeLayer(tokenDeclarations, { ...THEMES, example: EXAMPLE }, THEME_CONTRACT, DEFAULT_THEME)} }`);
57
+ sheet.__bdBrandExample = true;
58
+ document.adoptedStyleSheets = [...document.adoptedStyleSheets, sheet];
59
+ };
60
+
61
+ const swatch = token => {
62
+ const value = resolve(token);
63
+ return html`
64
+ <div style="display:grid;gap:var(--spacing-4)">
65
+ <div style="height:var(--spacing-40);border-radius:var(--radius-md);background:var(${token});border:var(--border-width-1) solid var(--color-border-subtle)"></div>
66
+ <code style="font-size:var(--typography-fontSize-xs)">${token.replace('--color-', '')}</code>
67
+ <span style="font-size:var(--typography-fontSize-xs);color:var(--color-text-muted)">${value}</span>
68
+ </div>`;
69
+ };
70
+
71
+ const specimen = (label, brand) => html`
72
+ <div data-brand=${brand ?? ''} style="display:grid;gap:var(--spacing-12);padding:var(--spacing-16);border:var(--border-width-1) solid var(--color-border-container);border-radius:var(--radius-lg)">
73
+ <bd-p variant="small"><b>${label}</b></bd-p>
74
+ <div style="display:flex;flex-wrap:wrap;gap:var(--spacing-8);align-items:center">
75
+ <bd-button variant="primary" label="Primary"></bd-button>
76
+ <bd-button variant="tertiary" label="Tertiary"></bd-button>
77
+ <bd-badge tone="brand">Brand</bd-badge>
78
+ <bd-badge tone="info">Info</bd-badge>
79
+ <bd-checkbox checked label="Ticked"></bd-checkbox>
80
+ <bd-switch checked label="On"></bd-switch>
81
+ </div>
82
+ <div style="display:flex;flex-wrap:wrap;gap:var(--spacing-8);align-items:center;padding:var(--spacing-12);border-radius:var(--radius-md);background:var(--color-surface-brand)">
83
+ <bd-button variant="primary" surface="brand" label="Primary"></bd-button>
84
+ <bd-button variant="tertiary" surface="brand" label="Tertiary"></bd-button>
85
+ <bd-link href="#" surface="brand" arrow>Learn more</bd-link>
86
+ </div>
87
+ </div>`;
88
+
89
+ export const Brands = () => {
90
+ installExample();
91
+ const ink = resolve('--color-text-brand');
92
+ const action = resolve('--color-action-primary');
93
+ const onFill = resolve('--color-brand-on-fill');
94
+ return docsPage({
95
+ title: 'Brands',
96
+ lede : `Partners appear on co-branded pages on bitdefender.com. Bitdefender is the host, so the
97
+ foundation is shared and only a theme changes: a partner brings colour and shape,
98
+ nothing else. Colour is a ramp, not a colour. Components reach the brand hue at ten different steps —
99
+ a tinted wash at 50, a tinted edge at 200, gradient stops and glows at 400 and 950, the
100
+ action at 500, brand text at 600 and 700 — so a brand that only named its primary would
101
+ leave all of that behind. A theme restates the eleven --color-brand-* steps, the ink that
102
+ sits on a brand fill, and the six corner steps, and everything that reads them follows.`,
103
+ note: html`<b>Info is not the brand.</b> <code>--status-info-*</code> and
104
+ <code>--color-surface-info</code> read <code>--color-blue-*</code> directly, so an info
105
+ message stays recognisable under every brand — a partner with a red brand must not
106
+ make info read as an error. <b>The Bitdefender AI logo is artwork</b> and keeps its blue for
107
+ the same reason a logo keeps its colours.`,
108
+ children: html`
109
+ ${refSection({
110
+ name : 'The ramp',
111
+ meta : 'today: the Bitdefender blue, step for step',
112
+ children: html`
113
+ <div style="display:grid;grid-template-columns:repeat(auto-fill,minmax(5.5rem,1fr));gap:var(--spacing-12)">
114
+ ${RAMP.map(swatch)}
115
+ </div>`
116
+ })}
117
+
118
+ ${refSection({
119
+ name : 'The ink and the corners',
120
+ meta : 'the rest of the contract',
121
+ children: html`
122
+ <div style="display:grid;grid-template-columns:repeat(auto-fill,minmax(6.5rem,1fr));gap:var(--spacing-12)">
123
+ <div style="display:grid;gap:var(--spacing-4)">
124
+ <div style="height:var(--spacing-40);border-radius:var(--radius-md);background:var(--color-action-primary);color:var(--color-brand-on-fill);display:grid;place-items:center;font-weight:600">Aa</div>
125
+ <code style="font-size:var(--typography-fontSize-xs)">brand-on-fill</code>
126
+ <span style="font-size:var(--typography-fontSize-xs);color:var(--color-text-muted)">${onFill}</span>
127
+ </div>
128
+ ${THEME_CONTRACT.shape.map(t => html`
129
+ <div style="display:grid;gap:var(--spacing-4)">
130
+ <div style="height:var(--spacing-40);border-radius:var(${t});background:var(--color-surface-muted);border:var(--border-width-1) solid var(--color-border-default)"></div>
131
+ <code style="font-size:var(--typography-fontSize-xs)">${t.replace('--shape-', '')}</code>
132
+ <span style="font-size:var(--typography-fontSize-xs);color:var(--color-text-muted)">${resolve(t)}</span>
133
+ </div>`)}
134
+ </div>
135
+ <bd-p variant="small">
136
+ The brand's ink is what sits on its fill — a label, a tick, a thumb, copy on a brand band
137
+ (<code>color="on-brand"</code>). A light brand sets it dark. The corners are what every card,
138
+ button, field and panel reads; circles, deliberate squares and the focus ring's corner are
139
+ not in the contract, because a brand must not move them.
140
+ </bd-p>`
141
+ })}
142
+
143
+ ${refSection({
144
+ name : 'A co-branded page',
145
+ meta : 'the attribute goes on the content region',
146
+ children: html`
147
+ <pre style="margin:0"><code>&lt;site navigation&gt; bitdefender.com's menu, outside this package
148
+ &lt;main data-brand="orange"&gt; the partner's theme
149
+ &lt;bd-header&gt; … the product hero follows the partner
150
+ &lt;bd-footer&gt; pins itself to Bitdefender
151
+
152
+ &lt;div data-brand="bitdefender"&gt; back to the foundation, inside a partner</code></pre>
153
+ <bd-p variant="small">
154
+ Brands nest. Every brand's block restates the same set of tokens, so an inner brand can
155
+ never let an outer one through, and <code>bitdefender</code> is always available to reset
156
+ to. Registered today: <b>${Object.keys(THEMES).join(', ')}</b>.
157
+ </bd-p>`
158
+ })}
159
+
160
+ ${refSection({
161
+ name : 'Scoped, side by side',
162
+ meta : 'example brand — defined in this story only, not registered',
163
+ children: html`
164
+ <div style="display:grid;grid-template-columns:repeat(auto-fit,minmax(16rem,1fr));gap:var(--spacing-16)">
165
+ ${specimen('No brand attribute', null)}
166
+ ${specimen('data-brand="example"', 'example')}
167
+ <div data-brand="example" style="display:grid;padding:var(--spacing-16);border-radius:var(--radius-lg);background:var(--color-surface-subtle)">
168
+ ${specimen('data-brand="bitdefender" inside "example"', 'bitdefender')}
169
+ </div>
170
+ </div>
171
+ <bd-p variant="small">
172
+ The same components, one page. In the example column the buttons, brand badge, tick and
173
+ thumb take the example's colour, its dark ink and its square corners; the info badge does
174
+ not change, by design. The focus ring follows too — tab into either column. On the brand
175
+ band, buttons and links placed with <code>surface="brand"</code> take the brand's ink:
176
+ white on Bitdefender, dark on the example.
177
+ </bd-p>`
178
+ })}
179
+
180
+ ${refSection({
181
+ name : 'What follows a theme',
182
+ meta : `${carried.length} tokens, computed from the token source`,
183
+ children: html`
184
+ <bd-p variant="small">
185
+ Every token that reads a themable token, directly or through other tokens. A brand's
186
+ <code>[data-brand]</code> block re-declares exactly these, because a custom property is
187
+ resolved where it is declared: <code>--color-action-primary</code> is worked out once on
188
+ <code>:root</code>, so overriding the ramp on a wrapper without re-declaring the tokens that
189
+ read it would change nothing below the wrapper.
190
+ </bd-p>
191
+ ${grouped.map(([name, tokens]) => html`
192
+ <div style="margin-top:var(--spacing-12)">
193
+ <bd-p variant="small"><b>${name}</b> (${tokens.length})</bd-p>
194
+ <div style="display:flex;flex-wrap:wrap;gap:var(--spacing-4) var(--spacing-12)">
195
+ ${tokens.map(t => html`<code style="font-size:var(--typography-fontSize-xs)">${t}</code>`)}
196
+ </div>
197
+ </div>`)}`
198
+ })}
199
+
200
+ ${refSection({
201
+ name : 'Adding a partner theme',
202
+ meta : 'src/tokens/themes/',
203
+ children: html`
204
+ <pre style="margin:0"><code>// themes/orange.js
205
+ import bitdefender from './bitdefender.js';
206
+ export default {
207
+ colour: { ...bitdefender.colour, '--color-brand-500': '#…', '--color-brand-on-fill': 'var(--color-neutral-1000)' },
208
+ shape : { ...bitdefender.shape, '--shape-radius-md': '0' }
209
+ };</code></pre>
210
+ <ol style="margin:0;padding-left:var(--spacing-20)">
211
+ <li>Duplicate the Bitdefender theme as above — spread it, so anything you do not change
212
+ keeps following Bitdefender — rename it, change what differs, and register it in
213
+ <code>themes/index.js</code>.</li>
214
+ <li><code>npm run build:tokens</code> — writes the block into <code>tokens.css</code>; components
215
+ pick it up at runtime from the same generator.</li>
216
+ <li><code>npm run verify:brands</code> — measures every registered brand against the contrast
217
+ floors, and <code>npm run verify:brands:sweep</code> renders every story to find anything
218
+ still painting the old ramp, sitting at an old corner, or leaving ink a light brand cannot
219
+ read.</li>
220
+ </ol>
221
+ <bd-p variant="small">
222
+ A theme may set only what the contract lists —
223
+ ${Object.entries(THEME_CONTRACT).map(([g, t]) => `${g}: ${t.length} tokens`)
224
+ .join(' · ')} —
225
+ and anything else fails the build.
226
+ </bd-p>
227
+ <bd-p variant="small">
228
+ The floors were met by the blue ramp, and a different hue can miss them.
229
+ Today: brand text on the page ${Math.round(contrast(ink, resolve('--color-surface-default')) * 100) / 100}:1,
230
+ brand ink on the action ${Math.round(contrast(onFill, action) * 100) / 100}:1 — both need 4.5:1.
231
+ </bd-p>`
232
+ })}
233
+ `
234
+ });
235
+ };
@@ -74,8 +74,17 @@ export function derive(cssText) {
74
74
  const m = k.match(RAMP);
75
75
  if (m) (RAMPS[m[1]] ??= {})[Number(m[2])] = v.trim().toLowerCase();
76
76
  }
77
+ /* The brand's contract colour tokens are aliases a theme restates, not roles
78
+ with a job of their own: --color-brand-N aliases a palette step (today
79
+ --color-blue-N, step for step) and --color-brand-on-fill aliases
80
+ --color-neutral-0. Each is seen through to its step. Only these -- a role
81
+ that aliases another role is still not a primitive, and treating it as one
82
+ would change what this derives. */
77
83
  const prim = ref => {
78
- const m = ref.trim().match(/^var\(\s*--color-(blue|red|green|yellow|neutral)-(\d+)\s*\)$/);
84
+ let r = ref.trim();
85
+ const b = r.match(/^var\(\s*(--color-brand-(?:\d+|on-fill))\s*\)$/);
86
+ if (b && decl.has(b[1])) r = decl.get(b[1]).trim();
87
+ const m = r.match(/^var\(\s*--color-(blue|red|green|yellow|neutral)-(\d+)\s*\)$/);
79
88
  return m ? [m[1], Number(m[2])] : null;
80
89
  };
81
90
  const hexof = p => RAMPS[p[0]][p[1]];