@keystone-sites/marketing-design-system 2.0.1 → 2.0.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/package.json +1 -1
- package/src/parts/composer.css +79 -3
- package/src/parts/composer.tsx +133 -17
- package/src/parts/nav.css +8 -6
- package/src/parts/nav.tsx +1 -1
- package/src/parts/plans.css +11 -10
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@keystone-sites/marketing-design-system",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.2",
|
|
4
4
|
"description": "The Set: Keystone's marketing design system. Tokens, fonts, base styles and the parts the marketing sites are built from, as plain CSS and React.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "UNLICENSED",
|
package/src/parts/composer.css
CHANGED
|
@@ -114,13 +114,76 @@
|
|
|
114
114
|
font-size: var(--key-icon);
|
|
115
115
|
transition: background-color 120ms var(--out);
|
|
116
116
|
}
|
|
117
|
-
.ks .ks-iconbtn:hover
|
|
117
|
+
.ks .ks-iconbtn:hover,
|
|
118
|
+
.ks-prompts[data-open] .ks-iconbtn {
|
|
118
119
|
background: var(--stone);
|
|
119
120
|
}
|
|
121
|
+
.ks-iconbtn > svg {
|
|
122
|
+
transition: rotate 200ms var(--out);
|
|
123
|
+
}
|
|
124
|
+
.ks-prompts[data-open] .ks-iconbtn > svg {
|
|
125
|
+
rotate: 45deg;
|
|
126
|
+
}
|
|
127
|
+
/* The +'s prompts, a menu opened down from the bar, over whatever lies under the composer: clear
|
|
128
|
+
of its edge by 6px, past its padding (8px) and border (1px), and flush with its left side. */
|
|
129
|
+
.ks-prompts {
|
|
130
|
+
position: relative;
|
|
131
|
+
}
|
|
132
|
+
.ks-prompts__menu {
|
|
133
|
+
position: absolute;
|
|
134
|
+
top: calc(100% + 15px);
|
|
135
|
+
left: -9px;
|
|
136
|
+
z-index: 10;
|
|
137
|
+
display: grid;
|
|
138
|
+
width: max-content;
|
|
139
|
+
max-width: min(340px, calc(100vw - 32px));
|
|
140
|
+
padding: 4px;
|
|
141
|
+
background: var(--white);
|
|
142
|
+
border: 1px solid var(--line);
|
|
143
|
+
border-radius: 8px;
|
|
144
|
+
box-shadow: var(--lift-lg);
|
|
145
|
+
transform-origin: top left;
|
|
146
|
+
animation: ks-prompts-in 180ms var(--out);
|
|
147
|
+
}
|
|
148
|
+
@keyframes ks-prompts-in {
|
|
149
|
+
from {
|
|
150
|
+
opacity: 0;
|
|
151
|
+
transform: translateY(-4px) scale(0.98);
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
.ks-prompts__item {
|
|
155
|
+
padding: 9px 12px;
|
|
156
|
+
border-radius: 4px;
|
|
157
|
+
background: transparent;
|
|
158
|
+
color: var(--ink);
|
|
159
|
+
font-family: var(--sans);
|
|
160
|
+
font-size: var(--key-type);
|
|
161
|
+
line-height: 22px;
|
|
162
|
+
text-align: left;
|
|
163
|
+
transition: background-color 120ms var(--out);
|
|
164
|
+
}
|
|
165
|
+
.ks .ks-prompts__item:hover,
|
|
166
|
+
.ks .ks-prompts__item:focus-visible {
|
|
167
|
+
background: var(--paper);
|
|
168
|
+
outline: 0;
|
|
169
|
+
}
|
|
170
|
+
@media (prefers-reduced-motion: reduce) {
|
|
171
|
+
.ks-prompts__menu {
|
|
172
|
+
animation-name: ks-prompts-fade;
|
|
173
|
+
}
|
|
174
|
+
.ks-iconbtn > svg {
|
|
175
|
+
transition: none;
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
@keyframes ks-prompts-fade {
|
|
179
|
+
from {
|
|
180
|
+
opacity: 0;
|
|
181
|
+
}
|
|
182
|
+
}
|
|
120
183
|
.ks-send {
|
|
121
184
|
display: grid;
|
|
122
185
|
place-items: center;
|
|
123
|
-
width: var(--key);
|
|
186
|
+
width: calc(var(--key) * 2);
|
|
124
187
|
height: var(--key);
|
|
125
188
|
border-radius: 4px;
|
|
126
189
|
background: var(--pear-100);
|
|
@@ -176,7 +239,20 @@
|
|
|
176
239
|
background: #2c2b29;
|
|
177
240
|
color: var(--text-paper);
|
|
178
241
|
}
|
|
179
|
-
.ks-composer[data-tone="ink"] .ks-iconbtn:hover
|
|
242
|
+
.ks-composer[data-tone="ink"] .ks-iconbtn:hover,
|
|
243
|
+
.ks-composer[data-tone="ink"] .ks-prompts[data-open] .ks-iconbtn {
|
|
244
|
+
background: #3a3836;
|
|
245
|
+
}
|
|
246
|
+
.ks-composer[data-tone="ink"] .ks-prompts__menu {
|
|
247
|
+
background: #2c2b29;
|
|
248
|
+
border-color: #3a3836;
|
|
249
|
+
box-shadow: 0 24px 60px rgb(0 0 0 / 0.5);
|
|
250
|
+
}
|
|
251
|
+
.ks-composer[data-tone="ink"] .ks-prompts__item {
|
|
252
|
+
color: var(--text-paper);
|
|
253
|
+
}
|
|
254
|
+
.ks .ks-composer[data-tone="ink"] .ks-prompts__item:hover,
|
|
255
|
+
.ks .ks-composer[data-tone="ink"] .ks-prompts__item:focus-visible {
|
|
180
256
|
background: #3a3836;
|
|
181
257
|
}
|
|
182
258
|
.ks-composer[data-tone="ink"] .ks-send {
|
package/src/parts/composer.tsx
CHANGED
|
@@ -2,9 +2,11 @@
|
|
|
2
2
|
|
|
3
3
|
import {
|
|
4
4
|
type CSSProperties,
|
|
5
|
+
type KeyboardEvent,
|
|
5
6
|
type ReactNode,
|
|
6
7
|
type RefObject,
|
|
7
8
|
useEffect,
|
|
9
|
+
useId,
|
|
8
10
|
useLayoutEffect,
|
|
9
11
|
useRef,
|
|
10
12
|
useState,
|
|
@@ -100,6 +102,9 @@ export function useComposer({
|
|
|
100
102
|
return { value, setValue, load, send, focus: bring, loaded, ref };
|
|
101
103
|
}
|
|
102
104
|
|
|
105
|
+
/** A prompt the + offers: what its line in the menu says, and what lands in the composer. */
|
|
106
|
+
export type ComposerPrompt = { label: string; prompt: string };
|
|
107
|
+
|
|
103
108
|
type Props = {
|
|
104
109
|
composer: ComposerState;
|
|
105
110
|
/** What the empty line shows. */
|
|
@@ -107,11 +112,24 @@ type Props = {
|
|
|
107
112
|
tone?: "ink";
|
|
108
113
|
className?: string;
|
|
109
114
|
style?: CSSProperties;
|
|
110
|
-
/** Extra controls on the left of the bar, after
|
|
115
|
+
/** Extra controls on the left of the bar, after the +. */
|
|
111
116
|
tools?: ReactNode;
|
|
117
|
+
/** What the + offers. Without them there is no +. */
|
|
118
|
+
prompts?: readonly ComposerPrompt[];
|
|
119
|
+
/** What choosing one does. By default its prompt is dropped in. */
|
|
120
|
+
onPrompt?: (prompt: ComposerPrompt) => void;
|
|
112
121
|
};
|
|
113
122
|
|
|
114
|
-
export function Composer({
|
|
123
|
+
export function Composer({
|
|
124
|
+
composer,
|
|
125
|
+
placeholder,
|
|
126
|
+
tone,
|
|
127
|
+
className,
|
|
128
|
+
style,
|
|
129
|
+
tools,
|
|
130
|
+
prompts,
|
|
131
|
+
onPrompt,
|
|
132
|
+
}: Props) {
|
|
115
133
|
const { value, setValue, send, loaded, ref } = composer;
|
|
116
134
|
const field = useRef<HTMLTextAreaElement>(null);
|
|
117
135
|
const ready = value.trim() !== "";
|
|
@@ -160,15 +178,18 @@ export function Composer({ composer, placeholder, tone, className, style, tools
|
|
|
160
178
|
</label>
|
|
161
179
|
<div className="ks-composer__bar">
|
|
162
180
|
<div className="ks-composer__actions">
|
|
163
|
-
|
|
164
|
-
<
|
|
165
|
-
|
|
181
|
+
{prompts && prompts.length > 0 ? (
|
|
182
|
+
<Prompts
|
|
183
|
+
prompts={prompts}
|
|
184
|
+
onPick={(prompt) => {
|
|
185
|
+
if (onPrompt) onPrompt(prompt);
|
|
186
|
+
else composer.load(prompt.prompt);
|
|
187
|
+
}}
|
|
188
|
+
/>
|
|
189
|
+
) : null}
|
|
166
190
|
{tools}
|
|
167
191
|
</div>
|
|
168
192
|
<div className="ks-composer__actions">
|
|
169
|
-
<span className="ks-iconbtn" aria-hidden>
|
|
170
|
-
<Mic />
|
|
171
|
-
</span>
|
|
172
193
|
{/* Keyed by the count of prompts dropped in, so each replays the send key's nudge. */}
|
|
173
194
|
<button
|
|
174
195
|
key={loaded}
|
|
@@ -186,7 +207,110 @@ export function Composer({ composer, placeholder, tone, className, style, tools
|
|
|
186
207
|
);
|
|
187
208
|
}
|
|
188
209
|
|
|
189
|
-
|
|
210
|
+
/** The + and the menu it opens down from the bar: a line to a prompt. Arrows move through them,
|
|
211
|
+
Escape or a click away closes it, and choosing one closes it and hands the prompt on. */
|
|
212
|
+
function Prompts({
|
|
213
|
+
prompts,
|
|
214
|
+
onPick,
|
|
215
|
+
}: {
|
|
216
|
+
prompts: readonly ComposerPrompt[];
|
|
217
|
+
onPick: (prompt: ComposerPrompt) => void;
|
|
218
|
+
}) {
|
|
219
|
+
const [open, setOpen] = useState(false);
|
|
220
|
+
const root = useRef<HTMLDivElement>(null);
|
|
221
|
+
const key = useRef<HTMLButtonElement>(null);
|
|
222
|
+
const menu = useId();
|
|
223
|
+
|
|
224
|
+
const items = () => [
|
|
225
|
+
...(root.current?.querySelectorAll<HTMLButtonElement>(".ks-prompts__item") ?? []),
|
|
226
|
+
];
|
|
227
|
+
|
|
228
|
+
useEffect(() => {
|
|
229
|
+
if (!open) return;
|
|
230
|
+
root.current?.querySelector<HTMLButtonElement>(".ks-prompts__item")?.focus();
|
|
231
|
+
const away = (event: PointerEvent) => {
|
|
232
|
+
if (!root.current?.contains(event.target as Node)) setOpen(false);
|
|
233
|
+
};
|
|
234
|
+
document.addEventListener("pointerdown", away);
|
|
235
|
+
return () => {
|
|
236
|
+
document.removeEventListener("pointerdown", away);
|
|
237
|
+
};
|
|
238
|
+
}, [open]);
|
|
239
|
+
|
|
240
|
+
const close = () => {
|
|
241
|
+
setOpen(false);
|
|
242
|
+
key.current?.focus();
|
|
243
|
+
};
|
|
244
|
+
|
|
245
|
+
const onKeyDown = (event: KeyboardEvent<HTMLDivElement>) => {
|
|
246
|
+
const all = items();
|
|
247
|
+
const at = all.indexOf(document.activeElement as HTMLButtonElement);
|
|
248
|
+
const move = (to: number) => {
|
|
249
|
+
event.preventDefault();
|
|
250
|
+
all[(to + all.length) % all.length]?.focus();
|
|
251
|
+
};
|
|
252
|
+
if (event.key === "Escape") {
|
|
253
|
+
event.preventDefault();
|
|
254
|
+
close();
|
|
255
|
+
} else if (event.key === "Tab") setOpen(false);
|
|
256
|
+
else if (event.key === "ArrowDown") move(at + 1);
|
|
257
|
+
else if (event.key === "ArrowUp") move(at - 1);
|
|
258
|
+
else if (event.key === "Home") move(0);
|
|
259
|
+
else if (event.key === "End") move(all.length - 1);
|
|
260
|
+
};
|
|
261
|
+
|
|
262
|
+
return (
|
|
263
|
+
<div ref={root} className="ks-prompts" data-open={open ? "" : undefined}>
|
|
264
|
+
<button
|
|
265
|
+
ref={key}
|
|
266
|
+
type="button"
|
|
267
|
+
className="ks-iconbtn"
|
|
268
|
+
aria-label="Try a prompt"
|
|
269
|
+
aria-haspopup="menu"
|
|
270
|
+
aria-expanded={open}
|
|
271
|
+
aria-controls={open ? menu : undefined}
|
|
272
|
+
onClick={() => {
|
|
273
|
+
setOpen((was) => !was);
|
|
274
|
+
}}
|
|
275
|
+
onKeyDown={(event) => {
|
|
276
|
+
if (event.key === "ArrowDown" && !open) {
|
|
277
|
+
event.preventDefault();
|
|
278
|
+
setOpen(true);
|
|
279
|
+
}
|
|
280
|
+
}}
|
|
281
|
+
>
|
|
282
|
+
<Plus />
|
|
283
|
+
</button>
|
|
284
|
+
{open ? (
|
|
285
|
+
<div
|
|
286
|
+
id={menu}
|
|
287
|
+
className="ks-prompts__menu"
|
|
288
|
+
role="menu"
|
|
289
|
+
aria-label="Prompts to try"
|
|
290
|
+
onKeyDown={onKeyDown}
|
|
291
|
+
>
|
|
292
|
+
{prompts.map((prompt) => (
|
|
293
|
+
<button
|
|
294
|
+
key={prompt.label}
|
|
295
|
+
type="button"
|
|
296
|
+
role="menuitem"
|
|
297
|
+
tabIndex={-1}
|
|
298
|
+
className="ks-prompts__item"
|
|
299
|
+
onClick={() => {
|
|
300
|
+
setOpen(false);
|
|
301
|
+
onPick(prompt);
|
|
302
|
+
}}
|
|
303
|
+
>
|
|
304
|
+
{prompt.label}
|
|
305
|
+
</button>
|
|
306
|
+
))}
|
|
307
|
+
</div>
|
|
308
|
+
) : null}
|
|
309
|
+
</div>
|
|
310
|
+
);
|
|
311
|
+
}
|
|
312
|
+
|
|
313
|
+
// The composer's two glyphs, drawn on the 24px grid the Figma file uses.
|
|
190
314
|
const glyph = {
|
|
191
315
|
width: "1em",
|
|
192
316
|
height: "1em",
|
|
@@ -203,14 +327,6 @@ function Plus() {
|
|
|
203
327
|
</svg>
|
|
204
328
|
);
|
|
205
329
|
}
|
|
206
|
-
function Mic() {
|
|
207
|
-
return (
|
|
208
|
-
<svg {...glyph} aria-hidden>
|
|
209
|
-
<rect x="9" y="3.5" width="6" height="11" rx="3" />
|
|
210
|
-
<path d="M5.5 11.5a6.5 6.5 0 0 0 13 0M12 18v3" strokeLinecap="square" />
|
|
211
|
-
</svg>
|
|
212
|
-
);
|
|
213
|
-
}
|
|
214
330
|
function Return() {
|
|
215
331
|
return (
|
|
216
332
|
<svg {...glyph} aria-hidden>
|
package/src/parts/nav.css
CHANGED
|
@@ -40,9 +40,9 @@
|
|
|
40
40
|
padding: 2px 6px;
|
|
41
41
|
border-radius: 2px;
|
|
42
42
|
font-weight: 400;
|
|
43
|
-
font-size:
|
|
44
|
-
line-height:
|
|
45
|
-
letter-spacing: -0.
|
|
43
|
+
font-size: 14px;
|
|
44
|
+
line-height: 21px;
|
|
45
|
+
letter-spacing: -0.01em;
|
|
46
46
|
color: var(--ink);
|
|
47
47
|
transition: color 120ms var(--out);
|
|
48
48
|
}
|
|
@@ -207,7 +207,9 @@
|
|
|
207
207
|
translate: none;
|
|
208
208
|
}
|
|
209
209
|
}
|
|
210
|
-
/* The way in, in the phone's menu only. */
|
|
211
|
-
|
|
212
|
-
|
|
210
|
+
/* The way in, last of the links: a link like the rest, with the arrow in the phone's menu only. */
|
|
211
|
+
@media (min-width: 721px) {
|
|
212
|
+
.ks-nav__login > svg {
|
|
213
|
+
display: none;
|
|
214
|
+
}
|
|
213
215
|
}
|
package/src/parts/nav.tsx
CHANGED
|
@@ -12,7 +12,7 @@ type Props = {
|
|
|
12
12
|
home: NavLink;
|
|
13
13
|
/** A link to `#id` glides to that section; any other is followed. */
|
|
14
14
|
links: readonly NavLink[];
|
|
15
|
-
/** The way in for a customer,
|
|
15
|
+
/** The way in for a customer, after the links. */
|
|
16
16
|
login: NavLink;
|
|
17
17
|
/** The key at the end: a handler, or a page to go to. */
|
|
18
18
|
cta: { label: string } & ({ onClick: () => void } | { href: string });
|
package/src/parts/plans.css
CHANGED
|
@@ -9,8 +9,8 @@
|
|
|
9
9
|
.ks-plan {
|
|
10
10
|
display: flex;
|
|
11
11
|
flex-direction: column;
|
|
12
|
-
gap: calc(var(--u) * 0.
|
|
13
|
-
padding: var(--u);
|
|
12
|
+
gap: calc(var(--u) * 0.5);
|
|
13
|
+
padding: calc(var(--u) * 0.7);
|
|
14
14
|
min-height: calc(var(--u) * 12);
|
|
15
15
|
}
|
|
16
16
|
.ks-plan + .ks-plan {
|
|
@@ -31,13 +31,13 @@
|
|
|
31
31
|
gap: 8px;
|
|
32
32
|
font-family: var(--serif);
|
|
33
33
|
font-weight: 200;
|
|
34
|
-
font-size: calc(var(--u) *
|
|
34
|
+
font-size: calc(var(--u) * 1.5);
|
|
35
35
|
line-height: 1;
|
|
36
36
|
letter-spacing: -0.03em;
|
|
37
37
|
}
|
|
38
38
|
.ks-plan__price small {
|
|
39
39
|
font-family: var(--sans);
|
|
40
|
-
font-size: var(--
|
|
40
|
+
font-size: max(14px, calc(var(--u) * 0.35));
|
|
41
41
|
letter-spacing: 0;
|
|
42
42
|
color: var(--muted);
|
|
43
43
|
}
|
|
@@ -47,13 +47,14 @@
|
|
|
47
47
|
.ks-plan__for {
|
|
48
48
|
font-family: var(--ext);
|
|
49
49
|
font-weight: 500;
|
|
50
|
-
font-size: calc(var(--u) * 0.
|
|
50
|
+
font-size: max(16px, calc(var(--u) * 0.42));
|
|
51
51
|
line-height: 1.25;
|
|
52
52
|
}
|
|
53
53
|
.ks-plan__list {
|
|
54
54
|
display: grid;
|
|
55
|
-
gap:
|
|
56
|
-
font-size: var(--
|
|
55
|
+
gap: 6px;
|
|
56
|
+
font-size: max(14px, calc(var(--u) * 0.35));
|
|
57
|
+
line-height: 1.45;
|
|
57
58
|
color: var(--soft);
|
|
58
59
|
}
|
|
59
60
|
.ks-plan[data-featured] .ks-plan__list {
|
|
@@ -61,14 +62,14 @@
|
|
|
61
62
|
}
|
|
62
63
|
.ks-plan__list li {
|
|
63
64
|
display: grid;
|
|
64
|
-
grid-template-columns:
|
|
65
|
+
grid-template-columns: 5px 1fr;
|
|
65
66
|
gap: 10px;
|
|
66
67
|
align-items: baseline;
|
|
67
68
|
}
|
|
68
69
|
.ks-plan__list li::before {
|
|
69
70
|
content: "";
|
|
70
|
-
width:
|
|
71
|
-
height:
|
|
71
|
+
width: 5px;
|
|
72
|
+
height: 5px;
|
|
72
73
|
background: currentColor;
|
|
73
74
|
translate: 0 -1px;
|
|
74
75
|
}
|