@keystone-sites/marketing-design-system 1.0.9 → 1.0.11

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/base.css CHANGED
@@ -83,6 +83,8 @@ input:where([type="button"], [type="submit"]) {
83
83
  --opsz: var(--ts-text-md-regular-opsz);
84
84
  font: var(--font);
85
85
  letter-spacing: var(--ls);
86
+ /* Tracking other than normal drops liga; name it so fi and fl stay on. */
87
+ font-feature-settings: "liga" 1;
86
88
  font-optical-sizing: none;
87
89
  font-variation-settings: "opsz" var(--opsz), var(--font-sans-slnt);
88
90
  overflow-x: clip;
package/icons.tsx CHANGED
@@ -1112,6 +1112,51 @@ export function IconSocialApplePodcasts({ size = 34, className }: Props) {
1112
1112
  );
1113
1113
  }
1114
1114
 
1115
+ /** icons/lock (1236:66275) — currentColor. */
1116
+ export function IconLock({ size = 20, className }: Props) {
1117
+ return (
1118
+ <svg
1119
+ width={size}
1120
+ height={size}
1121
+ viewBox="0 0 20 20"
1122
+ fill="none"
1123
+ aria-hidden="true"
1124
+ className={className}
1125
+ xmlns="http://www.w3.org/2000/svg"
1126
+ >
1127
+ <path
1128
+ d="M16.666 7.5V18.333H3.33301V7.5H16.666ZM4.58301 17.083H15.416V8.75H4.58301V17.083Z"
1129
+ fill="currentColor"
1130
+ />
1131
+ <path
1132
+ d="M12.916 7.91699V5.83398C12.916 4.22326 11.6107 2.91717 10 2.91699C8.38917 2.91699 7.08301 4.22315 7.08301 5.83398V7.91699C7.08301 8.26217 6.80319 8.54199 6.45801 8.54199C6.11283 8.54199 5.83301 8.26217 5.83301 7.91699V5.83398C5.83301 3.5328 7.69881 1.66699 10 1.66699C12.301 1.66717 14.166 3.53291 14.166 5.83398V7.91699C14.166 8.26217 13.8862 8.54199 13.541 8.54199C13.196 8.54182 12.916 8.26206 12.916 7.91699Z"
1133
+ fill="currentColor"
1134
+ />
1135
+ <path d="M9.375 11.042H10.625V14.792H9.375V11.042Z" fill="currentColor" />
1136
+ </svg>
1137
+ );
1138
+ }
1139
+
1140
+ /** icons/speed (1283:18013) — currentColor. */
1141
+ export function IconSpeed({ size = 20, className }: Props) {
1142
+ return (
1143
+ <svg
1144
+ width={size}
1145
+ height={size}
1146
+ viewBox="0 0 20 20"
1147
+ fill="none"
1148
+ aria-hidden="true"
1149
+ className={className}
1150
+ xmlns="http://www.w3.org/2000/svg"
1151
+ >
1152
+ <path
1153
+ d="M11.667 10C11.6668 9.07966 10.9204 8.33398 10 8.33398C9.07977 8.33416 8.33416 9.07977 8.33398 10C8.33398 10.9204 9.07966 11.6668 10 11.667C10.9205 11.667 11.667 10.9205 11.667 10ZM9.375 1.66699H10C14.6022 1.66699 18.3338 5.39778 18.334 10C18.334 14.6023 14.6023 18.334 10 18.334C5.39778 18.3338 1.66699 14.6022 1.66699 10C1.66704 8.71052 1.96023 7.48779 2.48438 6.39648L2.75488 5.83301L3.88184 6.37402L3.61133 6.9375C3.1665 7.86359 2.91704 8.90179 2.91699 10C2.91699 13.9119 6.08814 17.0838 10 17.084C13.912 17.084 17.084 13.912 17.084 10C17.0838 6.29867 14.2443 3.26161 10.625 2.94531V5H9.375V1.66699ZM12.917 10C12.917 11.6108 11.6108 12.917 10 12.917C8.3893 12.9168 7.08398 11.6107 7.08398 10C7.08405 9.42102 7.25394 8.88239 7.54492 8.42871L3.7002 4.58398L4.58398 3.7002L8.42871 7.54492C8.88239 7.25394 9.42102 7.08405 10 7.08398C11.6107 7.08398 12.9168 8.3893 12.917 10Z"
1154
+ fill="currentColor"
1155
+ />
1156
+ </svg>
1157
+ );
1158
+ }
1159
+
1115
1160
  /** Single-tone search mark for compact controls. */
