@keystone-sites/marketing-design-system 1.0.13 → 1.0.14
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
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@keystone-sites/marketing-design-system",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.14",
|
|
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": {
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
/* Disclosure: a hairline row that opens a body beneath it. Stacked
|
|
2
2
|
disclosures share dividers through .rows. The filter is a toolbar
|
|
3
3
|
trigger with a popover checklist; `.check` is the bare checkbox both
|
|
4
|
-
the checklist and dense tables use
|
|
5
|
-
|
|
4
|
+
the checklist and dense tables use, and round as a radio in the menu
|
|
5
|
+
of one choice. The trigger and the popover frame (`.filter-trigger`,
|
|
6
|
+
`.filter-menu`) are shared with the choice menu and the month range. */
|
|
6
7
|
|
|
7
8
|
/* Designed constants for this file. */
|
|
8
9
|
:root {
|
|
@@ -99,6 +100,12 @@
|
|
|
99
100
|
transition-duration: var(--motion-hover-duration);
|
|
100
101
|
transition-timing-function: var(--motion-hover-ease);
|
|
101
102
|
}
|
|
103
|
+
.check[type="radio"] {
|
|
104
|
+
border-radius: var(--radius-full);
|
|
105
|
+
}
|
|
106
|
+
.check[type="radio"]:checked {
|
|
107
|
+
background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12'%3E%3Ccircle cx='6' cy='6' r='2.5' fill='%23f8f7f2'/%3E%3C/svg%3E");
|
|
108
|
+
}
|
|
102
109
|
.check:checked,
|
|
103
110
|
.check:indeterminate {
|
|
104
111
|
background: var(--color-teal-500);
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
|
|
3
|
-
/** Disclosure: a row that opens a body beneath it, and
|
|
4
|
-
* checkboxes for
|
|
3
|
+
/** Disclosure: a row that opens a body beneath it, and the toolbar
|
|
4
|
+
* popovers: a menu of checkboxes for filters and a menu of one choice.
|
|
5
|
+
* Styles live in disclosure.css. */
|
|
5
6
|
|
|
6
7
|
import { useId, useState, type ReactNode } from "react";
|
|
7
8
|
import { IconChevronDownSmall, IconSearchGlyph } from "../icons";
|
|
@@ -222,3 +223,55 @@ export function FilterMenu<T extends string>({
|
|
|
222
223
|
</div>
|
|
223
224
|
);
|
|
224
225
|
}
|
|
226
|
+
|
|
227
|
+
/** A button named for the one option chosen, opening the list to choose
|
|
228
|
+
* another; the consumer owns the choice. For a view's few modes (a
|
|
229
|
+
* total or a rate, a sort), where a filter would check all but one. */
|
|
230
|
+
export function ChoiceMenu<T extends string>({
|
|
231
|
+
label,
|
|
232
|
+
options,
|
|
233
|
+
value,
|
|
234
|
+
onChange,
|
|
235
|
+
}: {
|
|
236
|
+
label: string;
|
|
237
|
+
options: readonly FilterOption<T>[];
|
|
238
|
+
value: T;
|
|
239
|
+
onChange: (next: T) => void;
|
|
240
|
+
}) {
|
|
241
|
+
const { open, setOpen, rootRef } = usePopover<HTMLDivElement>();
|
|
242
|
+
const menuId = useId();
|
|
243
|
+
const name = useId();
|
|
244
|
+
const chosen = options.find((o) => o.value === value)?.label ?? value;
|
|
245
|
+
return (
|
|
246
|
+
<div className="filter" ref={rootRef}>
|
|
247
|
+
<FilterTrigger
|
|
248
|
+
label={chosen}
|
|
249
|
+
name={`${label}: ${chosen}`}
|
|
250
|
+
open={open}
|
|
251
|
+
menuId={menuId}
|
|
252
|
+
onToggle={() => setOpen((v) => !v)}
|
|
253
|
+
/>
|
|
254
|
+
{open && (
|
|
255
|
+
<div className="filter-menu" id={menuId} role="radiogroup" aria-label={label}>
|
|
256
|
+
<div className="filter-options">
|
|
257
|
+
{options.map((option) => (
|
|
258
|
+
<label key={option.value} className="type type-fixed ts-text-sm-light filter-option">
|
|
259
|
+
<input
|
|
260
|
+
type="radio"
|
|
261
|
+
className="check"
|
|
262
|
+
name={name}
|
|
263
|
+
checked={option.value === value}
|
|
264
|
+
onChange={() => {
|
|
265
|
+
onChange(option.value);
|
|
266
|
+
setOpen(false);
|
|
267
|
+
}}
|
|
268
|
+
/>
|
|
269
|
+
<span>{option.label}</span>
|
|
270
|
+
</label>
|
|
271
|
+
))}
|
|
272
|
+
</div>
|
|
273
|
+
</div>
|
|
274
|
+
)}
|
|
275
|
+
</div>
|
|
276
|
+
);
|
|
277
|
+
}
|