@keystone-sites/marketing-design-system 1.0.8 → 1.0.10
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/index.css +1 -0
- package/package.json +3 -1
- package/primitives/grader.css +6 -8
- package/sections/nav-menu.css +57 -0
- package/sections/nav-menu.tsx +112 -0
- package/sections/nav.css +1 -0
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.
|
|
3
|
+
"version": "1.0.10",
|
|
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",
|
package/primitives/grader.css
CHANGED
|
@@ -182,7 +182,12 @@
|
|
|
182
182
|
}
|
|
183
183
|
|
|
184
184
|
/* The suggestion menu overlays following content without shifting layout.
|
|
185
|
-
|
|
185
|
+
It fits its rows; the search hook already caps how many each group shows.
|
|
186
|
+
Sections are their own stacking contexts (grid/engine.css), so the one
|
|
187
|
+
hosting an open menu rises above the sections that follow it. */
|
|
188
|
+
.sec:has(.grader[data-open]) {
|
|
189
|
+
z-index: var(--z-raised);
|
|
190
|
+
}
|
|
186
191
|
.grader-menu {
|
|
187
192
|
--_menu-name-font: var(--ts-text-md-medium-font);
|
|
188
193
|
--_menu-name-ls: var(--ts-text-md-medium-ls);
|
|
@@ -200,13 +205,6 @@
|
|
|
200
205
|
gap: var(--space-xs);
|
|
201
206
|
margin: var(--space-none);
|
|
202
207
|
padding: var(--space-md);
|
|
203
|
-
max-height: calc(
|
|
204
|
-
var(--space-md) * 2 + var(--space-sm) + 12px + var(--space-xs) +
|
|
205
|
-
(5 * (var(--space-sm) + 44px + var(--space-md))) + (4 * var(--space-xs))
|
|
206
|
-
);
|
|
207
|
-
overflow-x: hidden;
|
|
208
|
-
overflow-y: auto;
|
|
209
|
-
overscroll-behavior: contain;
|
|
210
208
|
background: var(--color-bg-000);
|
|
211
209
|
border: 1px solid var(--color-border-000);
|
|
212
210
|
border-radius: var(--radius-xl);
|
|
@@ -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
|
+
}
|