1116
1161
  export function IconSearchGlyph({ size = 16, className }: Props) {
1117
1162
  return (
@@ -1188,15 +1233,6 @@ export function IconLink(props: Props) {
1188
1233
  );
1189
1234
  }
1190
1235
 
1191
- export function IconLock(props: Props) {
1192
- return (
1193
- <LineGlyph {...props}>
1194
- <rect x="4.5" y="10.5" width="15" height="10" rx="2.5" />
1195
- <path d="M8 10.5V8a4 4 0 1 1 8 0v2.5" />
1196
- </LineGlyph>
1197
- );
1198
- }
1199
-
1200
1236
  export function IconMic(props: Props) {
1201
1237
  return (
1202
1238
  <LineGlyph {...props}>
package/index.css CHANGED
@@ -70,6 +70,7 @@
70
70
  @import "./sections/footer-signature.css" layer(sections);
71
71
  @import "./sections/nav.css" layer(sections);
72
72
  @import "./sections/nav-desktop.css" layer(sections);
73
+ @import "./sections/nav-menu.css" layer(sections);
73
74
  @import "./sections/nav-mobile.css" layer(sections);
74
75
  @import "./sections/faq.css" layer(sections);
75
76
  @import "./sections/gallery-overlay.css" layer(sections);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@keystone-sites/marketing-design-system",
3
- "version": "1.0.9",
3
+ "version": "1.0.11",
4
4
  "description": "Keystone's marketing design system: tokens, the tick grid, type, primitives, site chrome, and the landing kit. Source-shipped CSS and TSX for Next.js consumers.",
5
5
  "license": "UNLICENSED",
6
6
  "repository": {
@@ -182,6 +182,8 @@
182
182
  "./sections/load.css": "./sections/load.css",
183
183
  "./sections/nav-desktop.css": "./sections/nav-desktop.css",
184
184
  "./sections/nav-desktop": "./sections/nav-desktop.tsx",
185
+ "./sections/nav-menu.css": "./sections/nav-menu.css",
186
+ "./sections/nav-menu": "./sections/nav-menu.tsx",
185
187
  "./sections/nav-mobile.css": "./sections/nav-mobile.css",
186
188
  "./sections/nav-mobile": "./sections/nav-mobile.tsx",
187
189
  "./sections/nav.css": "./sections/nav.css",
@@ -46,6 +46,8 @@
46
46
  .type {
47
47
  font: var(--font);
48
48
  letter-spacing: var(--ls, normal);
49
+ /* Tracking other than normal drops liga; name it so fi and fl stay on. */
50
+ font-feature-settings: "liga" 1;
49
51
  text-transform: var(--case, none);
50
52
  /* Pinning the slant axis stops WebKit rendering GT Standard oblique. */
51
53
  font-variation-settings: "opsz" var(--opsz, 10), var(--font-sans-slnt);
@@ -1,52 +1,80 @@
1
- /* The signature footer (sections/footer-signature.tsx): a two-cell
2
- signature — tagline beside the lockup — over one legal line, framed by
3
- the lattice. Stacked in rm/rs, side by side from rt. Type is fixed per
4
- band (site chrome); a band that steps restates --font/--ls. */
1
+ /* The signature footer (sections/footer-signature.tsx): tagline beside
2
+ the lockup over one legal line, framed by the lattice. Stacked in
3
+ rm/rs (each block three ticks, a lattice row under the legal line);
4
+ side by side from rt, with the legal line inset one cell, two from
5
+ rd1. Type is fixed per band; a band that steps restates --font/--ls. */
5
6
 
6
7
  /* Designed constants for this file. */
7
8
  :root {
8
- --fsig-dot: 6px;
9
- --fsig-dot-rs: 8px;
10
- --fsig-lockup-ratio: 380 / 61;
9
+ /* An 8px circle on the first line's baseline: 13px down in a 21px
10
+ box at the tablet, 19px down in a 27px box at the desktop. */
11
+ --fsig-dot: 8px;
12
+ --fsig-dot-drop: 13px;
13
+ --fsig-dot-drop-rd: 19px;
14
+ --fsig-lockup-ratio: 391.6 / 62.9;
15
+ /* Desktop legal padding (Figma 64px). Not a spacing step. */
16
+ --fsig-legal-pad: 64px;
11
17
  }
12
18
 
13
19
  .fsig {
14
20
  position: relative;
15
- min-height: calc(var(--t) * 8);
21
+ min-height: calc(var(--t) * 11);
16
22
  }
17
23
 
24
+ /* Content boxes are line-inclusive (k·t + 1px) and each seam is pulled
25
+ up 1px, so a box's border lands on the lattice pixel instead of
26
+ drawing a second hairline beside it. */
18
27
  .fsig-signature {
19
- position: relative;
20
- display: grid;
21
- grid-template-rows: repeat(2, calc(var(--t) * 3));
28
+ display: flex;
29
+ flex-direction: column;
22
30
  width: calc(var(--t) * 10 + 1px);
23
- min-height: calc(var(--t) * 6 + 1px);
24
- margin-top: calc(var(--t));
31
+ margin-top: var(--t);
25
32
  margin-left: var(--t);
26
33
  }
27
34
 
28
35
  .fsig-statement,
29
- .fsig-lockband {
36
+ .fsig-lockband,
37
+ .fsig-copy {
30
38
  box-sizing: border-box;
31
39
  min-width: 0;
32
- overflow: hidden;
33
40
  border: 1px solid var(--line);
41
+ }
42
+
43
+ .fsig-statement,
44
+ .fsig-lockband {
34
45
  display: flex;
35
46
  align-items: center;
47
+ min-height: calc(var(--t) * 3 + 1px);
48
+ }
49
+
50
+ .fsig-lockband,
51
+ .fsig-copy {
52
+ margin-top: -1px;
36
53
  }
37
54
 
38
55
  .fsig-statement {
39
- gap: var(--space-sm);
40
- padding: var(--space-lg);
56
+ justify-content: center;
57
+ padding: var(--space-xl);
58
+ text-align: center;
59
+ }
60
+
61
+ .fsig-lead {
62
+ display: flex;
63
+ align-items: flex-start;
64
+ justify-content: center;
65
+ width: 100%;
66
+ min-width: 0;
41
67
  }
42
68
 
43
69
  .fsig-tagline {
44
70
  max-width: 100%;
45
71
  margin: 0;
46
72
  color: var(--color-text-200);
73
+ white-space: pre-line;
47
74
  }
48
75
 
49
76
  .fsig-dot {
77
+ display: none;
50
78
  flex: none;
51
79
  width: var(--fsig-dot);
52
80
  height: var(--fsig-dot);
@@ -56,14 +84,11 @@
56
84
 
57
85
  .fsig-lockband {
58
86
  justify-content: center;
59
- margin-top: -1px;
60
87
  }
61
88
 
62
89
  .fsig-lockup {
63
90
  display: block;
64
- width: min(calc(var(--t) * 5), 82%);
65
- max-width: calc(100% - var(--space-2xl) - var(--space-2xl));
66
- max-height: calc(100% - var(--space-xl) - var(--space-xl));
91
+ width: calc(var(--t) * 5);
67
92
  aspect-ratio: var(--fsig-lockup-ratio);
68
93
  background-color: var(--color-text-200);
69
94
  -webkit-mask-image: url("/media/brand/ks-lockup.svg");
@@ -77,25 +102,22 @@
77
102
  }
78
103
 
79
104
  .fsig-copy {
80
- box-sizing: border-box;
81
- border: 1px solid var(--line);
82
- width: calc(var(--t) * 10 + 1px);
83
- margin-left: var(--t);
84
- min-height: calc(var(--t) + 1px);
85
105
  display: flex;
86
106
  flex-wrap: wrap;
87
107
  align-items: center;
88
108
  justify-content: center;
89
- gap: var(--space-xs) var(--space-lg);
90
- padding: var(--space-md) calc(var(--t));
91
- color: var(--color-text-500);
109
+ gap: var(--space-xs) var(--space-xl);
110
+ width: calc(var(--t) * 10 + 1px);
111
+ min-height: calc(var(--t) * 3 + 1px);
112
+ margin-left: var(--t);
113
+ padding: 0;
114
+ color: var(--color-text-400);
92
115
  }
93
116
 
117
+ /* Phone: the copyright and the links are one wrapping row. From the
118
+ tablet they split, copyright at the start and the links as a group. */
94
119
  .fsig-legal-links {
95
- display: flex;
96
- flex-wrap: wrap;
97
- justify-content: center;
98
- gap: var(--space-xs) var(--space-lg);
120
+ display: contents;
99
121
  }
100
122
 
101
123
  .fsig-copy a,
@@ -119,63 +141,67 @@
119
141
  box-shadow: 0 0 0 var(--ring-w) var(--color-bg-400);
120
142
  }
121
143
 
122
- @container (--rs) {
123
- .fsig-statement {
124
- gap: var(--space-md);
125
- padding: var(--space-xl);
126
- }
127
- .fsig-tagline {
128
- --font: var(--ts-display-serif-sm-light-font);
129
- --ls: var(--ts-display-serif-sm-light-ls);
130
- }
131
- .fsig-dot {
132
- width: var(--fsig-dot-rs);
133
- height: var(--fsig-dot-rs);
134
- }
135
- }
136
-
137
144
  @container (--rt) {
138
145
  .fsig {
139
146
  min-height: calc(var(--t) * 5);
140
147
  }
141
148
  .fsig-signature {
142
- grid-template-columns: 1fr 1fr;
143
- grid-template-rows: none;
144
- min-height: calc(var(--t) * 3 + 1px);
149
+ flex-direction: row;
150
+ }
151
+ .fsig-statement,
152
+ .fsig-lockband {
153
+ flex: 1;
145
154
  }
146
155
  .fsig-statement {
147
- padding-inline: var(--space-3xl);
156
+ padding: var(--space-xl) var(--space-4xl);
157
+ padding-left: calc(var(--space-4xl) + var(--space-2xs));
158
+ text-align: start;
148
159
  }
149
- .fsig-lockup {
150
- width: min(calc(var(--t) * 4.5), 70%);
160
+ .fsig-lead {
161
+ justify-content: flex-start;
162
+ gap: var(--space-lg);
163
+ width: auto;
164
+ }
165
+ .fsig-dot {
166
+ display: block;
167
+ margin-top: var(--fsig-dot-drop);
151
168
  }
152
169
  .fsig-lockband {
153
170
  margin-top: 0;
154
171
  margin-left: -1px;
155
172
  }
173
+ .fsig-lockup {
174
+ width: calc(var(--t) * 3.5);
175
+ }
156
176
  .fsig-copy {
157
177
  flex-wrap: nowrap;
158
178
  justify-content: space-between;
159
- padding-inline: var(--t);
179
+ min-height: calc(var(--t) + 1px);
180
+ padding: 0 var(--space-4xl);
160
181
  }
161
182
  .fsig-legal-links {
183
+ display: flex;
162
184
  flex-wrap: nowrap;
163
- gap: var(--space-xl);
185
+ gap: var(--space-2xl);
164
186
  }
165
187
  }
166
188
 
167
- @container (--rd2) {
189
+ @container (--rd1) {
168
190
  .fsig-statement {
169
191
  padding-inline: var(--space-5xl);
192
+ padding-left: calc(var(--space-5xl) + var(--space-2xs));
170
193
  }
171
194
  .fsig-tagline {
172
- --font: var(--ts-display-serif-md-light-font);
173
- --ls: var(--ts-display-serif-md-light-ls);
195
+ --font: var(--ts-display-serif-md-plus-thin-font);
196
+ --ls: var(--ts-display-serif-md-plus-thin-ls);
197
+ }
198
+ .fsig-dot {
199
+ margin-top: var(--fsig-dot-drop-rd);
174
200
  }
175
201
  .fsig-copy {
176
- --font: var(--ts-text-sm-light-font);
177
- --ls: var(--ts-text-sm-light-ls);
178
- --opsz: var(--ts-text-sm-light-opsz);
202
+ width: calc(var(--t) * 8 + 1px);
203
+ margin-left: calc(var(--t) * 2);
204
+ padding-inline: var(--fsig-legal-pad);
179
205
  }
180
206
  .fsig-legal-links {
181
207
  gap: var(--space-5xl);
@@ -1,9 +1,12 @@
1
1
  import { CookiePreferencesLink } from "@keystone-sites/widgets/consent/CookiePreferencesLink";
2
- import { GridRegion, GridDecor, type GridBand } from "../grid/region";
2
+ import { GridRegion, type GridBand } from "../grid/region";
3
3
 
4
4
  /** The compact footer for a product page: a tagline and the lockup side
5
5
  * by side (stacked in the narrow bands) over one line of legal links.
6
- * The full marketing footer is sections/footer.tsx. */
6
+ * The full marketing footer is sections/footer.tsx.
7
+ *
8
+ * Lattice is only the empty cells. Content boxes own the lines of the
9
+ * cells they fill, so a legal row never paints across a side cell. */
7
10
 
8
11
  export interface FooterSignatureCopy {
9
12
  tagline: string;
@@ -24,59 +27,48 @@ interface R {
24
27
  gw?: number;
25
28
  gh?: number;
26
29
  }
27
- interface Orn extends R {
28
- shape: "square" | "circle" | "outline";
29
- }
30
- interface BandMap {
31
- regions: R[];
32
- ornaments: Orn[];
33
- }
34
30
 
35
- function footerMap(stacked: boolean): BandMap {
36
- const sideCells = stacked ? 7 : 4;
37
- const bottomRow = stacked ? 7 : 4;
38
- return {
39
- regions: [
31
+ /* Phone: statement, lockup, and legal are each three ticks between one
32
+ side cell, closed by a lattice row. From the tablet the signature is
33
+ one row of three ticks and the legal row is one tick, inset one cell;
34
+ the desktop insets it two. */
35
+ function footerMap(stacked: boolean, legalInset = 1): R[] {
36
+ if (stacked) {
37
+ return [
40
38
  { gx: 0, gy: 0, gw: 12, gh: 1 },
41
- { gx: 0, gy: 1, gw: 1, gh: sideCells },
42
- { gx: 11, gy: 1, gw: 1, gh: sideCells },
43
- { gx: 0, gy: bottomRow, gw: 12, gh: 1 },
44
- ],
45
- ornaments: [
46
- { gx: 8, gy: 0, shape: "square" },
47
- { gx: 3, gy: bottomRow, shape: "circle" },
48
- ],
49
- };
39
+ { gx: 0, gy: 1, gw: 1, gh: 3 },
40
+ { gx: 11, gy: 1, gw: 1, gh: 3 },
41
+ { gx: 0, gy: 4, gw: 1, gh: 3 },
42
+ { gx: 11, gy: 4, gw: 1, gh: 3 },
43
+ { gx: 0, gy: 7, gw: 1, gh: 3 },
44
+ { gx: 11, gy: 7, gw: 1, gh: 3 },
45
+ { gx: 0, gy: 10, gw: 12, gh: 1 },
46
+ ];
47
+ }
48
+ return [
49
+ { gx: 0, gy: 0, gw: 12, gh: 1 },
50
+ { gx: 0, gy: 1, gw: 1, gh: 3 },
51
+ { gx: 11, gy: 1, gw: 1, gh: 3 },
52
+ { gx: 0, gy: 4, gw: legalInset, gh: 1 },
53
+ { gx: 12 - legalInset, gy: 4, gw: legalInset, gh: 1 },
54
+ ];
50
55
  }
51
56
 
52
57
  const BANDS: GridBand[] = ["rm", "rs", "rt", "rd1", "rd2"];
53
- const FOOTER_MAP: Record<GridBand, BandMap> = {
58
+ const FOOTER_MAP: Record<GridBand, R[]> = {
54
59
  rm: footerMap(true),
55
60
  rs: footerMap(true),
56
- rt: footerMap(false),
57
- rd1: footerMap(false),
58
- rd2: footerMap(false),
59
- };
60
-
61
- const ORNAMENT_CLASS: Record<Orn["shape"], string> = {
62
- square: "f-cell fill",
63
- circle: "f-cell fill round",
64
- outline: "f-cell round",
61
+ rt: footerMap(false, 1),
62
+ rd1: footerMap(false, 2),
63
+ rd2: footerMap(false, 2),
65
64
  };
66
65
 
67
- function Overlay({ maps }: { maps: Record<GridBand, BandMap> }) {
66
+ function Overlay({ maps }: { maps: Record<GridBand, R[]> }) {
68
67
  return (
69
68
  <div className="gx" aria-hidden="true">
70
- {BANDS.map((band) => [
71
- ...maps[band].regions.map((r, i) => (
72
- <GridRegion key={`${band}-r${i}`} band={band} {...r} />
73
- )),
74
- ...maps[band].ornaments.map((o, i) => (
75
- <GridDecor key={`${band}-o${i}`} band={band} gx={o.gx} gy={o.gy}>
76
- <span className={ORNAMENT_CLASS[o.shape]} />
77
- </GridDecor>
78
- )),
79
- ])}
69
+ {BANDS.map((band) =>
70
+ maps[band].map((r, i) => <GridRegion key={`${band}-r${i}`} band={band} {...r} />),
71
+ )}
80
72
  </div>
81
73
  );
82
74
  }
@@ -93,8 +85,12 @@ export function FooterSignature({
93
85
  <Overlay maps={FOOTER_MAP} />
94
86
  <div className="fsig-signature" data-landmark="signature">
95
87
  <div className="fsig-statement">
96
- <span className="fsig-dot" aria-hidden="true" />
97
- <p className="type type-fixed ts-display-serif-xs-light fsig-tagline">{copy.tagline}</p>
88
+ <div className="fsig-lead">
89
+ <span className="fsig-dot" aria-hidden="true" />
90
+ <p className="type type-fixed ts-display-serif-xs-extralight fsig-tagline">
91
+ {copy.tagline}
92
+ </p>
93
+ </div>
98
94
  </div>
99
95
  <div className="fsig-lockband">
100
96
  <div className="fsig-lockup" role="img" aria-label={copy.lockupAlt} />
@@ -0,0 +1,57 @@
1
+ /* Nav menu (rd1+): a rail item's few links in a panel hung from its own
2
+ trigger. The panel is the drawer's surface and reveal (nav-desktop.css)
3
+ at the width of its links; each link is a rail button's row, type and
4
+ ink. */
5
+
6
+ .knav-menu {
7
+ position: relative;
8
+ display: flex;
9
+ }
10
+
11
+ .knav-menu-panel {
12
+ position: absolute;
13
+ top: calc(100% + var(--space-xs));
14
+ left: 0;
15
+ display: flex;
16
+ flex-direction: column;
17
+ min-width: 100%;
18
+ padding-block: var(--space-xs);
19
+ background: var(--color-bg-000);
20
+ box-shadow: var(--shadow-hard-square);
21
+ opacity: 0;
22
+ translate: 0 calc(-1 * var(--knav-reveal-rise));
23
+ visibility: hidden;
24
+ pointer-events: none;
25
+ transition:
26
+ opacity var(--knav-reveal-fade) ease,
27
+ translate var(--knav-reveal-slide) var(--motion-drawer-ease),
28
+ visibility 0s linear var(--knav-reveal-slide);
29
+ }
30
+ .knav-menu-panel[data-open] {
31
+ opacity: 1;
32
+ translate: 0 0;
33
+ visibility: visible;
34
+ pointer-events: auto;
35
+ transition:
36
+ opacity var(--knav-reveal-fade) ease,
37
+ translate var(--knav-reveal-slide) var(--motion-drawer-ease);
38
+ }
39
+
40
+ .knav-menu-link {
41
+ display: flex;
42
+ align-items: center;
43
+ min-height: var(--knav-bar-h);
44
+ padding-inline: var(--space-xl) var(--knav-btn-pr);
45
+ color: var(--color-text-300);
46
+ text-decoration: none;
47
+ white-space: nowrap;
48
+ transition: color var(--knav-ink-dur) var(--motion-hover-ease);
49
+ }
50
+ .knav-menu-link[aria-current="page"] {
51
+ color: var(--color-text-100);
52
+ }
53
+ @media (hover: hover) {
54
+ .knav-menu-link:hover {
55
+ color: var(--color-text-100);
56
+ }
57
+ }
@@ -0,0 +1,112 @@
1
+ "use client";
2
+
3
+ /** NavMenu: a rail item that drops its few links beneath it, for a
4
+ * product rail whose item is a group of pages. It is the drawers'
5
+ * trigger, surface and reveal at the size of a list; ks-MarketingSite has
6
+ * no node of its own for it, so every value is the drawer's. Styles live
7
+ * in nav-menu.css. */
8
+
9
+ import { useEffect, useId, useRef, useState, type FocusEvent, type KeyboardEvent } from "react";
10
+ import { IconNavTrigger } from "../icons";
11
+
12
+ /** The drawers' intent delay: the pointer crosses the gap to the panel. */
13
+ const CLOSE_INTENT_MS = 140;
14
+
15
+ export interface NavMenuLink {
16
+ id: string;
17
+ label: string;
18
+ href: string;
19
+ }
20
+
21
+ export function NavMenu({
22
+ label,
23
+ href,
24
+ links,
25
+ current,
26
+ }: {
27
+ label: string;
28
+ /** Where the item itself goes: the group's first page. */
29
+ href: string;
30
+ links: readonly NavMenuLink[];
31
+ /** The id of the link for the current page, if it is in this group. */
32
+ current?: string;
33
+ }) {
34
+ const [open, setOpen] = useState(false);
35
+ const closeTimer = useRef<number | null>(null);
36
+ const triggerRef = useRef<HTMLAnchorElement>(null);
37
+ /* Escape hands focus back to the trigger without reopening the menu. */
38
+ const refocusing = useRef(false);
39
+ const menuId = useId();
40
+
41
+ const cancelClose = () => {
42
+ if (closeTimer.current !== null) {
43
+ window.clearTimeout(closeTimer.current);
44
+ closeTimer.current = null;
45
+ }
46
+ };
47
+ const show = () => {
48
+ cancelClose();
49
+ setOpen(true);
50
+ };
51
+ const scheduleClose = () => {
52
+ cancelClose();
53
+ closeTimer.current = window.setTimeout(() => setOpen(false), CLOSE_INTENT_MS);
54
+ };
55
+ const closeNow = () => {
56
+ cancelClose();
57
+ setOpen(false);
58
+ };
59
+
60
+ useEffect(() => cancelClose, []);
61
+
62
+ const onKeyDown = (event: KeyboardEvent<HTMLDivElement>) => {
63
+ if (event.key !== "Escape" || !open) return;
64
+ closeNow();
65
+ refocusing.current = true;
66
+ triggerRef.current?.focus();
67
+ refocusing.current = false;
68
+ };
69
+ const onBlur = (event: FocusEvent<HTMLDivElement>) => {
70
+ const next = event.relatedTarget;
71
+ if (!(next instanceof Node) || !event.currentTarget.contains(next)) closeNow();
72
+ };
73
+
74
+ return (
75
+ <div
76
+ className="knav-menu"
77
+ onMouseEnter={show}
78
+ onMouseLeave={scheduleClose}
79
+ onKeyDown={onKeyDown}
80
+ onBlur={onBlur}
81
+ >
82
+ <a
83
+ ref={triggerRef}
84
+ className="knav-btn"
85
+ href={href}
86
+ aria-expanded={open}
87
+ aria-controls={menuId}
88
+ aria-current={current ? "page" : undefined}
89
+ onFocus={() => {
90
+ if (!refocusing.current) show();
91
+ }}
92
+ >
93
+ <span className="type type-fixed ts-text-sm-medium knav-item">
94
+ {label}
95
+ <IconNavTrigger className="knav-tick" variant="chevron" />
96
+ </span>
97
+ </a>
98
+ <div id={menuId} className="knav-menu-panel" data-open={open || undefined}>
99
+ {links.map((link) => (
100
+ <a
101
+ key={link.id}
102
+ className="type type-fixed ts-text-sm-medium knav-menu-link"
103
+ href={link.href}
104
+ aria-current={link.id === current ? "page" : undefined}
105
+ >
106
+ {link.label}
107
+ </a>
108
+ ))}
109
+ </div>
110
+ </div>
111
+ );
112
+ }
package/sections/nav.css CHANGED
@@ -114,6 +114,7 @@
114
114
 
115
115
  .knav-logo:focus-visible,
116
116
  .knav-btn:focus-visible,
117
+ .knav-menu-link:focus-visible,
117
118
  .knav-mtoggle:focus-visible,
118
119
  .knav-row:focus-visible,
119
120
  .knav-sub:focus-visible,