lumonui 0.0.0-stage → 0.2.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/README.md +35 -2
- package/package.json +30 -4
- package/src/action-form.tsx +56 -0
- package/src/badge.tsx +5 -0
- package/src/button.tsx +20 -0
- package/src/card.tsx +3 -0
- package/src/controls.tsx +12 -0
- package/src/dialog.tsx +48 -0
- package/src/empty-state.tsx +23 -0
- package/src/field.tsx +19 -0
- package/src/file-button.tsx +27 -0
- package/src/index.ts +17 -0
- package/src/menu.tsx +4 -0
- package/src/misc.tsx +6 -0
- package/src/page-header.tsx +19 -0
- package/src/sidebar.tsx +21 -0
- package/src/styles.css +208 -0
- package/src/submit-button.tsx +18 -0
- package/src/tabs.tsx +18 -0
- package/src/toast.tsx +6 -0
- package/src/types.ts +1 -0
package/README.md
CHANGED
|
@@ -1,3 +1,36 @@
|
|
|
1
|
-
#
|
|
1
|
+
# lumonui
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Lumon Studio's UI: design tokens, Tailwind 4 styles and React components for modern React apps. Source is shipped as-is (no build step).
|
|
4
|
+
|
|
5
|
+
## Use it
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm i lumonui
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
`globals.css` (after Tailwind):
|
|
12
|
+
```css
|
|
13
|
+
@import "tailwindcss";
|
|
14
|
+
@import "lumonui/styles.css";
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
```tsx
|
|
18
|
+
import { PageHeader, Field, SubmitButton, Badge, Dialog } from "lumonui";
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
Needs `react`, `react-dom`, `lucide-react` (the only icon library) and `tailwindcss` 4. The layout should set `--font-inter` when using a custom Inter font.
|
|
22
|
+
|
|
23
|
+
## What's inside
|
|
24
|
+
|
|
25
|
+
- `styles.css`: `@theme` tokens (colours, shadow, font) and classes: `.btn*`, `.icon-btn`, `.control`, `.card`, `.table`, `.badge*`, `.tabs`, `.dialog`, `.skeleton`, motion rules (all respect reduced motion).
|
|
26
|
+
- Components: `ActionForm`, `Button`, `SubmitButton`, `Field`, `FormAlert`, `Dialog`, `PageTabs`, `PageHeader`, `EmptyState`, `TableEmpty`, `FileButton`, `Badge`, `Input`, `Textarea`, `Select`, `Checkbox`, `Radio`, `Switch`, `Card`, `CardHeader`, `Toaster`, `useToast`, `Menu`, `MenuItem`, `MenuSeparator`, `Skeleton`, `Avatar`, `Progress`, `Breadcrumbs`, `Pagination`.
|
|
27
|
+
|
|
28
|
+
### Core components
|
|
29
|
+
|
|
30
|
+
`Button` supports `primary`, `secondary`, `danger`, and `danger-solid` variants, `sm` sizing, loading state, and `href` links. Use `Field` around `Input`, `Textarea`, or `Select` so IDs and error/help ARIA relationships are applied automatically.
|
|
31
|
+
|
|
32
|
+
`Card` and `CardHeader` provide the 8px surface pattern. `Toaster` exposes `useToast()` for success, error, and info notices. `Menu` provides a keyboard-closeable menu surface, while `Skeleton`, `Avatar`, `Progress`, `Breadcrumbs`, and `Pagination` cover common application chrome.
|
|
33
|
+
|
|
34
|
+
## Releasing
|
|
35
|
+
|
|
36
|
+
Semantic versions. Bug fix = patch, new component = minor, breaking change = major. Every release is a GitHub Release with notes.
|
package/package.json
CHANGED
|
@@ -1,6 +1,32 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "lumonui",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "0.2.0",
|
|
4
|
+
"description": "Lumon Studio UI: light operational design tokens and framework-neutral React components.",
|
|
5
|
+
"license": "UNLICENSED",
|
|
6
|
+
"type": "module",
|
|
7
|
+
"files": [
|
|
8
|
+
"src"
|
|
9
|
+
],
|
|
10
|
+
"exports": {
|
|
11
|
+
".": "./src/index.ts",
|
|
12
|
+
"./styles.css": "./src/styles.css"
|
|
13
|
+
},
|
|
14
|
+
"scripts": {
|
|
15
|
+
"typecheck": "tsc --noEmit"
|
|
16
|
+
},
|
|
17
|
+
"peerDependencies": {
|
|
18
|
+
"lucide-react": ">=1",
|
|
19
|
+
"react": ">=19",
|
|
20
|
+
"react-dom": ">=19",
|
|
21
|
+
"tailwindcss": ">=4"
|
|
22
|
+
},
|
|
23
|
+
"devDependencies": {
|
|
24
|
+
"@types/react": "^19.3.0",
|
|
25
|
+
"@types/react-dom": "^19.2.0",
|
|
26
|
+
"lucide-react": "^1.72.0",
|
|
27
|
+
"react": "^19.3.1",
|
|
28
|
+
"react-dom": "^19.3.1",
|
|
29
|
+
"typescript": "^5.9.0"
|
|
30
|
+
},
|
|
31
|
+
"dependencies": {}
|
|
32
|
+
}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { createContext, useContext, useRef, useState, type ReactNode } from "react";
|
|
3
|
+
import type { ActionResult } from "./types";
|
|
4
|
+
import { FormAlert } from "./field";
|
|
5
|
+
|
|
6
|
+
type Action = (prev: ActionResult, fd: FormData) => Promise<ActionResult>;
|
|
7
|
+
const PendingCtx = createContext(false);
|
|
8
|
+
export const useActionPending = () => useContext(PendingCtx);
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Form bound to a server action. The action is awaited directly (not through the `action` prop),
|
|
12
|
+
* so React never resets fields (input is preserved on errors) and the pending/success state does
|
|
13
|
+
* not depend on the background page refresh finishing.
|
|
14
|
+
*/
|
|
15
|
+
export function ActionForm({ action, children, onSuccess, className = "space-y-4", resetOnSuccess = false, showSuccess = false, encType }: {
|
|
16
|
+
action: Action; children: ReactNode | ((r: ActionResult) => ReactNode); onSuccess?: () => void; className?: string; resetOnSuccess?: boolean; showSuccess?: boolean; encType?: string;
|
|
17
|
+
}) {
|
|
18
|
+
const [state, setState] = useState<ActionResult>({ ok: false });
|
|
19
|
+
const [pending, setPending] = useState(false);
|
|
20
|
+
const ref = useRef<HTMLFormElement>(null);
|
|
21
|
+
|
|
22
|
+
return (
|
|
23
|
+
<PendingCtx.Provider value={pending}>
|
|
24
|
+
<form
|
|
25
|
+
ref={ref} className={className} noValidate encType={encType} aria-busy={pending}
|
|
26
|
+
onSubmit={async (e) => {
|
|
27
|
+
e.preventDefault();
|
|
28
|
+
if (pending) return;
|
|
29
|
+
const fd = new FormData(e.currentTarget, (e.nativeEvent as SubmitEvent).submitter);
|
|
30
|
+
setPending(true);
|
|
31
|
+
let r: ActionResult;
|
|
32
|
+
try {
|
|
33
|
+
r = await action(state, fd);
|
|
34
|
+
} catch (err) {
|
|
35
|
+
// redirect() inside an action navigates away; anything else is a real failure.
|
|
36
|
+
if (err && typeof err === "object" && "digest" in err && String((err as { digest: unknown }).digest).startsWith("NEXT_REDIRECT")) return;
|
|
37
|
+
r = { ok: false, error: "Something went wrong. Please try again." };
|
|
38
|
+
} finally {
|
|
39
|
+
setPending(false);
|
|
40
|
+
}
|
|
41
|
+
setState(r ?? { ok: false });
|
|
42
|
+
if (r?.ok) {
|
|
43
|
+
if (resetOnSuccess) ref.current?.reset();
|
|
44
|
+
onSuccess?.();
|
|
45
|
+
} else {
|
|
46
|
+
requestAnimationFrame(() => ref.current?.querySelector<HTMLElement>("[aria-invalid='true']")?.focus());
|
|
47
|
+
}
|
|
48
|
+
}}
|
|
49
|
+
>
|
|
50
|
+
{state.error && <FormAlert>{state.error}</FormAlert>}
|
|
51
|
+
{showSuccess && state.ok && state.message && <FormAlert tone="success">{state.message}</FormAlert>}
|
|
52
|
+
{typeof children === "function" ? children(state) : children}
|
|
53
|
+
</form>
|
|
54
|
+
</PendingCtx.Provider>
|
|
55
|
+
);
|
|
56
|
+
}
|
package/src/badge.tsx
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { HTMLAttributes, ReactNode } from "react";
|
|
2
|
+
|
|
3
|
+
export function Badge({ tone = "neutral", children, className = "", ...props }: HTMLAttributes<HTMLSpanElement> & { tone?: "neutral" | "green" | "orange" | "blue" | "purple" | "red" | "accent"; children: ReactNode }) {
|
|
4
|
+
return <span {...props} className={`badge badge-${tone} ${className}`}>{children}</span>;
|
|
5
|
+
}
|
package/src/button.tsx
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { Loader2 } from "lucide-react";
|
|
2
|
+
import type { AnchorHTMLAttributes, ButtonHTMLAttributes, ReactNode } from "react";
|
|
3
|
+
|
|
4
|
+
type Variant = "primary" | "secondary" | "danger" | "danger-solid";
|
|
5
|
+
type Common = { variant?: Variant; size?: "default" | "sm"; loading?: boolean; children: ReactNode; className?: string };
|
|
6
|
+
type ButtonProps = Common & Omit<ButtonHTMLAttributes<HTMLButtonElement>, "children"> & { href?: never };
|
|
7
|
+
type LinkProps = Common & Omit<AnchorHTMLAttributes<HTMLAnchorElement>, "children"> & { href: string };
|
|
8
|
+
|
|
9
|
+
export function Button(props: ButtonProps | LinkProps) {
|
|
10
|
+
const { variant = "primary", size = "default", loading = false, className = "", children, ...rest } = props;
|
|
11
|
+
const cls = `btn btn-${variant}${size === "sm" ? " btn-sm" : ""} ${className}`;
|
|
12
|
+
if ("href" in props && props.href) {
|
|
13
|
+
return <a {...(rest as AnchorHTMLAttributes<HTMLAnchorElement>)} href={props.href} className={cls} aria-disabled={loading || undefined} tabIndex={loading ? -1 : undefined}>
|
|
14
|
+
{loading && <Loader2 className="animate-spin" aria-hidden />} {children}
|
|
15
|
+
</a>;
|
|
16
|
+
}
|
|
17
|
+
return <button {...(rest as ButtonHTMLAttributes<HTMLButtonElement>)} className={cls} disabled={loading || (rest as ButtonHTMLAttributes<HTMLButtonElement>).disabled} aria-busy={loading || undefined}>
|
|
18
|
+
{loading && <Loader2 className="animate-spin" aria-hidden />} {children}
|
|
19
|
+
</button>;
|
|
20
|
+
}
|
package/src/card.tsx
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import type { HTMLAttributes, ReactNode } from "react";
|
|
2
|
+
export function Card({ pad = false, className = "", ...props }: HTMLAttributes<HTMLDivElement> & { pad?: boolean }) { return <div {...props} className={`card${pad ? " card-pad" : ""} ${className}`} />; }
|
|
3
|
+
export function CardHeader({ title, meta, actions, className = "" }: { title: ReactNode; meta?: ReactNode; actions?: ReactNode; className?: string }) { return <div className={`card-header ${className}`}><div><h2 className="h2">{title}</h2>{meta && <div className="meta">{meta}</div>}</div>{actions && <div className="card-actions">{actions}</div>}</div>; }
|
package/src/controls.tsx
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { InputHTMLAttributes, SelectHTMLAttributes, TextareaHTMLAttributes, ReactNode } from "react";
|
|
2
|
+
|
|
3
|
+
type Props = { prefix?: ReactNode; suffix?: ReactNode; className?: string };
|
|
4
|
+
export function Input({ prefix, suffix, className = "", ...props }: Props & InputHTMLAttributes<HTMLInputElement>) {
|
|
5
|
+
return <ControlShell prefix={prefix} suffix={suffix}><input {...props} className={`control ${className}`} /></ControlShell>;
|
|
6
|
+
}
|
|
7
|
+
export function Textarea({ className = "", ...props }: TextareaHTMLAttributes<HTMLTextAreaElement>) { return <textarea {...props} className={`control ${className}`} />; }
|
|
8
|
+
export function Select({ className = "", children, ...props }: SelectHTMLAttributes<HTMLSelectElement>) { return <select {...props} className={`control ${className}`}>{children}</select>; }
|
|
9
|
+
export function Checkbox({ label, className = "", ...props }: InputHTMLAttributes<HTMLInputElement> & { label: ReactNode }) { return <label className={`check-row ${className}`}><input {...props} type="checkbox" className="check" />{label}</label>; }
|
|
10
|
+
export function Radio({ label, className = "", ...props }: InputHTMLAttributes<HTMLInputElement> & { label: ReactNode }) { return <label className={`check-row ${className}`}><input {...props} type="radio" className="check" />{label}</label>; }
|
|
11
|
+
export function Switch({ label, className = "", ...props }: InputHTMLAttributes<HTMLInputElement> & { label?: ReactNode }) { return <label className={`switch-row ${className}`}><input {...props} type="checkbox" role="switch" />{label && <span>{label}</span>}</label>; }
|
|
12
|
+
function ControlShell({ prefix, suffix, children }: { prefix?: ReactNode; suffix?: ReactNode; children: ReactNode }) { return prefix || suffix ? <span className="control-shell">{prefix && <span className="control-slot">{prefix}</span>}{children}{suffix && <span className="control-slot">{suffix}</span>}</span> : children; }
|
package/src/dialog.tsx
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { X } from "lucide-react";
|
|
3
|
+
import { createContext, useContext, useEffect, useId, useRef, useState, type ReactNode } from "react";
|
|
4
|
+
|
|
5
|
+
const CloseCtx = createContext<(() => void) | null>(null);
|
|
6
|
+
/** Close the surrounding Dialog from inside a form (works from server-rendered pages). */
|
|
7
|
+
export function useDialogClose() {
|
|
8
|
+
return useContext(CloseCtx) ?? (() => {});
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Native <dialog> modal: traps focus, closes on Escape, and restores focus to the trigger.
|
|
13
|
+
* `children` may be a function receiving `close`.
|
|
14
|
+
*/
|
|
15
|
+
export function Dialog({ trigger, title, description, children, triggerClassName = "btn btn-primary", triggerLabel, wide, width, onClosed }: {
|
|
16
|
+
trigger: ReactNode; triggerLabel?: string; title: string; description?: string; triggerClassName?: string; wide?: boolean; width?: string; onClosed?: () => void;
|
|
17
|
+
children: ReactNode | ((close: () => void) => ReactNode);
|
|
18
|
+
}) {
|
|
19
|
+
const ref = useRef<HTMLDialogElement>(null);
|
|
20
|
+
const [open, setOpen] = useState(false);
|
|
21
|
+
const id = useId();
|
|
22
|
+
useEffect(() => {
|
|
23
|
+
const d = ref.current;
|
|
24
|
+
if (!d) return;
|
|
25
|
+
if (open && !d.open) d.showModal();
|
|
26
|
+
if (!open && d.open) d.close();
|
|
27
|
+
}, [open]);
|
|
28
|
+
const close = () => setOpen(false);
|
|
29
|
+
return (
|
|
30
|
+
<>
|
|
31
|
+
<button type="button" className={triggerClassName} onClick={() => setOpen(true)} aria-haspopup="dialog" aria-label={triggerLabel}>{trigger}</button>
|
|
32
|
+
<dialog ref={ref} className="dialog m-auto" style={wide ? { width: "min(880px, calc(100vw - 24px))" } : width ? { width: `min(${width}, calc(100vw - 24px))` } : undefined} aria-labelledby={`${id}-t`} onClose={() => { close(); onClosed?.(); }} onClick={(e) => { if (e.target === ref.current) close(); }}>
|
|
33
|
+
{open && (
|
|
34
|
+
<div className="flex max-h-[calc(100dvh-34px)] flex-col">
|
|
35
|
+
<div className="flex items-start justify-between gap-4 border-b border-border px-5 py-4">
|
|
36
|
+
<div>
|
|
37
|
+
<h2 id={`${id}-t`} className="text-[15px] font-semibold">{title}</h2>
|
|
38
|
+
{description && <p className="mt-0.5 text-muted">{description}</p>}
|
|
39
|
+
</div>
|
|
40
|
+
<button type="button" className="icon-btn -mr-2 -mt-1" aria-label="Close dialog" onClick={close}><X aria-hidden /></button>
|
|
41
|
+
</div>
|
|
42
|
+
<div className="overflow-y-auto px-5 py-4"><CloseCtx.Provider value={close}>{typeof children === "function" ? children(close) : children}</CloseCtx.Provider></div>
|
|
43
|
+
</div>
|
|
44
|
+
)}
|
|
45
|
+
</dialog>
|
|
46
|
+
</>
|
|
47
|
+
);
|
|
48
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { ReactNode } from "react";
|
|
2
|
+
|
|
3
|
+
export function EmptyState({ icon, title, body, action }: { icon: ReactNode; title: string; body: string; action?: ReactNode }) {
|
|
4
|
+
return (
|
|
5
|
+
<div className="flex flex-col items-center px-6 py-12 text-center">
|
|
6
|
+
<div className="mb-3 flex h-10 w-10 items-center justify-center rounded-lg bg-accent-soft text-accent [&_svg]:h-5 [&_svg]:w-5" aria-hidden>{icon}</div>
|
|
7
|
+
<h3 className="h2">{title}</h3>
|
|
8
|
+
<p className="mt-1 max-w-sm text-muted">{body}</p>
|
|
9
|
+
{action && <div className="mt-4">{action}</div>}
|
|
10
|
+
</div>
|
|
11
|
+
);
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
/** Empty state rendered inside a table body. */
|
|
15
|
+
export function TableEmpty({ colSpan, ...p }: { colSpan: number; icon: ReactNode; title: string; body: string; action?: ReactNode }) {
|
|
16
|
+
return (
|
|
17
|
+
<tr>
|
|
18
|
+
<td colSpan={colSpan} className="!p-0 hover:!bg-transparent">
|
|
19
|
+
<EmptyState {...p} />
|
|
20
|
+
</td>
|
|
21
|
+
</tr>
|
|
22
|
+
);
|
|
23
|
+
}
|
package/src/field.tsx
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { Children, cloneElement, isValidElement, type ReactNode } from "react";
|
|
2
|
+
|
|
3
|
+
export function Field({ label, htmlFor, hint, error, children, className }: { label: string; htmlFor: string; hint?: ReactNode; error?: string; children: ReactNode; className?: string }) {
|
|
4
|
+
const describedBy = [hint && `${htmlFor}-hint`, error && `${htmlFor}-error`].filter(Boolean).join(" ") || undefined;
|
|
5
|
+
const control = Children.only(children);
|
|
6
|
+
const child = isValidElement(control) ? cloneElement(control as never, { id: htmlFor, "aria-invalid": error ? true : undefined, "aria-describedby": describedBy } as never) : control;
|
|
7
|
+
return (
|
|
8
|
+
<div className={className}>
|
|
9
|
+
<label className="label" htmlFor={htmlFor}>{label}</label>
|
|
10
|
+
{child}
|
|
11
|
+
{error ? <p className="field-error" id={`${htmlFor}-error`}>{error}</p> : hint ? <p className="hint" id={`${htmlFor}-hint`}>{hint}</p> : null}
|
|
12
|
+
</div>
|
|
13
|
+
);
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export function FormAlert({ tone = "error", children }: { tone?: "error" | "success" | "info"; children: ReactNode }) {
|
|
17
|
+
const cls = tone === "error" ? "border-[#efc4c0] bg-red-soft text-red" : tone === "success" ? "border-[#bfe3cf] bg-green-soft text-green" : "border-[#cfe0f1] bg-blue-soft text-blue";
|
|
18
|
+
return <div role={tone === "error" ? "alert" : "status"} className={`rounded-md border px-3 py-2.5 text-[12.5px] font-medium ${cls}`}>{children}</div>;
|
|
19
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { useEffect, useRef, useState, type ChangeEventHandler } from "react";
|
|
3
|
+
import { Upload } from "lucide-react";
|
|
4
|
+
|
|
5
|
+
/** Secondary "Upload" button wrapping a visually hidden file input (still submitted with the form). */
|
|
6
|
+
export function FileButton({ id, name, accept, multiple, required, label = "Upload", autoSubmit, onChange }: {
|
|
7
|
+
id: string; name: string; accept?: string; multiple?: boolean; required?: boolean; label?: string;
|
|
8
|
+
/** Submit the parent form as soon as a file is chosen (no separate Upload button). */
|
|
9
|
+
autoSubmit?: boolean; onChange?: ChangeEventHandler<HTMLInputElement>;
|
|
10
|
+
}) {
|
|
11
|
+
const ref = useRef<HTMLInputElement>(null);
|
|
12
|
+
const [names, setNames] = useState<string[]>([]);
|
|
13
|
+
useEffect(() => {
|
|
14
|
+
const form = ref.current?.form;
|
|
15
|
+
const clear = () => setNames([]);
|
|
16
|
+
form?.addEventListener("reset", clear);
|
|
17
|
+
return () => form?.removeEventListener("reset", clear);
|
|
18
|
+
}, []);
|
|
19
|
+
return (
|
|
20
|
+
<span className="inline-flex max-w-full items-center gap-2.5">
|
|
21
|
+
<input ref={ref} id={id} name={name} type="file" accept={accept} multiple={multiple} required={required} className="sr-only" tabIndex={-1}
|
|
22
|
+
onChange={(e) => { setNames(Array.from(e.target.files ?? []).map((f) => f.name)); onChange?.(e); if (autoSubmit && e.target.files?.length) e.target.form?.requestSubmit(); }} />
|
|
23
|
+
<button type="button" className="btn btn-secondary" onClick={() => ref.current?.click()}><Upload aria-hidden />{label}</button>
|
|
24
|
+
{names.length > 0 && <span className="min-w-0 truncate text-[12px] text-muted" title={names.join(", ")}>{names.length > 1 ? `${names.length} files selected` : names[0]}</span>}
|
|
25
|
+
</span>
|
|
26
|
+
);
|
|
27
|
+
}
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export * from "./action-form";
|
|
2
|
+
export * from "./button";
|
|
3
|
+
export * from "./badge";
|
|
4
|
+
export * from "./dialog";
|
|
5
|
+
export * from "./empty-state";
|
|
6
|
+
export * from "./field";
|
|
7
|
+
export * from "./file-button";
|
|
8
|
+
export * from "./page-header";
|
|
9
|
+
export * from "./submit-button";
|
|
10
|
+
export * from "./tabs";
|
|
11
|
+
export * from "./controls";
|
|
12
|
+
export * from "./card";
|
|
13
|
+
export * from "./toast";
|
|
14
|
+
export * from "./menu";
|
|
15
|
+
export * from "./misc";
|
|
16
|
+
export * from "./sidebar";
|
|
17
|
+
export type { ActionResult } from "./types";
|
package/src/menu.tsx
ADDED
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { useEffect, useRef, useState, type ReactNode } from "react";
|
|
2
|
+
export function Menu({ trigger, children }: { trigger: ReactNode; children: ReactNode }) { const [open,setOpen]=useState(false); const ref=useRef<HTMLDivElement>(null); useEffect(()=>{const close=(e:MouseEvent)=>{if(!ref.current?.contains(e.target as Node))setOpen(false)};document.addEventListener("mousedown",close);return()=>document.removeEventListener("mousedown",close)},[]); return <div className="menu" ref={ref}><button className="menu-trigger" aria-haspopup="menu" aria-expanded={open} onClick={()=>setOpen(v=>!v)}>{trigger}</button>{open&&<div className="menu-panel" role="menu" onKeyDown={e=>e.key==="Escape"&&setOpen(false)}>{children}</div>}</div> }
|
|
3
|
+
export function MenuItem({ children, destructive = false, onSelect }: { children: ReactNode; destructive?: boolean; onSelect?: ()=>void }) { return <button role="menuitem" className={`menu-item${destructive?" destructive":""}`} onClick={onSelect}>{children}</button> }
|
|
4
|
+
export function MenuSeparator(){return <div className="menu-separator" role="separator"/>}
|
package/src/misc.tsx
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { ReactNode } from "react";
|
|
2
|
+
export function Skeleton({ className = "" }: { className?: string }) { return <span className={`skeleton ${className}`} aria-hidden />; }
|
|
3
|
+
export function Avatar({ src, alt = "", initials, size = "md" }: { src?: string; alt?: string; initials?: string; size?: "sm" | "md" | "lg" }) { return <span className={`avatar avatar-${size}`}>{src ? <img src={src} alt={alt} /> : initials}</span>; }
|
|
4
|
+
export function Progress({ value, label, className = "" }: { value: number; label?: ReactNode; className?: string }) { return <div className={`progress ${className}`}><div className="progress-track"><span style={{ width: `${Math.max(0, Math.min(100, value))}%` }} /></div>{label && <span className="progress-label">{label}</span>}</div>; }
|
|
5
|
+
export function Breadcrumbs({ items }: { items: Array<{ label: string; href?: string }> }) { return <nav aria-label="Breadcrumb" className="breadcrumbs">{items.map((item,i)=><span key={`${item.label}-${i}`}>{i>0&&<span aria-hidden> / </span>}{item.href?<a href={item.href}>{item.label}</a>:<strong aria-current="page">{item.label}</strong>}</span>)}</nav> }
|
|
6
|
+
export function Pagination({ page, pages, onPageChange }: { page: number; pages: number; onPageChange: (page:number)=>void }) { return <nav className="pagination" aria-label="Pagination">{Array.from({length:pages},(_,i)=>i+1).map(n=><button key={n} className="page-btn" aria-current={n===page?"page":undefined} onClick={()=>onPageChange(n)}>{n}</button>)}</nav> }
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { ReactNode } from "react";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Page heading. Section pages are already named in the top bar breadcrumb, so their H1 is kept for
|
|
5
|
+
* screen readers only. Record pages (with an eyebrow, e.g. "Booking") show the record's title visibly.
|
|
6
|
+
*/
|
|
7
|
+
export function PageHeader({ eyebrow, title, subtitle, actions, className = "" }: { eyebrow?: string; title: string; subtitle?: ReactNode; actions?: ReactNode; className?: string }) {
|
|
8
|
+
const visibleTitle = !!eyebrow;
|
|
9
|
+
return (
|
|
10
|
+
<div className={`flex flex-col gap-4 md:flex-row md:items-end md:justify-between ${className}`}>
|
|
11
|
+
<div className="min-w-0">
|
|
12
|
+
{eyebrow && <div className="meta mb-2 text-[11px] font-medium uppercase tracking-wide">{eyebrow}</div>}
|
|
13
|
+
<h1 className={visibleTitle ? "h1" : "sr-only"}>{title}</h1>
|
|
14
|
+
{subtitle && <p className={`max-w-2xl text-[13px] text-muted ${visibleTitle ? "mt-2" : ""}`}>{subtitle}</p>}
|
|
15
|
+
</div>
|
|
16
|
+
{actions && <div className="flex flex-wrap items-center gap-2">{actions}</div>}
|
|
17
|
+
</div>
|
|
18
|
+
);
|
|
19
|
+
}
|
package/src/sidebar.tsx
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { ReactNode } from "react";
|
|
2
|
+
|
|
3
|
+
export function Sidebar({ children, collapsed = false, className = "" }: { children: ReactNode; collapsed?: boolean; className?: string }) {
|
|
4
|
+
return <aside className={`sidebar${collapsed ? " sidebar-collapsed" : ""} ${className}`} aria-label="Sidebar">{children}</aside>;
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
export function SidebarHeader({ brand, action, className = "" }: { brand: ReactNode; action?: ReactNode; className?: string }) {
|
|
8
|
+
return <div className={`sidebar-header ${className}`}><div className="sidebar-brand">{brand}</div>{action}</div>;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export function SidebarSection({ label, children, className = "" }: { label?: ReactNode; children: ReactNode; className?: string }) {
|
|
12
|
+
return <section className={`sidebar-section ${className}`}>{label && <div className="sidebar-label">{label}</div>}<nav className="sidebar-nav">{children}</nav></section>;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export function SidebarItem({ href = "#", active = false, icon, children, badge, className = "", onClick }: { href?: string; active?: boolean; icon?: ReactNode; children: ReactNode; badge?: ReactNode; className?: string; onClick?: () => void }) {
|
|
16
|
+
return <a href={href} onClick={onClick} className={`sidebar-item${active ? " sidebar-item-active" : ""} ${className}`} aria-current={active ? "page" : undefined}><span className="sidebar-item-content">{icon && <span className="sidebar-icon" aria-hidden>{icon}</span>}<span className="sidebar-item-label">{children}</span></span>{badge && <span className="sidebar-badge">{badge}</span>}</a>;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export function SidebarFooter({ children, className = "" }: { children: ReactNode; className?: string }) {
|
|
20
|
+
return <div className={`sidebar-footer ${className}`}>{children}</div>;
|
|
21
|
+
}
|
package/src/styles.css
ADDED
|
@@ -0,0 +1,208 @@
|
|
|
1
|
+
|
|
2
|
+
@theme {
|
|
3
|
+
--font-sans: var(--font-inter), ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
|
|
4
|
+
--color-bg: #f7f8fa;
|
|
5
|
+
--color-surface: #ffffff;
|
|
6
|
+
--color-surface-subtle: #fbfbfc;
|
|
7
|
+
--color-border: #e5e7eb;
|
|
8
|
+
--color-border-strong: #d8dce4;
|
|
9
|
+
--color-text: #24262b;
|
|
10
|
+
--color-muted: #737984;
|
|
11
|
+
--color-quiet: #9ca3af;
|
|
12
|
+
--color-accent: #1f1f1f;
|
|
13
|
+
--color-accent-dark: #000000;
|
|
14
|
+
--color-accent-soft: #f1f1f1;
|
|
15
|
+
--color-green: #16835b;
|
|
16
|
+
--color-green-soft: #e7f6ee;
|
|
17
|
+
--color-orange: #bd6a24;
|
|
18
|
+
--color-orange-soft: #fff2e6;
|
|
19
|
+
--color-blue: #3777b5;
|
|
20
|
+
--color-blue-soft: #eaf3fb;
|
|
21
|
+
--color-purple: #8359b8;
|
|
22
|
+
--color-purple-soft: #f2ebfb;
|
|
23
|
+
--color-red: #c4382f;
|
|
24
|
+
--color-red-soft: #fdeceb;
|
|
25
|
+
--shadow-card: 0 1px 2px rgba(29, 34, 44, 0.04);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
:root { color-scheme: light; }
|
|
29
|
+
html, body { background: var(--color-bg); color: var(--color-text); }
|
|
30
|
+
body { font-size: 13px; line-height: 1.5; -webkit-font-smoothing: antialiased; }
|
|
31
|
+
|
|
32
|
+
@layer components {
|
|
33
|
+
.sidebar { display:flex; flex-direction:column; width:244px; min-height:100%; flex:none; background:var(--color-surface); border-right:1px solid var(--color-border); color:var(--color-text); }
|
|
34
|
+
.sidebar-header { display:flex; align-items:center; justify-content:space-between; gap:12px; min-height:56px; padding:0 16px; border-bottom:1px solid var(--color-border); }
|
|
35
|
+
.sidebar-brand { min-width:0; font-size:13px; font-weight:600; letter-spacing:-.01em; }
|
|
36
|
+
.sidebar-section { padding:14px 10px 0; }
|
|
37
|
+
.sidebar-section + .sidebar-section { padding-top:18px; }
|
|
38
|
+
.sidebar-label { padding:0 10px 7px; color:var(--color-quiet); font-size:10px; font-weight:500; letter-spacing:.04em; text-transform:uppercase; }
|
|
39
|
+
.sidebar-nav { display:grid; gap:2px; }
|
|
40
|
+
.sidebar-item { display:flex; align-items:center; justify-content:space-between; gap:8px; min-height:32px; padding:0 10px; border-radius:6px; color:#4b5059; font-size:13px; text-decoration:none; }
|
|
41
|
+
.sidebar-item:hover { background:#eef0f3; color:var(--color-text); }
|
|
42
|
+
.sidebar-item-active { background:var(--color-accent-soft); color:var(--color-accent); font-weight:600; }
|
|
43
|
+
.sidebar-item-content { display:flex; align-items:center; gap:9px; min-width:0; }
|
|
44
|
+
.sidebar-icon { display:inline-flex; align-items:center; justify-content:center; width:16px; height:16px; color:var(--color-muted); flex:none; }
|
|
45
|
+
.sidebar-icon svg { width:16px; height:16px; }
|
|
46
|
+
.sidebar-item-active .sidebar-icon { color:var(--color-accent); }
|
|
47
|
+
.sidebar-item-label { overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
|
|
48
|
+
.sidebar-badge { color:var(--color-quiet); font-size:10px; font-variant-numeric:tabular-nums; }
|
|
49
|
+
.sidebar-footer { margin-top:auto; padding:12px 16px; border-top:1px solid var(--color-border); }
|
|
50
|
+
.sidebar-collapsed { width:64px; }
|
|
51
|
+
.sidebar-collapsed .sidebar-item-label,.sidebar-collapsed .sidebar-label,.sidebar-collapsed .sidebar-badge { display:none; }
|
|
52
|
+
.sidebar-collapsed .sidebar-item { justify-content:center; padding:0; }
|
|
53
|
+
.sidebar-collapsed .sidebar-item-content { justify-content:center; }
|
|
54
|
+
.h1 { font-size: 26px; font-weight: 600; line-height: 1.1; letter-spacing: -0.035em; }
|
|
55
|
+
.h2 { font-size: 15px; font-weight: 600; }
|
|
56
|
+
.meta { font-size: 12px; color: var(--color-muted); }
|
|
57
|
+
|
|
58
|
+
.btn {
|
|
59
|
+
display: inline-flex; align-items: center; justify-content: center; gap: 6px; white-space: nowrap; flex-shrink: 0;
|
|
60
|
+
height: 34px; padding: 0 12px; border-radius: 6px; font-size: 12.5px; font-weight: 600; line-height: 1;
|
|
61
|
+
border: 1px solid transparent; cursor: pointer; transition: background-color .12s, border-color .12s, color .12s;
|
|
62
|
+
appearance: none; text-decoration: none; user-select: none;
|
|
63
|
+
}
|
|
64
|
+
.btn svg { width: 14px; height: 14px; flex: none; stroke-width: 2; }
|
|
65
|
+
.btn:focus-visible, .icon-btn:focus-visible, .tab:focus-visible, .nav-link:focus-visible, .link:focus-visible {
|
|
66
|
+
outline: 2px solid var(--color-accent); outline-offset: 2px;
|
|
67
|
+
}
|
|
68
|
+
.btn:disabled, .btn[aria-disabled="true"] { cursor: not-allowed; opacity: .55; }
|
|
69
|
+
.btn-primary { background: var(--color-accent); color: #fff; }
|
|
70
|
+
.btn-primary:hover:not(:disabled) { background: var(--color-accent-dark); }
|
|
71
|
+
.btn-secondary { background: var(--color-surface); color: var(--color-text); border-color: var(--color-border-strong); }
|
|
72
|
+
.btn-secondary:hover:not(:disabled) { background: var(--color-surface-subtle); border-color: #c9ced8; }
|
|
73
|
+
.btn-danger { background: var(--color-surface); color: var(--color-red); border-color: #efc4c0; }
|
|
74
|
+
.btn-danger:hover:not(:disabled) { background: var(--color-red-soft); }
|
|
75
|
+
.btn-danger-solid { background: var(--color-red); color: #fff; }
|
|
76
|
+
.btn-sm { height: 30px; padding: 0 10px; font-size: 12px; }
|
|
77
|
+
|
|
78
|
+
.icon-btn {
|
|
79
|
+
display: inline-flex; align-items: center; justify-content: center; width: 32px; height: 32px; border-radius: 6px;
|
|
80
|
+
color: var(--color-muted); background: transparent; border: 0; cursor: pointer; position: relative;
|
|
81
|
+
}
|
|
82
|
+
.icon-btn::after { content: ""; position: absolute; inset: -6px; } /* 44px touch target */
|
|
83
|
+
.icon-btn:hover { background: #f0f1f4; color: var(--color-text); }
|
|
84
|
+
.icon-btn svg { width: 16px; height: 16px; }
|
|
85
|
+
|
|
86
|
+
/* Inputs (Twenty UI): 32px, 4px radius, light border, subtle fill; neutral focus border, no glow. */
|
|
87
|
+
.control {
|
|
88
|
+
width: 100%; height: 32px; border: 1px solid #ebebeb; border-radius: 4px;
|
|
89
|
+
background: #fcfcfc; color: #333333; padding: 0 8px; font-size: 13px; appearance: none;
|
|
90
|
+
transition: border-color .12s, box-shadow .12s, background-color .12s;
|
|
91
|
+
}
|
|
92
|
+
.control:hover:not(:disabled):not(:focus) { background: #f8f8f8; }
|
|
93
|
+
.control:focus, .control:focus-visible { outline: none; border-color: #1f1f1f; background: #fff; box-shadow: none; }
|
|
94
|
+
.control::placeholder { color: var(--color-quiet); }
|
|
95
|
+
.control:disabled { background: var(--color-surface-subtle); color: var(--color-muted); }
|
|
96
|
+
.control[aria-invalid="true"] { border-color: var(--color-red); }
|
|
97
|
+
.control[aria-invalid="true"]:focus { box-shadow: none; border-color: var(--color-red); }
|
|
98
|
+
textarea.control { height: auto; padding: 8px; min-height: 84px; line-height: 1.5; }
|
|
99
|
+
select.control {
|
|
100
|
+
padding-right: 28px; cursor: pointer;
|
|
101
|
+
background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23737984' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
|
|
102
|
+
background-repeat: no-repeat; background-position: right 8px center;
|
|
103
|
+
}
|
|
104
|
+
input[type="checkbox"].check, input[type="radio"].check { width: 16px; height: 16px; accent-color: var(--color-accent); }
|
|
105
|
+
.label { display: block; font-size: 12px; font-weight: 600; margin-bottom: 6px; color: var(--color-text); }
|
|
106
|
+
.hint { font-size: 11.5px; color: var(--color-muted); margin-top: 5px; }
|
|
107
|
+
.field-error { font-size: 11.5px; color: var(--color-red); margin-top: 5px; }
|
|
108
|
+
|
|
109
|
+
.card { background: var(--color-surface); border: 1px solid var(--color-border); border-radius: 8px; box-shadow: var(--shadow-card); }
|
|
110
|
+
.card-pad { padding: 16px; }
|
|
111
|
+
|
|
112
|
+
.table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 12.5px; }
|
|
113
|
+
.table th { background: var(--color-surface-subtle); text-align: left; font-weight: 500; font-size: 11.5px; color: var(--color-muted); padding: 9px 12px; border-bottom: 1px solid var(--color-border); white-space: nowrap; }
|
|
114
|
+
.table td { padding: 10px 12px; border-bottom: 1px solid var(--color-border); vertical-align: middle; }
|
|
115
|
+
.table tr:last-child td { border-bottom: 0; }
|
|
116
|
+
.table tbody tr:hover td { background: #fcfcfd; }
|
|
117
|
+
|
|
118
|
+
/* Tags (Twenty UI style): soft tint, hairline border in the same hue, coloured label, no dot. */
|
|
119
|
+
.badge {
|
|
120
|
+
display: inline-flex; align-items: center; gap: 4px; height: 22px; padding: 0 8px; border-radius: 6px;
|
|
121
|
+
border: 1px solid transparent; font-size: 12px; font-weight: 500; line-height: 1; white-space: nowrap;
|
|
122
|
+
}
|
|
123
|
+
.badge svg { width: 12px; height: 12px; }
|
|
124
|
+
.badge-neutral { background: #f4f5f7; color: #4b5059; border-color: #e3e5e9; }
|
|
125
|
+
.badge-green { background: #ecf8f1; color: #1a7f53; border-color: #c4e8d4; }
|
|
126
|
+
.badge-orange { background: #fff5eb; color: #b05f1d; border-color: #f6d9bb; }
|
|
127
|
+
.badge-blue { background: #eef5fc; color: #2f6ea8; border-color: #c9ddf1; }
|
|
128
|
+
.badge-purple { background: #f5effc; color: #7a4fb0; border-color: #ddcdf1; }
|
|
129
|
+
.badge-red { background: #fdf0ef; color: #b8352c; border-color: #f3cbc7; }
|
|
130
|
+
.badge-accent { background: #f4f5f7; color: #1f1f1f; border-color: #e3e5e9; }
|
|
131
|
+
|
|
132
|
+
.tabs { display: flex; gap: 18px; height: 48px; border-bottom: 1px solid var(--color-border); overflow-x: auto; scrollbar-width: none; }
|
|
133
|
+
.tab { display: inline-flex; align-items: center; gap: 7px; height: 100%; font-size: 12.5px; font-weight: 500; color: var(--color-muted); border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; text-decoration: none; }
|
|
134
|
+
.tab:hover { color: var(--color-text); }
|
|
135
|
+
.tab[aria-current="page"], .tab[aria-current="true"], .tab[aria-selected="true"] { color: var(--color-accent); border-bottom-color: var(--color-accent); font-weight: 600; }
|
|
136
|
+
.tab svg { width: 15px; height: 15px; }
|
|
137
|
+
|
|
138
|
+
.nav-link { display: flex; align-items: center; gap: 10px; height: 32px; padding: 0 10px; border-radius: 6px; font-size: 13px; color: #4b5059; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; text-decoration: none; }
|
|
139
|
+
.nav-link svg { width: 16px; height: 16px; flex: none; color: var(--color-muted); }
|
|
140
|
+
.nav-link:hover { background: #eef0f3; color: var(--color-text); }
|
|
141
|
+
.nav-link[aria-current="page"] { background: var(--color-accent-soft); color: var(--color-accent); font-weight: 600; }
|
|
142
|
+
.nav-link[aria-current="page"] svg { color: var(--color-accent); }
|
|
143
|
+
|
|
144
|
+
.link { color: var(--color-text); font-weight: 500; text-decoration: underline; text-decoration-color: #d0d3d9; text-underline-offset: 2px; }
|
|
145
|
+
.link:hover { text-decoration-color: currentColor; }
|
|
146
|
+
|
|
147
|
+
.dl { display: grid; grid-template-columns: minmax(110px, 38%) 1fr; gap: 8px 12px; font-size: 12.5px; }
|
|
148
|
+
.dl dt { color: var(--color-muted); }
|
|
149
|
+
.dl dd { color: var(--color-text); min-width: 0; overflow-wrap: anywhere; }
|
|
150
|
+
|
|
151
|
+
dialog.dialog { border: 1px solid var(--color-border); border-radius: 10px; padding: 0; width: min(560px, calc(100vw - 24px)); max-height: calc(100dvh - 32px); box-shadow: 0 12px 32px rgba(29,34,44,.14); color: var(--color-text); }
|
|
152
|
+
dialog.dialog::backdrop { background: rgba(36, 38, 43, .32); }
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
@media (prefers-reduced-motion: reduce) {
|
|
156
|
+
*, *::before, *::after { transition: none !important; animation: none !important; scroll-behavior: auto !important; }
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
/* Floating liquid-glass navigation (ring via inset shadow so height stays exact) */
|
|
160
|
+
.glass-nav {
|
|
161
|
+
/* Frosted "liquid glass": a milky tint plus heavy blur, so whatever is behind softens into colour but is never readable. */
|
|
162
|
+
background: linear-gradient(135deg, rgba(255,255,255,0.78), rgba(255,255,255,0.58));
|
|
163
|
+
-webkit-backdrop-filter: blur(28px) saturate(200%) brightness(1.08);
|
|
164
|
+
backdrop-filter: blur(28px) saturate(200%) brightness(1.08);
|
|
165
|
+
box-shadow: inset 0 1px 1px rgba(255,255,255,0.9), inset 0 -1px 1px rgba(255,255,255,0.35), 0 0 0 1px rgba(255,255,255,0.45), 0 0 0 2px rgba(20,30,50,0.06);
|
|
166
|
+
}
|
|
167
|
+
@media (prefers-reduced-transparency: reduce) { .glass-nav { background: #fff; -webkit-backdrop-filter: none; backdrop-filter: none; } }
|
|
168
|
+
|
|
169
|
+
/* Smooth scrolling + scroll reveal */
|
|
170
|
+
html { scroll-behavior: smooth; scroll-padding-top: 96px; overscroll-behavior-y: none; }
|
|
171
|
+
.reveal { opacity: 0; transform: translateY(22px); transition: opacity .7s cubic-bezier(.22,1,.36,1), transform .7s cubic-bezier(.22,1,.36,1); transition-delay: var(--reveal-delay, 0ms); will-change: opacity, transform; }
|
|
172
|
+
.reveal.reveal-in { opacity: 1; transform: none; will-change: auto; }
|
|
173
|
+
@keyframes hero-rise { from { opacity: 0; transform: translateY(18px); } to { opacity: 1; transform: none; } }
|
|
174
|
+
.hero-rise > * { opacity: 0; animation: hero-rise .9s cubic-bezier(.22,1,.36,1) forwards; }
|
|
175
|
+
.hero-rise > *:nth-child(2) { animation-delay: .1s; } .hero-rise > *:nth-child(3) { animation-delay: .2s; } .hero-rise > *:nth-child(4) { animation-delay: .3s; }
|
|
176
|
+
@media (prefers-reduced-motion: reduce) { .reveal { opacity: 1; transform: none; } .hero-rise > * { opacity: 1; animation: none; } }
|
|
177
|
+
|
|
178
|
+
/* Smooth page changes: cross-fade the page body, . */
|
|
179
|
+
@keyframes vt-out { to { opacity: 0; } }
|
|
180
|
+
@keyframes vt-in { from { opacity: 0; } }
|
|
181
|
+
::view-transition-old(root) { animation: vt-out 160ms ease-out both; }
|
|
182
|
+
::view-transition-new(root) { animation: vt-in 240ms ease-out 60ms both; }
|
|
183
|
+
@media (prefers-reduced-motion: reduce) {
|
|
184
|
+
::view-transition-group(*), ::view-transition-old(*), ::view-transition-new(*) { animation: none !important; }
|
|
185
|
+
}
|
|
186
|
+
/* Loading placeholders appear only if the page is slow, so quick loads never flash. */
|
|
187
|
+
.load-delay { opacity: 1; }
|
|
188
|
+
|
|
189
|
+
/* Skeleton placeholders: soft shimmer shown while a page is slow to load. */
|
|
190
|
+
@keyframes skeleton-shimmer { to { background-position: -200% 0; } }
|
|
191
|
+
.skeleton { background: linear-gradient(100deg, #eceef1 40%, #f6f7f9 50%, #eceef1 60%) 0 0 / 200% 100%; animation: skeleton-shimmer 1.4s linear infinite; border-radius: 10px; }
|
|
192
|
+
@media (prefers-reduced-motion: reduce) { .skeleton { animation: none; } }
|
|
193
|
+
|
|
194
|
+
/* Soft page-to-page entrance (see (site)/template.tsx). Opacity + a few px of lift only, so layout never jumps. */
|
|
195
|
+
@keyframes page-enter { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
|
|
196
|
+
.page-enter { animation: none; }
|
|
197
|
+
@media (prefers-reduced-motion: reduce) { .page-enter { animation: none; } }
|
|
198
|
+
|
|
199
|
+
@layer components {
|
|
200
|
+
.control-shell { display:flex;align-items:center;width:100%;height:32px;border:1px solid #ebebeb;border-radius:4px;background:#fcfcfc;padding:0 8px;transition:border-color .12s,background-color .12s; }
|
|
201
|
+
.control-shell:focus-within { border-color:#1f1f1f;background:#fff; }.control-shell .control{border:0;background:transparent;padding:0 6px}.control-slot{display:inline-flex;color:var(--color-muted)}.control-slot svg{width:14px;height:14px}
|
|
202
|
+
.check-row,.switch-row{display:inline-flex;align-items:center;gap:8px;min-height:32px;cursor:pointer;font-size:13px}.switch-row input{appearance:none;width:32px;height:18px;margin:0;border:1px solid var(--color-border-strong);border-radius:999px;background:var(--color-surface);cursor:pointer;position:relative;transition:background-color .12s,border-color .12s}.switch-row input::after{content:"";position:absolute;width:14px;height:14px;top:1px;left:1px;border-radius:50%;background:#fff;box-shadow:var(--shadow-card);transition:transform .12s}.switch-row input:checked{background:var(--color-accent);border-color:var(--color-accent)}.switch-row input:checked::after{transform:translateX(14px)}
|
|
203
|
+
.card-header{display:flex;align-items:flex-start;justify-content:space-between;gap:16px;padding:14px 16px;border-bottom:1px solid var(--color-border)}.card-header .meta{margin-top:3px}.card-actions{display:flex;gap:8px;align-items:center}
|
|
204
|
+
.toaster{position:fixed;z-index:100;right:16px;bottom:16px;display:grid;gap:8px;width:min(360px,calc(100vw - 24px))}.toast{display:flex;align-items:center;gap:9px;min-height:46px;padding:10px 10px 10px 12px;background:var(--color-surface);border:1px solid var(--color-border);border-radius:8px;box-shadow:0 12px 32px rgba(29,34,44,.14);font-size:12.5px;animation:toast-in .16s ease-out both}.toast>svg{width:16px;height:16px;flex:none}.toast-success>svg{color:var(--color-green)}.toast-error>svg{color:var(--color-red)}.toast-info>svg{color:var(--color-blue)}.toast>span{flex:1}
|
|
205
|
+
.menu{position:relative;display:inline-block}.menu-trigger{border:0;background:transparent;padding:0;cursor:pointer}.menu-panel{position:absolute;z-index:20;right:0;top:calc(100% + 5px);min-width:180px;padding:4px;background:var(--color-surface);border:1px solid var(--color-border);border-radius:8px;box-shadow:0 12px 32px rgba(29,34,44,.14)}.menu-item{display:flex;align-items:center;width:100%;min-height:32px;padding:0 9px;border:0;border-radius:6px;background:transparent;color:var(--color-text);font-size:12.5px;text-align:left;cursor:pointer}.menu-item:hover,.menu-item:focus-visible{background:#eef0f3;outline:0}.menu-item.destructive{color:var(--color-red)}.menu-separator{height:1px;margin:4px 0;background:var(--color-border)}
|
|
206
|
+
.avatar{display:inline-grid;place-items:center;overflow:hidden;flex:none;border-radius:50%;background:var(--color-accent-soft);color:var(--color-accent);font-size:12px;font-weight:600}.avatar img{width:100%;height:100%;object-fit:cover}.avatar-sm{width:24px;height:24px}.avatar-md{width:32px;height:32px}.avatar-lg{width:40px;height:40px}.progress{display:flex;align-items:center;gap:9px}.progress-track{height:6px;flex:1;overflow:hidden;border-radius:999px;background:var(--color-accent-soft)}.progress-track span{display:block;height:100%;border-radius:inherit;background:var(--color-accent);transition:width .16s ease-out}.progress-label{color:var(--color-muted);font-size:12px;font-variant-numeric:tabular-nums}.breadcrumbs{display:flex;align-items:center;gap:4px;color:var(--color-muted);font-size:12px}.breadcrumbs a{color:inherit;text-decoration:none}.breadcrumbs a:hover{color:var(--color-text)}.breadcrumbs strong{color:var(--color-text);font-weight:600}.pagination{display:flex;gap:4px}.page-btn{min-width:30px;height:30px;border:1px solid var(--color-border);border-radius:6px;background:var(--color-surface);color:var(--color-muted);cursor:pointer}.page-btn:hover{background:var(--color-surface-subtle);color:var(--color-text)}.page-btn[aria-current="page"]{border-color:var(--color-accent);background:var(--color-accent);color:#fff}
|
|
207
|
+
@keyframes toast-in{from{opacity:0;transform:translateY(8px)}to{opacity:1;transform:none}}
|
|
208
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import type { ReactNode } from "react";
|
|
3
|
+
import { useActionPending } from "./action-form";
|
|
4
|
+
import { Button } from "./button";
|
|
5
|
+
|
|
6
|
+
export function SubmitButton({ children, variant = "primary", pendingLabel, className = "", confirm, name, value }: { children: ReactNode; variant?: "primary" | "secondary" | "danger" | "danger-solid"; pendingLabel?: string; className?: string; confirm?: string; name?: string; value?: string }) {
|
|
7
|
+
const ctx = useActionPending();
|
|
8
|
+
const pending = ctx;
|
|
9
|
+
return (
|
|
10
|
+
<Button
|
|
11
|
+
type="submit" name={name} value={value}
|
|
12
|
+
variant={variant} className={className} loading={pending}
|
|
13
|
+
onClick={(e) => { if (confirm && !window.confirm(confirm)) e.preventDefault(); }}
|
|
14
|
+
>
|
|
15
|
+
{pending ? pendingLabel ?? "Working…" : children}
|
|
16
|
+
</Button>
|
|
17
|
+
);
|
|
18
|
+
}
|
package/src/tabs.tsx
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { ReactNode } from "react";
|
|
2
|
+
|
|
3
|
+
export type TabItem = { href: string; label: string; icon?: ReactNode; active: boolean; count?: number };
|
|
4
|
+
|
|
5
|
+
/** Page-level tab band. Leaves 36px before content (design.md §4). */
|
|
6
|
+
export function PageTabs({ items, className = "mt-6 mb-9" }: { items: TabItem[]; className?: string }) {
|
|
7
|
+
return (
|
|
8
|
+
<nav aria-label="Sections" className={`tabs ${className}`}>
|
|
9
|
+
{items.map((t) => (
|
|
10
|
+
<a key={t.href} href={t.href} className="tab" aria-current={t.active ? "page" : undefined}>
|
|
11
|
+
{t.icon}
|
|
12
|
+
{t.label}
|
|
13
|
+
{typeof t.count === "number" && <span className="rounded-[5px] bg-[#f0f1f4] px-1.5 text-[11px] text-muted">{t.count}</span>}
|
|
14
|
+
</a>
|
|
15
|
+
))}
|
|
16
|
+
</nav>
|
|
17
|
+
);
|
|
18
|
+
}
|
package/src/toast.tsx
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { AlertCircle, CheckCircle2, Info, X } from "lucide-react";
|
|
2
|
+
import { createContext, useCallback, useContext, useMemo, useState, type ReactNode } from "react";
|
|
3
|
+
type Kind = "success" | "error" | "info"; type Item = { id: number; kind: Kind; message: string; action?: ReactNode };
|
|
4
|
+
const ToastContext = createContext<{toast:{success:(message:string,action?:ReactNode)=>void;error:(message:string,action?:ReactNode)=>void;info:(message:string,action?:ReactNode)=>void}} | null>(null);
|
|
5
|
+
export function Toaster({ children }: { children?: ReactNode }) { const [items,setItems]=useState<Item[]>([]); const add=useCallback((kind:Kind,message:string,action?:ReactNode)=>{const id=Date.now()+Math.random();setItems(v=>[...v.slice(-2),{id,kind,message,action}]);if(kind!=="error"||!action)window.setTimeout(()=>setItems(v=>v.filter(x=>x.id!==id)),kind==="error"?6000:4000)},[]); const toast=useMemo(()=>({success:(m:string,a?:ReactNode)=>add("success",m,a),error:(m:string,a?:ReactNode)=>add("error",m,a),info:(m:string,a?:ReactNode)=>add("info",m,a)}),[add]);return <ToastContext.Provider value={{toast}}>{children}<div className="toaster" aria-live="polite">{items.map(item=><div className={`toast toast-${item.kind}`} key={item.id} role={item.kind==="error"?"alert":"status"}>{item.kind==="success"?<CheckCircle2 aria-hidden/>:item.kind==="error"?<AlertCircle aria-hidden/>:<Info aria-hidden/>}<span>{item.message}</span>{item.action}<button className="icon-btn" aria-label="Dismiss notification" onClick={()=>setItems(v=>v.filter(x=>x.id!==item.id))}><X aria-hidden/></button></div>)}</div></ToastContext.Provider> }
|
|
6
|
+
export function useToast(){const context=useContext(ToastContext);if(!context)throw new Error("useToast must be used inside Toaster");return context.toast}
|
package/src/types.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export type ActionResult = { ok: boolean; error?: string; fieldErrors?: Record<string, string>; message?: string };
|