lumonui 0.0.0-stage → 0.1.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 +34 -2
- package/package.json +27 -4
- package/src/action-form.tsx +56 -0
- package/src/badge.tsx +5 -0
- package/src/dialog.tsx +52 -0
- package/src/empty-state.tsx +23 -0
- package/src/field.tsx +16 -0
- package/src/file-button.tsx +27 -0
- package/src/index.ts +10 -0
- package/src/page-header.tsx +19 -0
- package/src/styles.css +176 -0
- package/src/submit-button.tsx +20 -0
- package/src/tabs.tsx +19 -0
- package/src/types.ts +1 -0
package/README.md
CHANGED
|
@@ -1,3 +1,35 @@
|
|
|
1
|
-
#
|
|
1
|
+
# lumonui
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Lumon Studio's UI: design tokens, Tailwind 4 styles and React components for Next.js apps. Source is shipped as-is (no build step).
|
|
4
|
+
|
|
5
|
+
## Use it
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm i lumonui
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
`next.config.ts`:
|
|
12
|
+
```ts
|
|
13
|
+
const config = { transpilePackages: ["lumonui"] };
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
`globals.css` (after Tailwind):
|
|
17
|
+
```css
|
|
18
|
+
@import "tailwindcss";
|
|
19
|
+
@import "lumonui/styles.css";
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
```tsx
|
|
23
|
+
import { PageHeader, Field, SubmitButton, Badge, Dialog } from "lumonui";
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
Needs `next`, `react`, `react-dom`, `lucide-react` (the only icon library) and `tailwindcss` 4. The layout must set `--font-inter` (next/font) for the font.
|
|
27
|
+
|
|
28
|
+
## What's inside
|
|
29
|
+
|
|
30
|
+
- `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).
|
|
31
|
+
- Components: `ActionForm`, `SubmitButton`, `Field`, `FormAlert`, `Dialog`, `PageTabs`, `PageHeader`, `EmptyState`, `TableEmpty`, `FileButton`, `Badge`.
|
|
32
|
+
|
|
33
|
+
## Releasing
|
|
34
|
+
|
|
35
|
+
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,29 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "lumonui",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Lumon Studio UI: design tokens, Tailwind 4 styles and React components for Next.js apps.",
|
|
5
|
+
"license": "UNLICENSED",
|
|
6
|
+
"type": "module",
|
|
7
|
+
"files": ["src"],
|
|
8
|
+
"exports": {
|
|
9
|
+
".": "./src/index.ts",
|
|
10
|
+
"./styles.css": "./src/styles.css"
|
|
11
|
+
},
|
|
12
|
+
"scripts": { "typecheck": "tsc --noEmit" },
|
|
13
|
+
"peerDependencies": {
|
|
14
|
+
"lucide-react": ">=1",
|
|
15
|
+
"next": ">=15",
|
|
16
|
+
"react": ">=19",
|
|
17
|
+
"react-dom": ">=19",
|
|
18
|
+
"tailwindcss": ">=4"
|
|
19
|
+
},
|
|
20
|
+
"devDependencies": {
|
|
21
|
+
"@types/react": "^19.3.0",
|
|
22
|
+
"@types/react-dom": "^19.2.0",
|
|
23
|
+
"lucide-react": "^1.72.0",
|
|
24
|
+
"next": "^15.5.29",
|
|
25
|
+
"react": "^19.3.1",
|
|
26
|
+
"react-dom": "^19.3.1",
|
|
27
|
+
"typescript": "^5.9.0"
|
|
28
|
+
}
|
|
29
|
+
}
|
|
@@ -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 { ReactNode } from "react";
|
|
2
|
+
|
|
3
|
+
export function Badge({ tone = "neutral", children }: { tone?: "neutral" | "green" | "orange" | "blue" | "purple" | "red" | "accent"; children: ReactNode }) {
|
|
4
|
+
return <span className={`badge badge-${tone}`}>{children}</span>;
|
|
5
|
+
}
|
package/src/dialog.tsx
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { X } from "lucide-react";
|
|
3
|
+
import { usePathname } from "next/navigation";
|
|
4
|
+
import { createContext, useContext, useEffect, useId, useRef, useState, type ReactNode } from "react";
|
|
5
|
+
|
|
6
|
+
const CloseCtx = createContext<(() => void) | null>(null);
|
|
7
|
+
/** Close the surrounding Dialog from inside a form (works from server-rendered pages). */
|
|
8
|
+
export function useDialogClose() {
|
|
9
|
+
return useContext(CloseCtx) ?? (() => {});
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Native <dialog> modal: traps focus, closes on Escape, and restores focus to the trigger.
|
|
14
|
+
* `children` may be a function receiving `close`.
|
|
15
|
+
*/
|
|
16
|
+
export function Dialog({ trigger, title, description, children, triggerClassName = "btn btn-primary", triggerLabel, wide, width, onClosed }: {
|
|
17
|
+
trigger: ReactNode; triggerLabel?: string; title: string; description?: string; triggerClassName?: string; wide?: boolean; width?: string; onClosed?: () => void;
|
|
18
|
+
children: ReactNode | ((close: () => void) => ReactNode);
|
|
19
|
+
}) {
|
|
20
|
+
const ref = useRef<HTMLDialogElement>(null);
|
|
21
|
+
const [open, setOpen] = useState(false);
|
|
22
|
+
const id = useId();
|
|
23
|
+
useEffect(() => {
|
|
24
|
+
const d = ref.current;
|
|
25
|
+
if (!d) return;
|
|
26
|
+
if (open && !d.open) d.showModal();
|
|
27
|
+
if (!open && d.open) d.close();
|
|
28
|
+
}, [open]);
|
|
29
|
+
// Layouts persist across navigation, so close when the route changes.
|
|
30
|
+
const path = usePathname();
|
|
31
|
+
useEffect(() => setOpen(false), [path]);
|
|
32
|
+
const close = () => setOpen(false);
|
|
33
|
+
return (
|
|
34
|
+
<>
|
|
35
|
+
<button type="button" className={triggerClassName} onClick={() => setOpen(true)} aria-haspopup="dialog" aria-label={triggerLabel}>{trigger}</button>
|
|
36
|
+
<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(); }}>
|
|
37
|
+
{open && (
|
|
38
|
+
<div className="flex max-h-[calc(100dvh-34px)] flex-col">
|
|
39
|
+
<div className="flex items-start justify-between gap-4 border-b border-border px-5 py-4">
|
|
40
|
+
<div>
|
|
41
|
+
<h2 id={`${id}-t`} className="text-[15px] font-semibold">{title}</h2>
|
|
42
|
+
{description && <p className="mt-0.5 text-muted">{description}</p>}
|
|
43
|
+
</div>
|
|
44
|
+
<button type="button" className="icon-btn -mr-2 -mt-1" aria-label="Close dialog" onClick={close}><X aria-hidden /></button>
|
|
45
|
+
</div>
|
|
46
|
+
<div className="overflow-y-auto px-5 py-4"><CloseCtx.Provider value={close}>{typeof children === "function" ? children(close) : children}</CloseCtx.Provider></div>
|
|
47
|
+
</div>
|
|
48
|
+
)}
|
|
49
|
+
</dialog>
|
|
50
|
+
</>
|
|
51
|
+
);
|
|
52
|
+
}
|
|
@@ -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,16 @@
|
|
|
1
|
+
import 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
|
+
return (
|
|
5
|
+
<div className={className}>
|
|
6
|
+
<label className="label" htmlFor={htmlFor}>{label}</label>
|
|
7
|
+
{children}
|
|
8
|
+
{error ? <p className="field-error" id={`${htmlFor}-error`}>{error}</p> : hint ? <p className="hint">{hint}</p> : null}
|
|
9
|
+
</div>
|
|
10
|
+
);
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export function FormAlert({ tone = "error", children }: { tone?: "error" | "success" | "info"; children: ReactNode }) {
|
|
14
|
+
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";
|
|
15
|
+
return <div role={tone === "error" ? "alert" : "status"} className={`rounded-md border px-3 py-2.5 text-[12.5px] font-medium ${cls}`}>{children}</div>;
|
|
16
|
+
}
|
|
@@ -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,10 @@
|
|
|
1
|
+
export * from "./action-form";
|
|
2
|
+
export * from "./badge";
|
|
3
|
+
export * from "./dialog";
|
|
4
|
+
export * from "./empty-state";
|
|
5
|
+
export * from "./field";
|
|
6
|
+
export * from "./file-button";
|
|
7
|
+
export * from "./page-header";
|
|
8
|
+
export * from "./submit-button";
|
|
9
|
+
export * from "./tabs";
|
|
10
|
+
export type { ActionResult } from "./types";
|
|
@@ -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 }: { eyebrow?: string; title: string; subtitle?: ReactNode; actions?: ReactNode }) {
|
|
8
|
+
const visibleTitle = !!eyebrow;
|
|
9
|
+
return (
|
|
10
|
+
<div className="flex flex-col gap-4 md:flex-row md:items-end md:justify-between">
|
|
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/styles.css
ADDED
|
@@ -0,0 +1,176 @@
|
|
|
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
|
+
.h1 { font-size: 26px; font-weight: 600; line-height: 1.1; letter-spacing: -0.035em; }
|
|
34
|
+
.h2 { font-size: 15px; font-weight: 600; }
|
|
35
|
+
.meta { font-size: 12px; color: var(--color-muted); }
|
|
36
|
+
|
|
37
|
+
.btn {
|
|
38
|
+
display: inline-flex; align-items: center; justify-content: center; gap: 6px; white-space: nowrap; flex-shrink: 0;
|
|
39
|
+
height: 34px; padding: 0 12px; border-radius: 6px; font-size: 12.5px; font-weight: 600; line-height: 1;
|
|
40
|
+
border: 1px solid transparent; cursor: pointer; transition: background-color .12s, border-color .12s, color .12s;
|
|
41
|
+
appearance: none; text-decoration: none; user-select: none;
|
|
42
|
+
}
|
|
43
|
+
.btn svg { width: 14px; height: 14px; flex: none; stroke-width: 2; }
|
|
44
|
+
.btn:focus-visible, .icon-btn:focus-visible, .tab:focus-visible, .nav-link:focus-visible, .link:focus-visible {
|
|
45
|
+
outline: 2px solid var(--color-accent); outline-offset: 2px;
|
|
46
|
+
}
|
|
47
|
+
.btn:disabled, .btn[aria-disabled="true"] { cursor: not-allowed; opacity: .55; }
|
|
48
|
+
.btn-primary { background: var(--color-accent); color: #fff; }
|
|
49
|
+
.btn-primary:hover:not(:disabled) { background: var(--color-accent-dark); }
|
|
50
|
+
.btn-secondary { background: var(--color-surface); color: var(--color-text); border-color: var(--color-border-strong); }
|
|
51
|
+
.btn-secondary:hover:not(:disabled) { background: var(--color-surface-subtle); border-color: #c9ced8; }
|
|
52
|
+
.btn-danger { background: var(--color-surface); color: var(--color-red); border-color: #efc4c0; }
|
|
53
|
+
.btn-danger:hover:not(:disabled) { background: var(--color-red-soft); }
|
|
54
|
+
.btn-danger-solid { background: var(--color-red); color: #fff; }
|
|
55
|
+
.btn-sm { height: 30px; padding: 0 10px; font-size: 12px; }
|
|
56
|
+
|
|
57
|
+
.icon-btn {
|
|
58
|
+
display: inline-flex; align-items: center; justify-content: center; width: 32px; height: 32px; border-radius: 6px;
|
|
59
|
+
color: var(--color-muted); background: transparent; border: 0; cursor: pointer; position: relative;
|
|
60
|
+
}
|
|
61
|
+
.icon-btn::after { content: ""; position: absolute; inset: -6px; } /* 44px touch target */
|
|
62
|
+
.icon-btn:hover { background: #f0f1f4; color: var(--color-text); }
|
|
63
|
+
.icon-btn svg { width: 16px; height: 16px; }
|
|
64
|
+
|
|
65
|
+
/* Inputs (Twenty UI): 32px, 4px radius, light border, subtle fill; neutral focus border, no glow. */
|
|
66
|
+
.control {
|
|
67
|
+
width: 100%; height: 32px; border: 1px solid #ebebeb; border-radius: 4px;
|
|
68
|
+
background: #fcfcfc; color: #333333; padding: 0 8px; font-size: 13px; appearance: none;
|
|
69
|
+
transition: border-color .12s, box-shadow .12s, background-color .12s;
|
|
70
|
+
}
|
|
71
|
+
.control:hover:not(:disabled):not(:focus) { background: #f8f8f8; }
|
|
72
|
+
.control:focus, .control:focus-visible { outline: none; border-color: #1f1f1f; background: #fff; box-shadow: none; }
|
|
73
|
+
.control::placeholder { color: var(--color-quiet); }
|
|
74
|
+
.control:disabled { background: var(--color-surface-subtle); color: var(--color-muted); }
|
|
75
|
+
.control[aria-invalid="true"] { border-color: var(--color-red); }
|
|
76
|
+
.control[aria-invalid="true"]:focus { box-shadow: none; border-color: var(--color-red); }
|
|
77
|
+
textarea.control { height: auto; padding: 8px; min-height: 84px; line-height: 1.5; }
|
|
78
|
+
select.control {
|
|
79
|
+
padding-right: 28px; cursor: pointer;
|
|
80
|
+
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");
|
|
81
|
+
background-repeat: no-repeat; background-position: right 8px center;
|
|
82
|
+
}
|
|
83
|
+
input[type="checkbox"].check, input[type="radio"].check { width: 16px; height: 16px; accent-color: var(--color-accent); }
|
|
84
|
+
.label { display: block; font-size: 12px; font-weight: 600; margin-bottom: 6px; color: var(--color-text); }
|
|
85
|
+
.hint { font-size: 11.5px; color: var(--color-muted); margin-top: 5px; }
|
|
86
|
+
.field-error { font-size: 11.5px; color: var(--color-red); margin-top: 5px; }
|
|
87
|
+
|
|
88
|
+
.card { background: var(--color-surface); border: 1px solid var(--color-border); border-radius: 8px; box-shadow: var(--shadow-card); }
|
|
89
|
+
.card-pad { padding: 16px; }
|
|
90
|
+
|
|
91
|
+
.table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 12.5px; }
|
|
92
|
+
.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; }
|
|
93
|
+
.table td { padding: 10px 12px; border-bottom: 1px solid var(--color-border); vertical-align: middle; }
|
|
94
|
+
.table tr:last-child td { border-bottom: 0; }
|
|
95
|
+
.table tbody tr:hover td { background: #fcfcfd; }
|
|
96
|
+
|
|
97
|
+
/* Tags (Twenty UI style): soft tint, hairline border in the same hue, coloured label, no dot. */
|
|
98
|
+
.badge {
|
|
99
|
+
display: inline-flex; align-items: center; gap: 4px; height: 22px; padding: 0 8px; border-radius: 6px;
|
|
100
|
+
border: 1px solid transparent; font-size: 12px; font-weight: 500; line-height: 1; white-space: nowrap;
|
|
101
|
+
}
|
|
102
|
+
.badge svg { width: 12px; height: 12px; }
|
|
103
|
+
.badge-neutral { background: #f4f5f7; color: #4b5059; border-color: #e3e5e9; }
|
|
104
|
+
.badge-green { background: #ecf8f1; color: #1a7f53; border-color: #c4e8d4; }
|
|
105
|
+
.badge-orange { background: #fff5eb; color: #b05f1d; border-color: #f6d9bb; }
|
|
106
|
+
.badge-blue { background: #eef5fc; color: #2f6ea8; border-color: #c9ddf1; }
|
|
107
|
+
.badge-purple { background: #f5effc; color: #7a4fb0; border-color: #ddcdf1; }
|
|
108
|
+
.badge-red { background: #fdf0ef; color: #b8352c; border-color: #f3cbc7; }
|
|
109
|
+
.badge-accent { background: #f4f5f7; color: #1f1f1f; border-color: #e3e5e9; }
|
|
110
|
+
|
|
111
|
+
.tabs { display: flex; gap: 18px; height: 48px; border-bottom: 1px solid var(--color-border); overflow-x: auto; scrollbar-width: none; }
|
|
112
|
+
.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; }
|
|
113
|
+
.tab:hover { color: var(--color-text); }
|
|
114
|
+
.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; }
|
|
115
|
+
.tab svg { width: 15px; height: 15px; }
|
|
116
|
+
|
|
117
|
+
.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; }
|
|
118
|
+
.nav-link svg { width: 16px; height: 16px; flex: none; color: var(--color-muted); }
|
|
119
|
+
.nav-link:hover { background: #eef0f3; color: var(--color-text); }
|
|
120
|
+
.nav-link[aria-current="page"] { background: var(--color-accent-soft); color: var(--color-accent); font-weight: 600; }
|
|
121
|
+
.nav-link[aria-current="page"] svg { color: var(--color-accent); }
|
|
122
|
+
|
|
123
|
+
.link { color: var(--color-text); font-weight: 500; text-decoration: underline; text-decoration-color: #d0d3d9; text-underline-offset: 2px; }
|
|
124
|
+
.link:hover { text-decoration-color: currentColor; }
|
|
125
|
+
|
|
126
|
+
.dl { display: grid; grid-template-columns: minmax(110px, 38%) 1fr; gap: 8px 12px; font-size: 12.5px; }
|
|
127
|
+
.dl dt { color: var(--color-muted); }
|
|
128
|
+
.dl dd { color: var(--color-text); min-width: 0; overflow-wrap: anywhere; }
|
|
129
|
+
|
|
130
|
+
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); }
|
|
131
|
+
dialog.dialog::backdrop { background: rgba(36, 38, 43, .32); }
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
@media (prefers-reduced-motion: reduce) {
|
|
135
|
+
*, *::before, *::after { transition: none !important; animation: none !important; scroll-behavior: auto !important; }
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
/* Floating liquid-glass navigation (ring via inset shadow so height stays exact) */
|
|
139
|
+
.glass-nav {
|
|
140
|
+
/* Frosted "liquid glass": a milky tint plus heavy blur, so whatever is behind softens into colour but is never readable. */
|
|
141
|
+
background: linear-gradient(135deg, rgba(255,255,255,0.78), rgba(255,255,255,0.58));
|
|
142
|
+
-webkit-backdrop-filter: blur(28px) saturate(200%) brightness(1.08);
|
|
143
|
+
backdrop-filter: blur(28px) saturate(200%) brightness(1.08);
|
|
144
|
+
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);
|
|
145
|
+
}
|
|
146
|
+
@media (prefers-reduced-transparency: reduce) { .glass-nav { background: #fff; -webkit-backdrop-filter: none; backdrop-filter: none; } }
|
|
147
|
+
|
|
148
|
+
/* Smooth scrolling + scroll reveal */
|
|
149
|
+
html { scroll-behavior: smooth; scroll-padding-top: 96px; overscroll-behavior-y: none; }
|
|
150
|
+
.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; }
|
|
151
|
+
.reveal.reveal-in { opacity: 1; transform: none; will-change: auto; }
|
|
152
|
+
@keyframes hero-rise { from { opacity: 0; transform: translateY(18px); } to { opacity: 1; transform: none; } }
|
|
153
|
+
.hero-rise > * { opacity: 0; animation: hero-rise .9s cubic-bezier(.22,1,.36,1) forwards; }
|
|
154
|
+
.hero-rise > *:nth-child(2) { animation-delay: .1s; } .hero-rise > *:nth-child(3) { animation-delay: .2s; } .hero-rise > *:nth-child(4) { animation-delay: .3s; }
|
|
155
|
+
@media (prefers-reduced-motion: reduce) { .reveal { opacity: 1; transform: none; } .hero-rise > * { opacity: 1; animation: none; } }
|
|
156
|
+
|
|
157
|
+
/* Smooth page changes: cross-fade the page body, . */
|
|
158
|
+
@keyframes vt-out { to { opacity: 0; } }
|
|
159
|
+
@keyframes vt-in { from { opacity: 0; } }
|
|
160
|
+
::view-transition-old(root) { animation: vt-out 160ms ease-out both; }
|
|
161
|
+
::view-transition-new(root) { animation: vt-in 240ms ease-out 60ms both; }
|
|
162
|
+
@media (prefers-reduced-motion: reduce) {
|
|
163
|
+
::view-transition-group(*), ::view-transition-old(*), ::view-transition-new(*) { animation: none !important; }
|
|
164
|
+
}
|
|
165
|
+
/* Loading placeholders appear only if the page is slow, so quick loads never flash. */
|
|
166
|
+
.load-delay { opacity: 1; }
|
|
167
|
+
|
|
168
|
+
/* Skeleton placeholders: soft shimmer shown while a page is slow to load. */
|
|
169
|
+
@keyframes skeleton-shimmer { to { background-position: -200% 0; } }
|
|
170
|
+
.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; }
|
|
171
|
+
@media (prefers-reduced-motion: reduce) { .skeleton { animation: none; } }
|
|
172
|
+
|
|
173
|
+
/* Soft page-to-page entrance (see (site)/template.tsx). Opacity + a few px of lift only, so layout never jumps. */
|
|
174
|
+
@keyframes page-enter { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
|
|
175
|
+
.page-enter { animation: none; }
|
|
176
|
+
@media (prefers-reduced-motion: reduce) { .page-enter { animation: none; } }
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { useFormStatus } from "react-dom";
|
|
3
|
+
import { Loader2 } from "lucide-react";
|
|
4
|
+
import type { ReactNode } from "react";
|
|
5
|
+
import { useActionPending } from "./action-form";
|
|
6
|
+
|
|
7
|
+
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 }) {
|
|
8
|
+
const status = useFormStatus();
|
|
9
|
+
const ctx = useActionPending();
|
|
10
|
+
const pending = status.pending || ctx;
|
|
11
|
+
return (
|
|
12
|
+
<button
|
|
13
|
+
type="submit" name={name} value={value}
|
|
14
|
+
className={`btn btn-${variant} ${className}`} disabled={pending} aria-busy={pending}
|
|
15
|
+
onClick={(e) => { if (confirm && !window.confirm(confirm)) e.preventDefault(); }}
|
|
16
|
+
>
|
|
17
|
+
{pending ? <><Loader2 className="animate-spin" aria-hidden />{pendingLabel ?? "Working…"}</> : children}
|
|
18
|
+
</button>
|
|
19
|
+
);
|
|
20
|
+
}
|
package/src/tabs.tsx
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import Link from "next/link";
|
|
2
|
+
import type { ReactNode } from "react";
|
|
3
|
+
|
|
4
|
+
export type TabItem = { href: string; label: string; icon?: ReactNode; active: boolean; count?: number };
|
|
5
|
+
|
|
6
|
+
/** Page-level tab band. Leaves 36px before content (design.md §4). */
|
|
7
|
+
export function PageTabs({ items, className = "mt-6 mb-9" }: { items: TabItem[]; className?: string }) {
|
|
8
|
+
return (
|
|
9
|
+
<nav aria-label="Sections" className={`tabs ${className}`}>
|
|
10
|
+
{items.map((t) => (
|
|
11
|
+
<Link key={t.href} href={t.href} className="tab" aria-current={t.active ? "page" : undefined} scroll={false}>
|
|
12
|
+
{t.icon}
|
|
13
|
+
{t.label}
|
|
14
|
+
{typeof t.count === "number" && <span className="rounded-[5px] bg-[#f0f1f4] px-1.5 text-[11px] text-muted">{t.count}</span>}
|
|
15
|
+
</Link>
|
|
16
|
+
))}
|
|
17
|
+
</nav>
|
|
18
|
+
);
|
|
19
|
+
}
|
package/src/types.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export type ActionResult = { ok: boolean; error?: string; fieldErrors?: Record<string, string>; message?: string };
|