@softure-ai/theme-notion 0.1.1 → 0.3.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.
- package/CHANGELOG.md +178 -0
- package/README.md +239 -12
- package/dist/index.d.ts +12 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +12 -0
- package/dist/index.js.map +1 -1
- package/dist/messages/en.d.ts +20 -0
- package/dist/messages/en.d.ts.map +1 -1
- package/dist/messages/en.js +11 -0
- package/dist/messages/en.js.map +1 -1
- package/dist/messages/index.d.ts +20 -0
- package/dist/messages/index.d.ts.map +1 -1
- package/dist/notion/Code.d.ts +8 -0
- package/dist/notion/Code.d.ts.map +1 -0
- package/dist/notion/Code.js +12 -0
- package/dist/notion/Code.js.map +1 -0
- package/dist/notion/DetailTable.d.ts +15 -0
- package/dist/notion/DetailTable.d.ts.map +1 -0
- package/dist/notion/DetailTable.js +20 -0
- package/dist/notion/DetailTable.js.map +1 -0
- package/dist/notion/FilterChip.d.ts +24 -0
- package/dist/notion/FilterChip.d.ts.map +1 -0
- package/dist/notion/FilterChip.js +18 -0
- package/dist/notion/FilterChip.js.map +1 -0
- package/dist/notion/FoldRow.d.ts +23 -0
- package/dist/notion/FoldRow.d.ts.map +1 -0
- package/dist/notion/FoldRow.js +14 -0
- package/dist/notion/FoldRow.js.map +1 -0
- package/dist/notion/MarkPopover.d.ts +19 -0
- package/dist/notion/MarkPopover.d.ts.map +1 -0
- package/dist/notion/MarkPopover.js +22 -0
- package/dist/notion/MarkPopover.js.map +1 -0
- package/dist/notion/PageHeader.d.ts +2 -1
- package/dist/notion/PageHeader.d.ts.map +1 -1
- package/dist/notion/PageHeader.js +2 -2
- package/dist/notion/PageHeader.js.map +1 -1
- package/dist/notion/SidePanel.d.ts +13 -0
- package/dist/notion/SidePanel.d.ts.map +1 -0
- package/dist/notion/SidePanel.js +28 -0
- package/dist/notion/SidePanel.js.map +1 -0
- package/dist/notion/Sortable.d.ts +36 -0
- package/dist/notion/Sortable.d.ts.map +1 -0
- package/dist/notion/Sortable.js +83 -0
- package/dist/notion/Sortable.js.map +1 -0
- package/dist/notion/Stats.d.ts +49 -0
- package/dist/notion/Stats.d.ts.map +1 -0
- package/dist/notion/Stats.js +38 -0
- package/dist/notion/Stats.js.map +1 -0
- package/dist/notion/Steps.d.ts +18 -0
- package/dist/notion/Steps.d.ts.map +1 -0
- package/dist/notion/Steps.js +32 -0
- package/dist/notion/Steps.js.map +1 -0
- package/dist/notion/TabBar.d.ts +15 -0
- package/dist/notion/TabBar.d.ts.map +1 -0
- package/dist/notion/TabBar.js +6 -0
- package/dist/notion/TabBar.js.map +1 -0
- package/dist/notion/tones.d.ts +8 -0
- package/dist/notion/tones.d.ts.map +1 -0
- package/dist/notion/tones.js +37 -0
- package/dist/notion/tones.js.map +1 -0
- package/dist/page.css +22 -0
- package/dist/theme.css +55 -46
- package/dist/tokens.d.ts +82 -64
- package/dist/tokens.d.ts.map +1 -1
- package/dist/tokens.js +22 -19
- package/dist/tokens.js.map +1 -1
- package/dist/ui/alert.js +1 -1
- package/dist/ui/alert.js.map +1 -1
- package/dist/ui/badge.d.ts +1 -1
- package/dist/ui/badge.d.ts.map +1 -1
- package/dist/ui/badge.js +33 -13
- package/dist/ui/badge.js.map +1 -1
- package/dist/ui/button-group.js +1 -1
- package/dist/ui/button-group.js.map +1 -1
- package/dist/ui/button.d.ts +1 -1
- package/dist/ui/button.js +3 -3
- package/dist/ui/button.js.map +1 -1
- package/dist/ui/checkbox.js +1 -1
- package/dist/ui/checkbox.js.map +1 -1
- package/dist/ui/dropdown-menu.js +1 -1
- package/dist/ui/empty.js +1 -1
- package/dist/ui/empty.js.map +1 -1
- package/dist/ui/field.js +2 -2
- package/dist/ui/field.js.map +1 -1
- package/dist/ui/item.d.ts.map +1 -1
- package/dist/ui/item.js +8 -3
- package/dist/ui/item.js.map +1 -1
- package/dist/ui/progress.d.ts +4 -1
- package/dist/ui/progress.d.ts.map +1 -1
- package/dist/ui/progress.js +9 -2
- package/dist/ui/progress.js.map +1 -1
- package/dist/ui/radio-group.d.ts +6 -0
- package/dist/ui/radio-group.d.ts.map +1 -0
- package/dist/ui/radio-group.js +14 -0
- package/dist/ui/radio-group.js.map +1 -0
- package/dist/ui/scroll-area.d.ts +3 -1
- package/dist/ui/scroll-area.d.ts.map +1 -1
- package/dist/ui/scroll-area.js +2 -2
- package/dist/ui/scroll-area.js.map +1 -1
- package/dist/ui/select.js +2 -2
- package/dist/ui/select.js.map +1 -1
- package/dist/ui/sidebar.js +4 -4
- package/dist/ui/sidebar.js.map +1 -1
- package/dist/ui/tabs.js +1 -1
- package/dist/ui/tabs.js.map +1 -1
- package/package.json +16 -5
- package/src/index.ts +32 -0
- package/src/messages/en.ts +12 -0
- package/src/notion/Code.tsx +39 -0
- package/src/notion/DetailTable.tsx +46 -0
- package/src/notion/FilterChip.tsx +71 -0
- package/src/notion/FoldRow.tsx +78 -0
- package/src/notion/MarkPopover.tsx +84 -0
- package/src/notion/PageHeader.tsx +4 -2
- package/src/notion/SidePanel.tsx +73 -0
- package/src/notion/Sortable.tsx +235 -0
- package/src/notion/Stats.tsx +165 -0
- package/src/notion/Steps.tsx +102 -0
- package/src/notion/TabBar.tsx +47 -0
- package/src/notion/tones.ts +45 -0
- package/src/page.css +22 -0
- package/src/tokens.ts +22 -19
- package/src/ui/alert.tsx +1 -1
- package/src/ui/badge.tsx +35 -13
- package/src/ui/button-group.tsx +1 -1
- package/src/ui/button.tsx +3 -3
- package/src/ui/checkbox.tsx +1 -1
- package/src/ui/dropdown-menu.tsx +1 -1
- package/src/ui/empty.tsx +1 -1
- package/src/ui/field.tsx +2 -2
- package/src/ui/item.tsx +16 -7
- package/src/ui/progress.tsx +19 -2
- package/src/ui/radio-group.tsx +44 -0
- package/src/ui/scroll-area.tsx +11 -2
- package/src/ui/select.tsx +2 -2
- package/src/ui/sidebar.tsx +4 -4
- package/src/ui/tabs.tsx +3 -3
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@softure-ai/theme-notion",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0",
|
|
4
4
|
"description": "SOFTURE AI Notion theme: shadcn/ui components (new-york v4, Radix, Tailwind CSS v4, lucide) with the Notion design system's tokens and deltas, ready to import.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -33,7 +33,8 @@
|
|
|
33
33
|
"default": "./dist/index.js"
|
|
34
34
|
},
|
|
35
35
|
"./theme.css": "./dist/theme.css",
|
|
36
|
-
"./sft-bridge.css": "./dist/sft-bridge.css"
|
|
36
|
+
"./sft-bridge.css": "./dist/sft-bridge.css",
|
|
37
|
+
"./page.css": "./dist/page.css"
|
|
37
38
|
},
|
|
38
39
|
"softureTheme": {
|
|
39
40
|
"sources": [
|
|
@@ -44,14 +45,20 @@
|
|
|
44
45
|
"tw-animate-css"
|
|
45
46
|
],
|
|
46
47
|
"stylesheets": [
|
|
47
|
-
"sft-bridge.css"
|
|
48
|
+
"sft-bridge.css",
|
|
49
|
+
"page.css"
|
|
48
50
|
]
|
|
49
51
|
},
|
|
50
52
|
"scripts": {
|
|
51
|
-
"build": "tsc -p tsconfig.build.json && softure-theme-css"
|
|
53
|
+
"build": "tsc -p tsconfig.build.json && softure-theme-css",
|
|
54
|
+
"test:visual": "NODE_OPTIONS=--conditions=@softure-ai/source playwright test",
|
|
55
|
+
"test:coverage": "vitest run --root ../.. themes/theme-notion --coverage.enabled --coverage.provider=v8 --coverage.include='themes/theme-notion/src/**' --coverage.reportsDirectory=coverage/theme-notion --coverage.thresholds.statements=90 --coverage.thresholds.branches=90"
|
|
52
56
|
},
|
|
53
57
|
"dependencies": {
|
|
54
|
-
"@
|
|
58
|
+
"@dnd-kit/core": "^6.3.1",
|
|
59
|
+
"@dnd-kit/sortable": "^10.0.0",
|
|
60
|
+
"@dnd-kit/utilities": "^3.2.2",
|
|
61
|
+
"@softure-ai/theme-kit": "^0.1.3",
|
|
55
62
|
"class-variance-authority": "^0.7.1",
|
|
56
63
|
"cmdk": "^1.1.1",
|
|
57
64
|
"lucide-react": "^1.61.0",
|
|
@@ -65,6 +72,10 @@
|
|
|
65
72
|
"tailwindcss": "^4.0.0"
|
|
66
73
|
},
|
|
67
74
|
"devDependencies": {
|
|
75
|
+
"@axe-core/playwright": "^4.14.0",
|
|
76
|
+
"@fontsource/inter": "^5.3.0",
|
|
77
|
+
"@fontsource/jetbrains-mono": "^5.3.0",
|
|
78
|
+
"@playwright/test": "^1.63.0",
|
|
68
79
|
"@softure-ai/ui": "^0.3.4",
|
|
69
80
|
"zod": "^4.6.5"
|
|
70
81
|
}
|
package/src/index.ts
CHANGED
|
@@ -27,6 +27,7 @@ export * from "./ui/kbd.js";
|
|
|
27
27
|
export * from "./ui/label.js";
|
|
28
28
|
export * from "./ui/popover.js";
|
|
29
29
|
export * from "./ui/progress.js";
|
|
30
|
+
export * from "./ui/radio-group.js";
|
|
30
31
|
export * from "./ui/scroll-area.js";
|
|
31
32
|
export * from "./ui/select.js";
|
|
32
33
|
export * from "./ui/separator.js";
|
|
@@ -43,8 +44,39 @@ export * from "./ui/textarea.js";
|
|
|
43
44
|
export * from "./ui/tooltip.js";
|
|
44
45
|
|
|
45
46
|
export { ICON_STROKE_WIDTH } from "./notion/icon-stroke.js";
|
|
47
|
+
export { Code, CodeBlock, type CodeBlockProps } from "./notion/Code.js";
|
|
48
|
+
export { DetailTable, type DetailRow, type DetailTableProps } from "./notion/DetailTable.js";
|
|
49
|
+
export { FilterChip, FilterChipAdd, type FilterChipAddProps, type FilterChipProps } from "./notion/FilterChip.js";
|
|
50
|
+
export { FoldRow, type FoldRowBadge, type FoldRowProps } from "./notion/FoldRow.js";
|
|
46
51
|
export { PALETTE_COLORS, type PaletteColor } from "./notion/palette.js";
|
|
52
|
+
export { MarkPopover, type MarkPopoverProps } from "./notion/MarkPopover.js";
|
|
47
53
|
export { PageFrame, type PageFrameProps } from "./notion/PageFrame.js";
|
|
48
54
|
export { PageHeader, type PageCrumb, type PageHeaderProps } from "./notion/PageHeader.js";
|
|
49
55
|
export { PropertyList, type Property, type PropertyListProps } from "./notion/PropertyList.js";
|
|
56
|
+
export { SidePanel, type SidePanelLayout, type SidePanelProps } from "./notion/SidePanel.js";
|
|
57
|
+
export {
|
|
58
|
+
SortableHandle,
|
|
59
|
+
SortableItem,
|
|
60
|
+
SortableList,
|
|
61
|
+
type SortableAnnouncements,
|
|
62
|
+
type SortableDragBy,
|
|
63
|
+
type SortableHandleProps,
|
|
64
|
+
type SortableItemProps,
|
|
65
|
+
type SortableListProps,
|
|
66
|
+
type SortableMove,
|
|
67
|
+
} from "./notion/Sortable.js";
|
|
68
|
+
export {
|
|
69
|
+
StatCards,
|
|
70
|
+
StatPills,
|
|
71
|
+
StatsFold,
|
|
72
|
+
type StatCard,
|
|
73
|
+
type StatCardAside,
|
|
74
|
+
type StatCardsProps,
|
|
75
|
+
type StatPill,
|
|
76
|
+
type StatPillsProps,
|
|
77
|
+
type StatsFoldProps,
|
|
78
|
+
} from "./notion/Stats.js";
|
|
50
79
|
export { Status, type StatusProps } from "./notion/Status.js";
|
|
80
|
+
export { Steps, type StepItem, type StepState, type StepsLayout, type StepsProps } from "./notion/Steps.js";
|
|
81
|
+
export { TabBar, type TabBarItem, type TabBarProps } from "./notion/TabBar.js";
|
|
82
|
+
export { TONES, TONE_COLORS, TONE_EDGE, TONE_FILL, TONE_TEXT, type Tone } from "./notion/tones.js";
|
package/src/messages/en.ts
CHANGED
|
@@ -5,8 +5,20 @@
|
|
|
5
5
|
export const en = {
|
|
6
6
|
breadcrumb: { label: "breadcrumb", more: "More" },
|
|
7
7
|
dialog: { close: "Close" },
|
|
8
|
+
filterChip: { add: "Add filter" },
|
|
8
9
|
sheet: { close: "Close" },
|
|
10
|
+
sidePanel: { close: "Close" },
|
|
9
11
|
sidebar: { mobileTitle: "Sidebar", mobileDescription: "Displays the mobile sidebar.", toggle: "Toggle Sidebar" },
|
|
10
12
|
spinner: { label: "Loading" },
|
|
13
|
+
sortable: {
|
|
14
|
+
instructions:
|
|
15
|
+
"To pick up a row, press Space or Enter. Use the arrow keys to move it, then press Space or Enter to drop it, or Escape to cancel.",
|
|
16
|
+
pickedUp: "Picked up {item}, position {position} of {total}.",
|
|
17
|
+
moved: "{item} moved to position {position} of {total}.",
|
|
18
|
+
dropped: "Dropped {item} at position {position} of {total}.",
|
|
19
|
+
cancelled: "Cancelled. {item} is back in place.",
|
|
20
|
+
handle: "Drag to reorder",
|
|
21
|
+
},
|
|
22
|
+
steps: { done: "Done", current: "Current", todo: "To do", failed: "Failed" },
|
|
11
23
|
command: { title: "Command Palette", description: "Search for a command to run..." },
|
|
12
24
|
} as const;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import type { ComponentProps } from "react";
|
|
2
|
+
|
|
3
|
+
import { cn } from "../lib/utils.js";
|
|
4
|
+
|
|
5
|
+
// Inline code: the `code` text style in mono, red on the grey `secondary` background, as in Notion.
|
|
6
|
+
export function Code({ className, ...props }: ComponentProps<"code">) {
|
|
7
|
+
return (
|
|
8
|
+
<code
|
|
9
|
+
data-slot="code"
|
|
10
|
+
className={cn("rounded-xs bg-secondary px-1 font-mono text-code text-code-foreground", className)}
|
|
11
|
+
{...props}
|
|
12
|
+
/>
|
|
13
|
+
);
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export interface CodeBlockProps extends ComponentProps<"pre"> {
|
|
17
|
+
// The block's accessible name; with it the block is a named region keyboard users can focus and scroll.
|
|
18
|
+
readonly label?: string;
|
|
19
|
+
// Wrap long lines instead of scrolling sideways.
|
|
20
|
+
readonly wrap?: boolean;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
// A mono block for logs and file paths, without syntax highlighting.
|
|
24
|
+
export function CodeBlock({ label, wrap = false, className, ...props }: CodeBlockProps) {
|
|
25
|
+
const region = label === undefined ? {} : { role: "region", "aria-label": label, tabIndex: 0 };
|
|
26
|
+
return (
|
|
27
|
+
<pre
|
|
28
|
+
data-slot="code-block"
|
|
29
|
+
data-wrap={wrap ? "" : undefined}
|
|
30
|
+
className={cn(
|
|
31
|
+
"overflow-x-auto rounded-lg bg-muted px-4 py-3 font-mono text-code",
|
|
32
|
+
wrap ? "whitespace-pre-wrap break-words" : "whitespace-pre",
|
|
33
|
+
className,
|
|
34
|
+
)}
|
|
35
|
+
{...region}
|
|
36
|
+
{...props}
|
|
37
|
+
/>
|
|
38
|
+
);
|
|
39
|
+
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import type { ReactNode } from "react";
|
|
2
|
+
|
|
3
|
+
export interface DetailRow {
|
|
4
|
+
/** Unique within the table; kept on the row as `data-detail`. */
|
|
5
|
+
readonly key: string;
|
|
6
|
+
readonly label: string;
|
|
7
|
+
/** `null`, `undefined` or "": nothing to show, the row is left out. */
|
|
8
|
+
readonly value: ReactNode;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export interface DetailTableProps {
|
|
12
|
+
/** The table's accessible name. */
|
|
13
|
+
readonly label: string;
|
|
14
|
+
readonly rows: readonly DetailRow[];
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
// A row header in a narrow muted column, a quiet line under every row; on a phone the label sits above its value.
|
|
18
|
+
const DETAIL_TABLE_CLASS = [
|
|
19
|
+
"w-full border-collapse text-ui",
|
|
20
|
+
"[&_tr]:border-b [&_tr]:border-border",
|
|
21
|
+
"[&_th]:w-48 [&_th]:py-1.5 [&_th]:pr-3 [&_th]:text-left [&_th]:align-top [&_th]:font-normal [&_th]:text-muted-foreground",
|
|
22
|
+
"[&_td]:py-1.5 [&_td]:align-top [&_td]:wrap-anywhere",
|
|
23
|
+
"max-sm:[&_tr]:block max-sm:[&_tr]:py-1.5 max-sm:[&_th]:block max-sm:[&_th]:w-auto max-sm:[&_th]:py-0 max-sm:[&_td]:block max-sm:[&_td]:py-0",
|
|
24
|
+
].join(" ");
|
|
25
|
+
|
|
26
|
+
function hasValue(row: DetailRow): boolean {
|
|
27
|
+
return row.value !== null && row.value !== undefined && row.value !== "";
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
// An item's details as a label and value table in the Notion table style; nothing renders when no row has a value.
|
|
31
|
+
export function DetailTable({ label, rows }: DetailTableProps) {
|
|
32
|
+
const shown = rows.filter(hasValue);
|
|
33
|
+
if (shown.length === 0) return null;
|
|
34
|
+
return (
|
|
35
|
+
<table data-slot="detail-table" className={DETAIL_TABLE_CLASS} aria-label={label}>
|
|
36
|
+
<tbody>
|
|
37
|
+
{shown.map((row) => (
|
|
38
|
+
<tr key={row.key} data-detail={row.key}>
|
|
39
|
+
<th scope="row">{row.label}</th>
|
|
40
|
+
<td>{row.value}</td>
|
|
41
|
+
</tr>
|
|
42
|
+
))}
|
|
43
|
+
</tbody>
|
|
44
|
+
</table>
|
|
45
|
+
);
|
|
46
|
+
}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import { ChevronDown, Plus } from "lucide-react";
|
|
2
|
+
import type { ReactNode } from "react";
|
|
3
|
+
|
|
4
|
+
import { en as messages } from "../messages/en.js";
|
|
5
|
+
import { DropdownMenu, DropdownMenuContent, DropdownMenuTrigger } from "../ui/dropdown-menu.js";
|
|
6
|
+
import { cn } from "../lib/utils.js";
|
|
7
|
+
|
|
8
|
+
import { ICON_STROKE_WIDTH } from "./icon-stroke.js";
|
|
9
|
+
|
|
10
|
+
export interface FilterChipProps {
|
|
11
|
+
/** The filtered field, as shown before the value: "Status:". */
|
|
12
|
+
readonly label: string;
|
|
13
|
+
/** The chosen option's text; the app's word for "all" when none is chosen. */
|
|
14
|
+
readonly value: string;
|
|
15
|
+
/** Drawn before the label; the caller hides it from assistive technology. */
|
|
16
|
+
readonly icon?: ReactNode;
|
|
17
|
+
/** A non-default value is chosen: the pill turns into the blue tag. */
|
|
18
|
+
readonly isActive?: boolean;
|
|
19
|
+
/** The options, as `DropdownMenu` items (radio items for one choice). */
|
|
20
|
+
readonly children: ReactNode;
|
|
21
|
+
readonly className?: string;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export interface FilterChipAddProps {
|
|
25
|
+
/** The pill's text; default "Add filter". */
|
|
26
|
+
readonly label?: string;
|
|
27
|
+
/** The fields that can be filtered, as `DropdownMenu` items. */
|
|
28
|
+
readonly children: ReactNode;
|
|
29
|
+
readonly className?: string;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
const PILL_CLASS =
|
|
33
|
+
"inline-flex h-6 shrink-0 cursor-pointer items-center gap-1 rounded-full px-2 text-sm whitespace-nowrap text-muted-foreground transition-colors duration-120 outline-none hover:bg-accent focus-visible:ring-2 focus-visible:ring-ring data-[state=open]:bg-accent [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-3.5";
|
|
34
|
+
|
|
35
|
+
const ACTIVE_CLASS =
|
|
36
|
+
"data-[active]:bg-blue-tag data-[active]:text-blue-tag-foreground data-[active]:hover:bg-blue-tag data-[active]:data-[state=open]:bg-blue-tag";
|
|
37
|
+
|
|
38
|
+
// A list filter drawn the way a Notion database view draws it: a small pill `icon · Label: value ▾` above a table
|
|
39
|
+
// that opens a menu of options in the design system's popover.
|
|
40
|
+
export function FilterChip({ label, value, icon, isActive = false, children, className }: FilterChipProps) {
|
|
41
|
+
return (
|
|
42
|
+
<DropdownMenu>
|
|
43
|
+
<DropdownMenuTrigger
|
|
44
|
+
data-slot="filter-chip"
|
|
45
|
+
data-active={isActive ? "" : undefined}
|
|
46
|
+
className={cn(PILL_CLASS, ACTIVE_CLASS, className)}
|
|
47
|
+
>
|
|
48
|
+
{icon}
|
|
49
|
+
<span>{label}</span>
|
|
50
|
+
<span data-slot="filter-chip-value" className="font-medium">
|
|
51
|
+
{value}
|
|
52
|
+
</span>
|
|
53
|
+
<ChevronDown aria-hidden="true" strokeWidth={ICON_STROKE_WIDTH} />
|
|
54
|
+
</DropdownMenuTrigger>
|
|
55
|
+
<DropdownMenuContent align="start">{children}</DropdownMenuContent>
|
|
56
|
+
</DropdownMenu>
|
|
57
|
+
);
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
// The "+ Add filter" pill next to the filters: the same height, a ghost look, a menu of the fields to filter by.
|
|
61
|
+
export function FilterChipAdd({ label = messages.filterChip.add, children, className }: FilterChipAddProps) {
|
|
62
|
+
return (
|
|
63
|
+
<DropdownMenu>
|
|
64
|
+
<DropdownMenuTrigger data-slot="filter-chip-add" className={cn(PILL_CLASS, className)}>
|
|
65
|
+
<Plus aria-hidden="true" strokeWidth={ICON_STROKE_WIDTH} />
|
|
66
|
+
<span>{label}</span>
|
|
67
|
+
</DropdownMenuTrigger>
|
|
68
|
+
<DropdownMenuContent align="start">{children}</DropdownMenuContent>
|
|
69
|
+
</DropdownMenu>
|
|
70
|
+
);
|
|
71
|
+
}
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import { ChevronRight } from "lucide-react";
|
|
2
|
+
import type { ReactNode } from "react";
|
|
3
|
+
|
|
4
|
+
import { Badge } from "../ui/badge.js";
|
|
5
|
+
|
|
6
|
+
import { DetailTable, type DetailRow } from "./DetailTable.js";
|
|
7
|
+
import { ICON_STROKE_WIDTH } from "./icon-stroke.js";
|
|
8
|
+
import { TONE_COLORS, type Tone } from "./tones.js";
|
|
9
|
+
|
|
10
|
+
export interface FoldRowBadge {
|
|
11
|
+
/** Unique within the row; kept on the badge as `data-badge`. */
|
|
12
|
+
readonly key: string;
|
|
13
|
+
readonly text: string;
|
|
14
|
+
readonly tone?: Tone;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export interface FoldRowProps {
|
|
18
|
+
readonly title: ReactNode;
|
|
19
|
+
/** Short facts after the title; left out when empty. */
|
|
20
|
+
readonly facts?: readonly ReactNode[];
|
|
21
|
+
/** Badges on the row's right, in order. */
|
|
22
|
+
readonly badges: readonly FoldRowBadge[];
|
|
23
|
+
/** The details table's accessible name. */
|
|
24
|
+
readonly detailsLabel: string;
|
|
25
|
+
readonly details: readonly DetailRow[];
|
|
26
|
+
/** More content under the table when opened. */
|
|
27
|
+
readonly children?: ReactNode;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
// An item as one folding list row: a native `<details>` that opens in place to its details, with no client state.
|
|
31
|
+
export function FoldRow({ title, facts = [], badges, detailsLabel, details, children }: FoldRowProps) {
|
|
32
|
+
return (
|
|
33
|
+
<details data-slot="fold-row" className="group/fold-row border-b border-border">
|
|
34
|
+
<summary
|
|
35
|
+
data-slot="fold-row-summary"
|
|
36
|
+
className="flex min-h-row-height cursor-pointer list-none flex-wrap items-center gap-x-2 gap-y-1 rounded-md px-1 py-1 transition-colors duration-120 group-open/fold-row:bg-accent hover:bg-accent focus-visible:ring-2 focus-visible:ring-ring focus-visible:outline-none [&::-webkit-details-marker]:hidden"
|
|
37
|
+
>
|
|
38
|
+
{/* The chevron and the title wrap as one: a long title folds onto lines beside its chevron. */}
|
|
39
|
+
<span data-slot="fold-row-heading" className="flex min-w-0 items-center gap-2">
|
|
40
|
+
<ChevronRight
|
|
41
|
+
aria-hidden="true"
|
|
42
|
+
strokeWidth={ICON_STROKE_WIDTH}
|
|
43
|
+
className="size-4 shrink-0 text-muted-foreground transition-transform duration-150 group-open/fold-row:rotate-90"
|
|
44
|
+
/>
|
|
45
|
+
<span className="min-w-0 text-ui-medium">{title}</span>
|
|
46
|
+
</span>
|
|
47
|
+
{facts.map((fact, index) => (
|
|
48
|
+
// Facts have no identity of their own; their order is fixed for one render.
|
|
49
|
+
<span key={index} data-slot="fold-row-fact" className="text-ui text-muted-foreground">
|
|
50
|
+
{fact}
|
|
51
|
+
</span>
|
|
52
|
+
))}
|
|
53
|
+
{badges.length === 0 ? null : (
|
|
54
|
+
<span data-slot="fold-row-badges" className="ml-auto inline-flex flex-wrap gap-1">
|
|
55
|
+
{badges.map((badge) => {
|
|
56
|
+
const tone = badge.tone ?? "default";
|
|
57
|
+
return (
|
|
58
|
+
<Badge
|
|
59
|
+
key={badge.key}
|
|
60
|
+
variant="tag"
|
|
61
|
+
color={TONE_COLORS[tone] ?? "default"}
|
|
62
|
+
data-badge={badge.key}
|
|
63
|
+
data-tone={tone}
|
|
64
|
+
>
|
|
65
|
+
{badge.text}
|
|
66
|
+
</Badge>
|
|
67
|
+
);
|
|
68
|
+
})}
|
|
69
|
+
</span>
|
|
70
|
+
)}
|
|
71
|
+
</summary>
|
|
72
|
+
<div data-slot="fold-row-content" className="flex flex-col gap-2 py-2 pr-1 pl-6 empty:hidden">
|
|
73
|
+
<DetailTable label={detailsLabel} rows={details} />
|
|
74
|
+
{children}
|
|
75
|
+
</div>
|
|
76
|
+
</details>
|
|
77
|
+
);
|
|
78
|
+
}
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import type { LucideIcon } from "lucide-react";
|
|
4
|
+
import { useId, type MouseEvent, type ReactNode } from "react";
|
|
5
|
+
|
|
6
|
+
import { badgeVariants } from "../ui/badge.js";
|
|
7
|
+
import { buttonVariants } from "../ui/button.js";
|
|
8
|
+
import { cn } from "../lib/utils.js";
|
|
9
|
+
|
|
10
|
+
import { ICON_STROKE_WIDTH } from "./icon-stroke.js";
|
|
11
|
+
import type { PaletteColor } from "./palette.js";
|
|
12
|
+
|
|
13
|
+
export interface MarkPopoverProps {
|
|
14
|
+
/** The mark's colour: a palette colour that means the worst of what it lists. */
|
|
15
|
+
readonly color: PaletteColor;
|
|
16
|
+
readonly icon: LucideIcon;
|
|
17
|
+
readonly count: number;
|
|
18
|
+
/** The mark's accessible name: what it counts and that it opens a list. */
|
|
19
|
+
readonly label: string;
|
|
20
|
+
readonly heading: string;
|
|
21
|
+
readonly closeLabel: string;
|
|
22
|
+
/** Extra `data-*` attributes kept on the button. */
|
|
23
|
+
readonly buttonData?: Readonly<Record<`data-${string}`, string | undefined>>;
|
|
24
|
+
/** The entries, as phrasing elements with `role="listitem"`. */
|
|
25
|
+
readonly children: ReactNode;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
// A counted tag (open warnings, tickets to buy) that opens a list of what it counts. The browser's Popover API opens
|
|
29
|
+
// it on click or Enter and closes it on Escape or a click outside, with no client state; the panel sits in the top
|
|
30
|
+
// layer, so a card's overflow never clips it. Centred on a phone, under its mark where CSS anchor positioning works.
|
|
31
|
+
// Phrasing elements only, so the mark fits inside a `<summary>` or a paragraph.
|
|
32
|
+
export function MarkPopover({ color, icon: Icon, count, label, heading, closeLabel, buttonData, children }: MarkPopoverProps) {
|
|
33
|
+
const panelId = useId();
|
|
34
|
+
return (
|
|
35
|
+
<span data-slot="mark" className="inline-flex [anchor-scope:--mark]">
|
|
36
|
+
<button
|
|
37
|
+
type="button"
|
|
38
|
+
className={cn(
|
|
39
|
+
badgeVariants({ variant: "tag", color }),
|
|
40
|
+
"cursor-pointer gap-1 font-medium tabular-nums [anchor-name:--mark] focus-visible:ring-2 focus-visible:ring-ring focus-visible:outline-none",
|
|
41
|
+
)}
|
|
42
|
+
{...buttonData}
|
|
43
|
+
popoverTarget={panelId}
|
|
44
|
+
aria-haspopup="dialog"
|
|
45
|
+
aria-label={label}
|
|
46
|
+
>
|
|
47
|
+
<Icon aria-hidden="true" strokeWidth={ICON_STROKE_WIDTH} />
|
|
48
|
+
<span aria-hidden="true">{count}</span>
|
|
49
|
+
</button>
|
|
50
|
+
<span
|
|
51
|
+
id={panelId}
|
|
52
|
+
popover="auto"
|
|
53
|
+
role="dialog"
|
|
54
|
+
aria-labelledby={`${panelId}-heading`}
|
|
55
|
+
data-slot="mark-popover"
|
|
56
|
+
className="max-h-[min(24rem,calc(100vh-2rem))] w-[min(22rem,calc(100vw-2rem))] cursor-auto overflow-y-auto rounded-xl bg-popover p-3 text-left text-ui font-normal whitespace-normal text-popover-foreground shadow-menu backdrop:bg-transparent sm:supports-[position-anchor:--mark]:mt-1 sm:supports-[position-anchor:--mark]:mr-0 sm:supports-[position-anchor:--mark]:mb-0 sm:supports-[position-anchor:--mark]:ml-0 sm:supports-[position-anchor:--mark]:[position-anchor:--mark] sm:supports-[position-anchor:--mark]:[position-area:block-end_span-inline-start] sm:supports-[position-anchor:--mark]:[position-try-fallbacks:flip-block,flip-inline]"
|
|
57
|
+
onClick={keepEnclosingDetailsFolded}
|
|
58
|
+
>
|
|
59
|
+
<span className="mb-2 flex items-center justify-between gap-2">
|
|
60
|
+
<span id={`${panelId}-heading`} className="text-ui-medium">
|
|
61
|
+
{heading}
|
|
62
|
+
</span>
|
|
63
|
+
<button
|
|
64
|
+
type="button"
|
|
65
|
+
className={buttonVariants({ variant: "ghost", size: "xs" })}
|
|
66
|
+
popoverTarget={panelId}
|
|
67
|
+
popoverTargetAction="hide"
|
|
68
|
+
>
|
|
69
|
+
{closeLabel}
|
|
70
|
+
</button>
|
|
71
|
+
</span>
|
|
72
|
+
<span role="list" className="flex flex-col gap-2">
|
|
73
|
+
{children}
|
|
74
|
+
</span>
|
|
75
|
+
</span>
|
|
76
|
+
</span>
|
|
77
|
+
);
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
// A click on the panel's text would toggle an enclosing `<details>` (the mark sits in its summary); links and
|
|
81
|
+
// buttons inside keep their default.
|
|
82
|
+
function keepEnclosingDetailsFolded(event: MouseEvent<HTMLElement>): void {
|
|
83
|
+
if (event.target instanceof Element && event.target.closest("a, button") === null) event.preventDefault();
|
|
84
|
+
}
|
|
@@ -19,6 +19,8 @@ export interface PageCrumb {
|
|
|
19
19
|
export interface PageHeaderProps {
|
|
20
20
|
title: ReactNode;
|
|
21
21
|
crumbs?: PageCrumb[];
|
|
22
|
+
// The breadcrumb's accessible name in the app's language; the built-in English one when absent.
|
|
23
|
+
crumbsLabel?: string;
|
|
22
24
|
// A lucide icon, never an emoji.
|
|
23
25
|
icon?: ReactNode;
|
|
24
26
|
description?: ReactNode;
|
|
@@ -29,11 +31,11 @@ export interface PageHeaderProps {
|
|
|
29
31
|
}
|
|
30
32
|
|
|
31
33
|
// The page's header, once per screen: breadcrumb, page icon, the 40 px title, what follows it, a description and actions.
|
|
32
|
-
export function PageHeader({ title, crumbs, icon, description, actions, children, className }: PageHeaderProps) {
|
|
34
|
+
export function PageHeader({ title, crumbs, crumbsLabel, icon, description, actions, children, className }: PageHeaderProps) {
|
|
33
35
|
return (
|
|
34
36
|
<header data-slot="page-header" className={cn("flex flex-col", className)}>
|
|
35
37
|
{crumbs && crumbs.length > 0 ? (
|
|
36
|
-
<Breadcrumb>
|
|
38
|
+
<Breadcrumb {...(crumbsLabel === undefined ? {} : { "aria-label": crumbsLabel })}>
|
|
37
39
|
<BreadcrumbList>
|
|
38
40
|
{crumbs.map((crumb, index) => (
|
|
39
41
|
<Fragment key={`${index}-${crumb.label}`}>
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import { X } from "lucide-react";
|
|
4
|
+
import { useEffect, useRef, type KeyboardEvent, type ReactNode } from "react";
|
|
5
|
+
|
|
6
|
+
import { en as messages } from "../messages/en.js";
|
|
7
|
+
import { Button } from "../ui/button.js";
|
|
8
|
+
|
|
9
|
+
import { ICON_STROKE_WIDTH } from "./icon-stroke.js";
|
|
10
|
+
|
|
11
|
+
// `over` and `left` float over the canvas's right or left side; `beside` and `list` sit next to it (after or before)
|
|
12
|
+
// and shrink it, and cover the whole canvas on a phone.
|
|
13
|
+
export type SidePanelLayout = "over" | "beside" | "left" | "list";
|
|
14
|
+
|
|
15
|
+
export interface SidePanelProps {
|
|
16
|
+
// Also the `data-testid`; the opener points at it with `aria-controls`.
|
|
17
|
+
readonly id: string;
|
|
18
|
+
readonly heading: string;
|
|
19
|
+
readonly layout: SidePanelLayout;
|
|
20
|
+
readonly isOpen: boolean;
|
|
21
|
+
// The close button and Escape; the caller moves focus back to its opener.
|
|
22
|
+
readonly onClose: () => void;
|
|
23
|
+
// The close button's accessible name, from the app's message layer.
|
|
24
|
+
readonly closeLabel?: string;
|
|
25
|
+
readonly children: ReactNode;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
// A non-modal panel at a side of a canvas (a map) that leaves the canvas usable. Its parent is a `relative` flex row
|
|
29
|
+
// holding the canvas and the panel. Hidden while closed, so its content leaves the reading order.
|
|
30
|
+
export function SidePanel({ id, heading, layout, isOpen, onClose, closeLabel = messages.sidePanel.close, children }: SidePanelProps) {
|
|
31
|
+
const panelRef = useRef<HTMLElement>(null);
|
|
32
|
+
const wasOpenRef = useRef(isOpen);
|
|
33
|
+
const headingId = `${id}-heading`;
|
|
34
|
+
|
|
35
|
+
// Focus moves in when the panel opens, not when it is open on first render.
|
|
36
|
+
useEffect(() => {
|
|
37
|
+
if (isOpen && !wasOpenRef.current) panelRef.current?.focus();
|
|
38
|
+
wasOpenRef.current = isOpen;
|
|
39
|
+
}, [isOpen]);
|
|
40
|
+
|
|
41
|
+
function closeOnEscape(event: KeyboardEvent<HTMLElement>) {
|
|
42
|
+
if (event.key !== "Escape") return;
|
|
43
|
+
event.stopPropagation();
|
|
44
|
+
onClose();
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
return (
|
|
48
|
+
<aside
|
|
49
|
+
ref={panelRef}
|
|
50
|
+
id={id}
|
|
51
|
+
tabIndex={-1}
|
|
52
|
+
data-slot="side-panel"
|
|
53
|
+
className="absolute inset-y-0 right-0 z-3 flex w-[min(24rem,100%)] flex-col border-l border-border bg-background text-foreground shadow-menu outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-inset data-[layout=beside]:relative data-[layout=beside]:w-auto data-[layout=beside]:max-w-full data-[layout=beside]:flex-[0_0_max(50%,24rem)] data-[layout=left]:right-auto data-[layout=left]:left-0 data-[layout=left]:border-r data-[layout=left]:border-l-0 max-sm:data-[layout=beside]:absolute max-sm:data-[layout=beside]:inset-0 max-sm:data-[layout=beside]:w-full max-sm:data-[layout=beside]:border-l-0 data-[layout=list]:relative data-[layout=list]:flex-none data-[layout=list]:border-r data-[layout=list]:border-l-0 max-sm:data-[layout=list]:absolute max-sm:data-[layout=list]:inset-0 max-sm:data-[layout=list]:w-full max-sm:data-[layout=list]:border-r-0 [&[hidden]]:hidden"
|
|
54
|
+
data-layout={layout}
|
|
55
|
+
hidden={!isOpen}
|
|
56
|
+
aria-labelledby={headingId}
|
|
57
|
+
data-testid={id}
|
|
58
|
+
onKeyDown={closeOnEscape}
|
|
59
|
+
>
|
|
60
|
+
<div className="flex items-center justify-between gap-2 border-b border-border py-2 pr-2 pl-4">
|
|
61
|
+
<h2 id={headingId} className="text-heading-3">
|
|
62
|
+
{heading}
|
|
63
|
+
</h2>
|
|
64
|
+
<Button type="button" variant="ghost" size="icon" aria-label={closeLabel} onClick={onClose}>
|
|
65
|
+
<X aria-hidden="true" strokeWidth={ICON_STROKE_WIDTH} />
|
|
66
|
+
</Button>
|
|
67
|
+
</div>
|
|
68
|
+
<div data-slot="side-panel-content" className="grid flex-1 content-start gap-3 overflow-y-auto p-3">
|
|
69
|
+
{children}
|
|
70
|
+
</div>
|
|
71
|
+
</aside>
|
|
72
|
+
);
|
|
73
|
+
}
|