@brdgapp/ui 1.0.0 → 1.1.1
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 +65 -0
- package/README.md +14 -3
- package/components/action-menu.d.ts +9 -2
- package/components/action-menu.js +14 -5
- package/components/avatar.d.ts +1 -1
- package/components/avatar.js +7 -5
- package/components/badge.js +2 -1
- package/components/bottom-sheet.d.ts +21 -4
- package/components/bottom-sheet.js +90 -6
- package/components/button-group.d.ts +2 -2
- package/components/button-group.js +1 -1
- package/components/button.d.ts +2 -2
- package/components/button.js +8 -6
- package/components/card.d.ts +2 -2
- package/components/card.js +1 -1
- package/components/checkbox.js +2 -2
- package/components/collapsible.js +4 -3
- package/components/column-filter-menu.d.ts +2 -1
- package/components/column-filter-menu.js +3 -2
- package/components/column-sort-button.d.ts +8 -2
- package/components/column-sort-button.js +12 -2
- package/components/confirm-dialog.d.ts +11 -3
- package/components/confirm-dialog.js +41 -6
- package/components/copy-field.js +4 -2
- package/components/data-state.js +2 -2
- package/components/data-table.d.ts +54 -5
- package/components/data-table.js +79 -30
- package/components/dialog.d.ts +29 -5
- package/components/dialog.js +27 -3
- package/components/drawer.d.ts +16 -6
- package/components/drawer.js +26 -9
- package/components/expandable-bio.js +2 -1
- package/components/field.js +3 -3
- package/components/filter-chip.js +4 -1
- package/components/filter-pill.js +6 -6
- package/components/hover-card.js +4 -2
- package/components/icon-button.d.ts +2 -2
- package/components/icon-button.js +6 -1
- package/components/info-hint.d.ts +8 -1
- package/components/info-hint.js +22 -7
- package/components/input.js +1 -1
- package/components/network-graph.js +1 -1
- package/components/page-banner.js +11 -5
- package/components/scene.d.ts +3 -1
- package/components/scene.js +2 -2
- package/components/search-input.d.ts +2 -2
- package/components/search-input.js +24 -3
- package/components/segmented-control.js +5 -1
- package/components/skeleton.js +3 -1
- package/components/skip-link.js +3 -1
- package/components/stat-box.d.ts +23 -5
- package/components/stat-box.js +33 -16
- package/components/switch.js +5 -1
- package/components/tabs.js +10 -2
- package/components/tag-input.d.ts +3 -1
- package/components/tag-input.js +27 -8
- package/components/tag.js +4 -2
- package/components/textarea.js +2 -2
- package/components/toast.d.ts +12 -5
- package/components/toast.js +15 -5
- package/lib/font-check.d.ts +3 -0
- package/lib/font-check.js +31 -0
- package/package.json +1 -1
- package/styles/globals.css +26 -3
package/components/stat-box.js
CHANGED
|
@@ -1,29 +1,46 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import {
|
|
2
|
+
import { jsxs as _jsxs, jsx as _jsx } from "react/jsx-runtime";
|
|
3
|
+
import * as React from "react";
|
|
3
4
|
import { mergeProps } from "@base-ui/react/merge-props";
|
|
4
5
|
import { useRender } from "@base-ui/react/use-render";
|
|
5
|
-
import { ChevronRight } from "lucide-react";
|
|
6
|
+
import { ArrowDown, ArrowUp, ChevronRight } from "lucide-react";
|
|
6
7
|
import { InfoHint } from "@brdgapp/ui/components/info-hint";
|
|
7
|
-
import { formatCount } from "@brdgapp/ui/lib/format";
|
|
8
|
+
import { formatCount, formatPercent } from "@brdgapp/ui/lib/format";
|
|
8
9
|
import { cn } from "@brdgapp/ui/lib/utils";
|
|
9
|
-
function
|
|
10
|
+
function ChangeLine({ change }) {
|
|
11
|
+
const pct = formatPercent(Math.abs(change.value) * 100);
|
|
12
|
+
if (change.value === 0) {
|
|
13
|
+
return _jsxs("span", { className: "mt-0.5 block text-11 leading-normal text-[var(--text-muted)]", children: ["No change vs ", change.since] });
|
|
14
|
+
}
|
|
15
|
+
const up = change.value > 0;
|
|
16
|
+
const good = up !== Boolean(change.downIsGood);
|
|
17
|
+
const Arrow = up ? ArrowUp : ArrowDown;
|
|
18
|
+
return (_jsxs("span", { "data-slot": "stat-box-change", className: "mt-0.5 flex items-center gap-1 text-11 leading-normal text-[var(--text-muted)]", children: [_jsxs("span", { className: cn("inline-flex items-center gap-0.5 font-semibold", good ? "text-[var(--success-text)]" : "text-[var(--danger-text)]"), children: [_jsx(Arrow, { "aria-hidden": "true", className: "size-3", strokeWidth: 2.5 }), _jsx("span", { className: "sr-only", children: up ? "Up" : "Down" }), pct] }), "vs ", change.since] }));
|
|
19
|
+
}
|
|
20
|
+
function StatBox({ label, value, sub, change, icon: Icon, display, info, href, render, className }) {
|
|
10
21
|
const clickable = Boolean(href || render);
|
|
11
|
-
const
|
|
12
|
-
const
|
|
13
|
-
|
|
22
|
+
const valueId = React.useId();
|
|
23
|
+
const labelId = React.useId();
|
|
24
|
+
// The cover link sits over the whole box and is named by its number and label. Everything else is
|
|
25
|
+
// drawn under it; the ⓘ sits above it, so it still works.
|
|
26
|
+
const cover = useRender({
|
|
14
27
|
render: render ?? _jsx("a", { href: href }),
|
|
15
28
|
enabled: clickable,
|
|
16
29
|
props: mergeProps({
|
|
17
|
-
"data-slot": "stat-box",
|
|
18
|
-
|
|
19
|
-
|
|
30
|
+
"data-slot": "stat-box-link",
|
|
31
|
+
"aria-labelledby": `${valueId} ${labelId}`,
|
|
32
|
+
className: "absolute inset-0 rounded-xl outline-none focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-solid focus-visible:outline-[var(--primary)]",
|
|
33
|
+
}, {}),
|
|
20
34
|
});
|
|
21
|
-
|
|
22
|
-
return link;
|
|
23
|
-
return (_jsx("div", { "data-slot": "stat-box", className: classes, children: body }));
|
|
35
|
+
return (_jsxs("div", { "data-slot": "stat-box", className: cn("group relative block rounded-xl bg-[var(--surface-secondary)] px-4 py-3", clickable && "transition-colors has-[[data-slot=stat-box-link]:hover]:bg-[var(--surface-tertiary)]", className), children: [cover, _jsxs("span", { className: "flex items-start justify-between gap-2", children: [_jsx("span", { id: valueId, "data-slot": "stat-box-value", className: cn("text-22 leading-none font-bold tabular-nums text-[var(--text-primary)]", clickable && "transition-colors group-has-[[data-slot=stat-box-link]:hover]:text-[var(--primary)]"), children: display ?? formatCount(value) }), clickable ? (_jsx(ChevronRight, { "aria-hidden": "true", className: "mt-0.5 size-3.5 shrink-0 text-[var(--text-disabled)] transition-colors group-has-[[data-slot=stat-box-link]:hover]:text-[var(--primary)]" })) : null] }), _jsxs("span", { className: "mt-1.5 flex items-center gap-1 text-12 leading-normal font-semibold text-[var(--text-body)]", children: [Icon ? _jsx(Icon, { "aria-hidden": "true", className: "size-3.5 shrink-0 text-[var(--text-muted)]" }) : null, _jsx("span", { id: labelId, children: label }), info ? (_jsx("span", { className: "relative z-10 inline-flex", children: _jsx(InfoHint, { text: info }) })) : null] }), change ? _jsx(ChangeLine, { change: change }) : null, sub ? _jsx("span", { className: "mt-0.5 block text-11 leading-normal text-[var(--text-muted)]", children: sub }) : null] }));
|
|
24
36
|
}
|
|
25
|
-
/**
|
|
26
|
-
|
|
27
|
-
|
|
37
|
+
/**
|
|
38
|
+
* Same size and shape as StatBox, for loading. Pass `sub` and `change` when the real box has those lines,
|
|
39
|
+
* so the row doesn't jump when the numbers arrive.
|
|
40
|
+
*/
|
|
41
|
+
function StatBoxSkeleton({ sub = false, change = false, className }) {
|
|
42
|
+
const bar = "animate-pulse rounded bg-[var(--skeleton)] motion-reduce:animate-none";
|
|
43
|
+
// Each bar sits in a line as tall as the real one: 22px number, 18px label, 16.5px for the small lines.
|
|
44
|
+
return (_jsxs("div", { "data-slot": "stat-box-skeleton", "aria-hidden": "true", className: cn("rounded-xl bg-[var(--surface-secondary)] px-4 py-3", className), children: [_jsx("div", { className: cn(bar, "h-[22px] w-10") }), _jsx("div", { className: "mt-1.5 flex h-[18px] items-center", children: _jsx("div", { className: cn(bar, "h-3 w-16") }) }), change ? (_jsx("div", { className: "mt-0.5 flex h-[16.5px] items-center", children: _jsx("div", { className: cn(bar, "h-2.5 w-20") }) })) : null, sub ? (_jsx("div", { className: "mt-0.5 flex h-[16.5px] items-center", children: _jsx("div", { className: cn(bar, "h-2.5 w-8") }) })) : null] }));
|
|
28
45
|
}
|
|
29
46
|
export { StatBox, StatBoxSkeleton };
|
package/components/switch.js
CHANGED
|
@@ -3,6 +3,10 @@ import { jsx as _jsx } from "react/jsx-runtime";
|
|
|
3
3
|
import { Switch as SwitchPrimitive } from "@base-ui/react/switch";
|
|
4
4
|
import { cn } from "@brdgapp/ui/lib/utils";
|
|
5
5
|
function Switch({ checked, onChange, disabled = false, className, ...props }) {
|
|
6
|
-
return (_jsx(SwitchPrimitive.Root, { "data-slot": "switch", checked: checked, onCheckedChange: (next) => onChange(next), disabled: disabled, className: cn(
|
|
6
|
+
return (_jsx(SwitchPrimitive.Root, { "data-slot": "switch", checked: checked, onCheckedChange: (next) => onChange(next), disabled: disabled, className: cn(
|
|
7
|
+
// Off is mid-grey, not pale: the track's edge has to reach 3:1 against the page (4.8:1 on white). 2026-11-04.
|
|
8
|
+
"relative inline-flex h-5 w-9 shrink-0 items-center rounded-full bg-[var(--text-muted)] transition-colors duration-200 outline-none",
|
|
9
|
+
// Hover steps darker in light and in dark, so the white thumb always stands out from the track.
|
|
10
|
+
"hover:bg-[var(--text-secondary)] dark:hover:bg-[var(--text-disabled)] data-[checked]:hover:bg-[var(--primary-solid-hover)]", "focus-visible:ring-2 focus-visible:ring-[var(--primary)] focus-visible:ring-offset-2 focus-visible:ring-offset-[var(--surface-primary)]", "data-[checked]:bg-[var(--primary-solid)]", "data-[disabled]:pointer-events-none data-[disabled]:opacity-50", className), ...props, children: _jsx(SwitchPrimitive.Thumb, { "data-slot": "switch-thumb", className: "inline-block size-4 translate-x-[2px] rounded-full bg-white shadow-[0_1px_2px_rgba(0,0,0,0.3)] transition-transform duration-200 data-[checked]:translate-x-[18px]" }) }));
|
|
7
11
|
}
|
|
8
12
|
export { Switch };
|
package/components/tabs.js
CHANGED
|
@@ -11,12 +11,20 @@ function Tabs({ className, ...props }) {
|
|
|
11
11
|
}
|
|
12
12
|
// The baseline is an inset shadow, not a border, so the active tab's 2px underline can cover it without
|
|
13
13
|
// sticking out of the row. (A border plus a -1px tab margin got clipped by the row's sideways scrolling.)
|
|
14
|
+
// 4px of padding each side (cancelled by -mx-1) leaves room for the tabs' focus ring at the row's ends.
|
|
14
15
|
// When the page draws its own baseline, pass `shadow-none -mb-px` so the row sits on that line instead.
|
|
15
16
|
function TabList({ className, ...props }) {
|
|
16
|
-
return (_jsx(TabsPrimitive.List, { "data-slot": "tab-list", className: cn("flex items-center gap-6 overflow-x-auto shadow-[inset_0_-1px_0_var(--border-default)] scrollbar-none", className), ...props }));
|
|
17
|
+
return (_jsx(TabsPrimitive.List, { "data-slot": "tab-list", className: cn("-mx-1 flex items-center gap-6 overflow-x-auto px-1 shadow-[inset_0_-1px_0_var(--border-default)] scrollbar-none", className), ...props }));
|
|
17
18
|
}
|
|
18
19
|
function Tab({ className, ...props }) {
|
|
19
|
-
return (_jsx(TabsPrimitive.Tab, { "data-slot": "tab", className: cn("relative shrink-0 rounded-t border-b-2 border-transparent pt-1 pb-3 max-md:min-h-11 text-[
|
|
20
|
+
return (_jsx(TabsPrimitive.Tab, { "data-slot": "tab", className: cn("relative -mx-1 shrink-0 rounded-t border-b-2 border-transparent px-1 pt-1 pb-3 max-md:min-h-11 text-14 leading-[1.625] font-bold tracking-[0.4px] whitespace-nowrap",
|
|
21
|
+
// Hover darkens an unselected tab a clear step; a selected tab stays dark.
|
|
22
|
+
"text-[var(--text-muted)] transition-colors duration-150 outline-none not-data-[active]:hover:text-[var(--text-secondary)]",
|
|
23
|
+
// The ring sits inside the tab: the row scrolls sideways, which clips anything outside it. 4px of room each
|
|
24
|
+
// side (px-1, cancelled by -mx-1) keeps it off the letters without moving the tabs.
|
|
25
|
+
"focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-[var(--primary)]", "data-[active]:border-[var(--text-primary)] data-[active]:text-[var(--text-primary)]",
|
|
26
|
+
// Base UI marks a disabled tab with data-disabled (it stays focusable), not the disabled attribute.
|
|
27
|
+
"data-[disabled]:pointer-events-none data-[disabled]:opacity-50", className), ...props }));
|
|
20
28
|
}
|
|
21
29
|
// A panel takes focus when it has nothing focusable inside, so it shows the same ring as everything else.
|
|
22
30
|
function TabPanel({ className, ...props }) {
|
|
@@ -8,8 +8,10 @@ type TagInputProps = ElementProps<HTMLDivElement> & {
|
|
|
8
8
|
ariaLabel?: string;
|
|
9
9
|
/** Chip colour: `primary` (blue tint) or `muted` (grey). */
|
|
10
10
|
variant?: "primary" | "muted";
|
|
11
|
+
/** Can't be changed: dimmed, no remove buttons. */
|
|
12
|
+
disabled?: boolean;
|
|
11
13
|
className?: string;
|
|
12
14
|
};
|
|
13
|
-
declare function TagInput({ value, onChange, placeholder, ariaLabel, variant, className, ...rest }: TagInputProps): React.JSX.Element;
|
|
15
|
+
declare function TagInput({ value, onChange, placeholder, ariaLabel, variant, disabled, className, ...rest }: TagInputProps): React.JSX.Element;
|
|
14
16
|
export { TagInput };
|
|
15
17
|
export type { TagInputProps };
|
package/components/tag-input.js
CHANGED
|
@@ -5,16 +5,31 @@ import { Button as ButtonPrimitive } from "@base-ui/react/button";
|
|
|
5
5
|
import { Input as InputPrimitive } from "@base-ui/react/input";
|
|
6
6
|
import { X } from "lucide-react";
|
|
7
7
|
import { cn } from "@brdgapp/ui/lib/utils";
|
|
8
|
-
function TagInput({ value, onChange, placeholder, ariaLabel, variant = "primary", className, ...rest }) {
|
|
8
|
+
function TagInput({ value, onChange, placeholder, ariaLabel, variant = "primary", disabled = false, className, ...rest }) {
|
|
9
9
|
const [draft, setDraft] = useState("");
|
|
10
10
|
const inputRef = useRef(null);
|
|
11
|
+
/** Adds each entry that isn't already there (ignoring case), then clears the text box. */
|
|
12
|
+
function addAll(entries) {
|
|
13
|
+
const next = [...value];
|
|
14
|
+
for (const raw of entries) {
|
|
15
|
+
const v = raw.trim();
|
|
16
|
+
if (v && !next.some((t) => t.toLowerCase() === v.toLowerCase()))
|
|
17
|
+
next.push(v);
|
|
18
|
+
}
|
|
19
|
+
if (next.length !== value.length)
|
|
20
|
+
onChange(next);
|
|
21
|
+
setDraft("");
|
|
22
|
+
}
|
|
11
23
|
function add(raw) {
|
|
12
|
-
|
|
13
|
-
|
|
24
|
+
addAll([raw]);
|
|
25
|
+
}
|
|
26
|
+
// A pasted list ("Climate, Health" or one per line) becomes one chip per entry.
|
|
27
|
+
function onPaste(e) {
|
|
28
|
+
const text = e.clipboardData.getData("text");
|
|
29
|
+
if (!/[,\n]/.test(text))
|
|
14
30
|
return;
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
setDraft("");
|
|
31
|
+
e.preventDefault();
|
|
32
|
+
addAll((draft + text).split(/[,\n]/));
|
|
18
33
|
}
|
|
19
34
|
function removeAt(index) {
|
|
20
35
|
onChange(value.filter((_, i) => i !== index));
|
|
@@ -32,9 +47,13 @@ function TagInput({ value, onChange, placeholder, ariaLabel, variant = "primary"
|
|
|
32
47
|
}
|
|
33
48
|
return (
|
|
34
49
|
// Clicking anywhere in the box focuses the text field (a mouse convenience; the field is reachable by Tab).
|
|
35
|
-
_jsxs("div", { ...rest, "data-slot": "tag-input", onClick: () => inputRef.current?.focus(), className: cn("flex min-h-11 md:min-h-10 w-full cursor-text flex-wrap items-center gap-1.5 rounded-lg border border-[var(--border-
|
|
50
|
+
_jsxs("div", { ...rest, "data-slot": "tag-input", onClick: () => inputRef.current?.focus(), "data-disabled": disabled || undefined, className: cn("flex min-h-11 md:min-h-10 w-full cursor-text flex-wrap items-center gap-1.5 rounded-lg border border-[var(--border-field)] bg-[var(--surface-primary)] px-2 py-1.5", "transition-all duration-150 hover:border-[var(--text-muted)] focus-within:border-[var(--primary)] focus-within:ring-2 focus-within:ring-[var(--primary)]/20",
|
|
51
|
+
// Inside an invalid Field, Base UI marks the text box; the whole field turns red, as Input does.
|
|
52
|
+
"has-[[data-invalid]]:border-[var(--error)] has-[[data-invalid]]:hover:border-[var(--error)] has-[[data-invalid]]:focus-within:ring-[var(--error)]/20",
|
|
53
|
+
// Disabled by the prop, or by a disabled Field around it.
|
|
54
|
+
"data-[disabled]:pointer-events-none data-[disabled]:opacity-50 has-[input:disabled]:pointer-events-none has-[input:disabled]:opacity-50", className), children: [value.map((tag, i) => (_jsxs("span", { "data-slot": "tag-input-chip", className: cn("inline-flex items-center gap-0.5 rounded-full py-0.5 pr-0.5 pl-2.5 text-11 leading-normal font-semibold", disabled && "pr-2.5", variant === "primary" ? "bg-[var(--primary)]/[0.08] text-[var(--primary)]" : "bg-[var(--surface-secondary)] text-[var(--text-body)]"), children: [tag, disabled ? null : (_jsx(ButtonPrimitive, { "aria-label": `Remove ${tag}`, onClick: (e) => {
|
|
36
55
|
e.stopPropagation();
|
|
37
56
|
removeAt(i);
|
|
38
|
-
}, className: "inline-flex size-5 items-center justify-center rounded-full opacity-60 outline-none transition-opacity hover:opacity-100 focus-visible:opacity-100 focus-visible:ring-2 focus-visible:ring-[var(--primary)]", children: _jsx(X, { "aria-hidden": "true", className: "size-3" }) })] }, `${tag}-${i}`))), _jsx(InputPrimitive, { ref: inputRef, "data-slot": "tag-input-field", type: "text", value: draft, "aria-label": ariaLabel, onChange: (e) => setDraft(e.target.value), onKeyDown: onKeyDown, onBlur: () => add(draft), placeholder: value.length === 0 ? placeholder : "", className: "min-w-[80px] flex-1 border-0 bg-transparent px-1.5 py-0.5 text-16 md:text-14 text-[var(--text-primary)] outline-none placeholder:text-[var(--text-muted)]" })] }));
|
|
57
|
+
}, className: "inline-flex size-5 items-center justify-center rounded-full opacity-60 outline-none transition-opacity hover:opacity-100 focus-visible:opacity-100 focus-visible:ring-2 focus-visible:ring-[var(--primary)]", children: _jsx(X, { "aria-hidden": "true", className: "size-3" }) }))] }, `${tag}-${i}`))), _jsx(InputPrimitive, { ref: inputRef, "data-slot": "tag-input-field", type: "text", value: draft, "aria-label": ariaLabel, onChange: (e) => setDraft(e.target.value), onKeyDown: onKeyDown, onPaste: onPaste, disabled: disabled, onBlur: () => add(draft), placeholder: value.length === 0 ? placeholder : "", className: "min-w-[80px] flex-1 border-0 bg-transparent px-1.5 py-0.5 text-16 md:text-14 text-[var(--text-primary)] outline-none placeholder:text-[var(--text-muted)]" })] }));
|
|
39
58
|
}
|
|
40
59
|
export { TagInput };
|
package/components/tag.js
CHANGED
|
@@ -16,9 +16,11 @@ const tagVariants = cva("inline-flex items-center gap-1 rounded-[4px] border fon
|
|
|
16
16
|
red: "border-[var(--error-border)] bg-[var(--error-bg)] text-[var(--error-text)]",
|
|
17
17
|
purple: "border-[var(--purple-border)] bg-[var(--purple-bg)] text-[var(--purple)]",
|
|
18
18
|
},
|
|
19
|
+
// Named sizes with the line height tags have always had (1.625), so they stay 25.5px (sm) and 33px (md)
|
|
20
|
+
// tall, as in Bridge OS (decision 2026-11-04).
|
|
19
21
|
size: {
|
|
20
|
-
sm: "px-2 py-0.5 text-[
|
|
21
|
-
md: "px-2.5 py-1 text-[
|
|
22
|
+
sm: "px-2 py-0.5 text-12 leading-[1.625] [&_svg]:size-3.5",
|
|
23
|
+
md: "px-2.5 py-1 text-14 leading-[1.625] [&_svg]:size-4",
|
|
22
24
|
},
|
|
23
25
|
},
|
|
24
26
|
defaultVariants: { color: "grey", size: "sm" },
|
package/components/textarea.js
CHANGED
|
@@ -17,7 +17,7 @@ import { cn } from "@brdgapp/ui/lib/utils";
|
|
|
17
17
|
const LINE = 20; // a 20px line (leading-5), at 14px and at 16px on phones
|
|
18
18
|
const PAD_Y = 10; // py-2.5
|
|
19
19
|
const BORDER = 1;
|
|
20
|
-
const textareaClasses = cn("block w-full min-w-0 resize-none rounded-lg border border-[var(--border-
|
|
20
|
+
const textareaClasses = cn("block w-full min-w-0 resize-none rounded-lg border border-[var(--border-field)] bg-[var(--surface-primary)] px-3.5 py-2.5", "text-16 leading-5 md:text-14 md:leading-5 text-[var(--text-primary)] placeholder:text-[var(--text-muted)]", "transition-colors duration-150 ease-out outline-none", "hover:border-[var(--text-muted)]", "focus-visible:border-[var(--primary)] focus-visible:ring-2 focus-visible:ring-[var(--primary)]/20", "aria-invalid:border-[var(--error)] aria-invalid:hover:border-[var(--error)] aria-invalid:focus-visible:border-[var(--error)] aria-invalid:focus-visible:ring-[var(--error)]/20", "data-[invalid]:border-[var(--error)] data-[invalid]:hover:border-[var(--error)] data-[invalid]:focus-visible:border-[var(--error)] data-[invalid]:focus-visible:ring-[var(--error)]/20", "disabled:cursor-not-allowed disabled:opacity-50");
|
|
21
21
|
/** How close to the limit the count turns red: the last 10%, at most 50 characters. */
|
|
22
22
|
function nearLimit(length, max) {
|
|
23
23
|
return max - length <= Math.min(50, Math.ceil(max * 0.1));
|
|
@@ -73,6 +73,6 @@ function Textarea({ rows = 3, maxRows = 10, maxLength, className, value, default
|
|
|
73
73
|
setTyped(e.target.value.length);
|
|
74
74
|
fit();
|
|
75
75
|
} }));
|
|
76
|
-
} }), maxLength !== undefined ? (_jsxs("p", { id: countId, "data-slot": "textarea-count", className: cn("self-end text-[
|
|
76
|
+
} }), maxLength !== undefined ? (_jsxs("p", { id: countId, "data-slot": "textarea-count", className: cn("self-end text-12 leading-[1.625] tabular-nums", warn ? "text-[var(--danger-text)]" : "text-[var(--text-muted)]"), children: [_jsxs("span", { "aria-hidden": "true", children: [length, "/", maxLength] }), _jsx("span", { className: "sr-only", children: `${remaining} of ${maxLength} characters left` })] })) : null, maxLength !== undefined ? (_jsx("span", { className: "sr-only", "aria-live": "polite", children: warn ? (remaining === 0 ? "Character limit reached" : `${remaining} characters left`) : "" })) : null] }));
|
|
77
77
|
}
|
|
78
78
|
export { Textarea };
|
package/components/toast.d.ts
CHANGED
|
@@ -1,13 +1,20 @@
|
|
|
1
1
|
type ToastVariant = "success" | "error";
|
|
2
|
+
type ToastOptions = {
|
|
3
|
+
/** A second, smaller line with detail the message can't hold: "12 couldn't be matched to a known firm". */
|
|
4
|
+
description?: string;
|
|
5
|
+
};
|
|
2
6
|
declare const toast: {
|
|
3
7
|
/** A past-tense confirmation: "Intro sent". */
|
|
4
|
-
success: (message: string) => string;
|
|
5
|
-
/** Something that failed out of sight: "Couldn't copy the link". Errors people must fix stay on the page. */
|
|
6
|
-
error: (message: string) => string;
|
|
8
|
+
success: (message: string, options?: ToastOptions) => string;
|
|
9
|
+
/** Something that failed out of sight: "Couldn't copy the link". Stays 6 seconds. Errors people must fix stay on the page. */
|
|
10
|
+
error: (message: string, options?: ToastOptions) => string;
|
|
7
11
|
/** Hide one toast, or all of them. */
|
|
8
12
|
close: (id?: string) => void;
|
|
9
13
|
};
|
|
10
|
-
/**
|
|
14
|
+
/**
|
|
15
|
+
* Mount once in the app's root layout. Toasts last 3 seconds (errors 6); at most 3 show at once. Being in
|
|
16
|
+
* every app's root, it also checks in development that the app loaded Mulish (see lib/font-check).
|
|
17
|
+
*/
|
|
11
18
|
declare function Toaster({ timeout }: {
|
|
12
19
|
timeout?: number;
|
|
13
20
|
}): import("react").JSX.Element;
|
|
@@ -22,4 +29,4 @@ type ToastProps = {
|
|
|
22
29
|
*/
|
|
23
30
|
declare function Toast({ open, message, variant }: ToastProps): import("react").JSX.Element;
|
|
24
31
|
export { Toast, Toaster, toast };
|
|
25
|
-
export type { ToastProps, ToastVariant };
|
|
32
|
+
export type { ToastOptions, ToastProps, ToastVariant };
|
package/components/toast.js
CHANGED
|
@@ -1,16 +1,19 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
3
|
import { useEffect, useState } from "react";
|
|
4
|
+
import { checkMulishLoaded } from "@brdgapp/ui/lib/font-check";
|
|
4
5
|
import { Toast as ToastPrimitive } from "@base-ui/react/toast";
|
|
5
6
|
import { AlertCircle, Check } from "lucide-react";
|
|
6
7
|
import { cn } from "@brdgapp/ui/lib/utils";
|
|
7
8
|
/** The app-wide toast queue. Needs one `<Toaster />` mounted. */
|
|
8
9
|
const manager = ToastPrimitive.createToastManager();
|
|
10
|
+
/** Errors stay twice as long as the default 3 seconds: they are longer and matter more. */
|
|
11
|
+
const ERROR_TIMEOUT = 6000;
|
|
9
12
|
const toast = {
|
|
10
13
|
/** A past-tense confirmation: "Intro sent". */
|
|
11
|
-
success: (message) => manager.add({ title: message, type: "success" }),
|
|
12
|
-
/** Something that failed out of sight: "Couldn't copy the link". Errors people must fix stay on the page. */
|
|
13
|
-
error: (message) => manager.add({ title: message, type: "error", priority: "high" }),
|
|
14
|
+
success: (message, options) => manager.add({ title: message, description: options?.description, type: "success" }),
|
|
15
|
+
/** Something that failed out of sight: "Couldn't copy the link". Stays 6 seconds. Errors people must fix stay on the page. */
|
|
16
|
+
error: (message, options) => manager.add({ title: message, description: options?.description, type: "error", priority: "high", timeout: ERROR_TIMEOUT }),
|
|
14
17
|
/** Hide one toast, or all of them. */
|
|
15
18
|
close: (id) => manager.close(id),
|
|
16
19
|
};
|
|
@@ -19,11 +22,18 @@ function ToastList() {
|
|
|
19
22
|
const { toasts } = ToastPrimitive.useToastManager();
|
|
20
23
|
return toasts.map((t) => {
|
|
21
24
|
const Icon = t.type === "error" ? AlertCircle : Check;
|
|
22
|
-
|
|
25
|
+
const twoLines = Boolean(t.description);
|
|
26
|
+
return (_jsxs(ToastPrimitive.Root, { toast: t, swipeDirection: "up", "data-slot": "toast", className: cn("pointer-events-auto inline-flex gap-2 border border-[var(--border-default)] bg-[var(--surface-elevated)] pr-4 pl-3 shadow-[var(--shadow-menu)]",
|
|
27
|
+
// One line is a pill; with a second line it becomes a rounded box, the icon level with the first line.
|
|
28
|
+
twoLines ? "max-w-sm items-start rounded-xl py-2.5" : "items-center rounded-full py-2", "transition-[opacity,translate] duration-200 ease-out data-[ending-style]:duration-150 data-[starting-style]:-translate-y-2 data-[starting-style]:opacity-0 data-[ending-style]:opacity-0"), children: [_jsx("span", { className: "flex h-[1.21875rem] shrink-0 items-center", children: _jsx(Icon, { "aria-hidden": "true", className: cn("size-4", t.type === "error" ? "text-[var(--danger-text)]" : "text-[var(--success)]") }) }), _jsxs("span", { className: "min-w-0", children: [_jsx(ToastPrimitive.Title, { render: _jsx("p", {}), className: "text-13 leading-normal font-semibold text-[var(--text-primary)]" }), twoLines ? _jsx(ToastPrimitive.Description, { render: _jsx("p", {}), className: "text-12 leading-normal text-[var(--text-muted)]" }) : null] })] }, t.id));
|
|
23
29
|
});
|
|
24
30
|
}
|
|
25
|
-
/**
|
|
31
|
+
/**
|
|
32
|
+
* Mount once in the app's root layout. Toasts last 3 seconds (errors 6); at most 3 show at once. Being in
|
|
33
|
+
* every app's root, it also checks in development that the app loaded Mulish (see lib/font-check).
|
|
34
|
+
*/
|
|
26
35
|
function Toaster({ timeout = 3000 }) {
|
|
36
|
+
useEffect(checkMulishLoaded, []);
|
|
27
37
|
return (_jsx(ToastPrimitive.Provider, { toastManager: manager, timeout: timeout, limit: 3, children: _jsx(ToastPrimitive.Portal, { children: _jsx(ToastPrimitive.Viewport, { "data-slot": "toaster", className: VIEWPORT, children: _jsx(ToastList, {}) }) }) }));
|
|
28
38
|
}
|
|
29
39
|
/**
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
// Every Bridge app sets its text in Mulish (rule "One typeface", 2026-11-06). The package's base styles ask
|
|
2
|
+
// for Mulish, but the app has to load the font file; without it, text quietly falls back to the device's
|
|
3
|
+
// font. So in development, once the page's fonts have settled, this checks that a Mulish face actually
|
|
4
|
+
// loaded and says how to fix it if not. Agents testing an app in a browser read the console too.
|
|
5
|
+
// It never runs in production, and never twice. Any way of loading works: next/font (its faces are named
|
|
6
|
+
// "__Mulish_…"), Fontsource, a Google Fonts link or a self-hosted file.
|
|
7
|
+
let checked = false;
|
|
8
|
+
function isDevelopment() {
|
|
9
|
+
// Bundlers (Next, Vite) replace `process.env.NODE_ENV`; where nothing does, `process` may not exist.
|
|
10
|
+
try {
|
|
11
|
+
return process.env.NODE_ENV !== "production";
|
|
12
|
+
}
|
|
13
|
+
catch {
|
|
14
|
+
return false;
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
/** Warns in the console, once and only in development, when no Mulish font has loaded. */
|
|
18
|
+
function checkMulishLoaded() {
|
|
19
|
+
if (checked || typeof document === "undefined" || !document.fonts || !isDevelopment())
|
|
20
|
+
return;
|
|
21
|
+
checked = true;
|
|
22
|
+
void document.fonts.ready.then(() => {
|
|
23
|
+
const loaded = Array.from(document.fonts).some((face) => /mulish/i.test(face.family) && face.status === "loaded");
|
|
24
|
+
if (loaded)
|
|
25
|
+
return;
|
|
26
|
+
console.warn("@brdgapp/ui: Mulish isn't loaded, so text is falling back to the device's font. Every Bridge app uses Mulish. " +
|
|
27
|
+
'Load it once in the root layout: next/font (Mulish with variable "--font-mulish") or @fontsource/mulish (400, 500, 600, 700). ' +
|
|
28
|
+
"Setup: https://handbook.brdg.app/migrating#install");
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
export { checkMulishLoaded };
|
package/package.json
CHANGED
package/styles/globals.css
CHANGED
|
@@ -33,11 +33,13 @@
|
|
|
33
33
|
--surface-primary: #FFFFFF;
|
|
34
34
|
--surface-secondary: #F9F9FA;
|
|
35
35
|
--surface-tertiary: #F2F3F5;
|
|
36
|
+
--skeleton: #F2F3F5; /* loading placeholders (Bridge OS's grey) */
|
|
36
37
|
--surface-elevated: #FFFFFF;
|
|
37
38
|
|
|
38
39
|
/* Borders */
|
|
39
40
|
--border-default: #ECEDF0;
|
|
40
41
|
--border-hover: #D9DBE1;
|
|
42
|
+
--border-field: #A3A7B5; /* Text fields' edge: 2.4:1 on white. 3:1 (#878C9D, 2026-11-04) looked too heavy on long forms; one step lighter picked by Aman 2026-11-05. The label, and the darker hover and focus edges, mark the field. */
|
|
41
43
|
--border-divider: #F2F3F5;
|
|
42
44
|
|
|
43
45
|
/* Text */
|
|
@@ -91,6 +93,7 @@
|
|
|
91
93
|
/* Accent: Honey — the alum/outline sticker hue (Arch "Solid label / Warning"). Distinct from
|
|
92
94
|
--warning (amber #F59E0B): honey is the darker Arch value used for the ALUM badge outline. */
|
|
93
95
|
--honey: #E19500;
|
|
96
|
+
--honey-text: #9A6B00; /* Honey for text on light surfaces: 4.7:1 on white (honey itself is 2.5). Decision 2026-11-04. */
|
|
94
97
|
|
|
95
98
|
/* Avatar badges — the same in both themes: they mark the person, not the page. The white mark
|
|
96
99
|
on each passes 3:1 (super connector 3.3–6.0, warning 3.6). */
|
|
@@ -147,11 +150,13 @@
|
|
|
147
150
|
--surface-primary: #0B0F1A;
|
|
148
151
|
--surface-secondary: #111627;
|
|
149
152
|
--surface-tertiary: #1A2035;
|
|
153
|
+
--skeleton: #283049; /* lighter than surfaces, so lines show on cards */
|
|
150
154
|
--surface-elevated: #151B2E;
|
|
151
155
|
|
|
152
156
|
/* Borders */
|
|
153
157
|
--border-default: #252D44;
|
|
154
158
|
--border-hover: #3A4460;
|
|
159
|
+
--border-field: #565D78;
|
|
155
160
|
--border-divider: #1E2640;
|
|
156
161
|
|
|
157
162
|
/* Text */
|
|
@@ -203,6 +208,7 @@
|
|
|
203
208
|
|
|
204
209
|
/* Accent: Honey (alum/outline sticker) — lightened for dark surfaces */
|
|
205
210
|
--honey: #F5C451;
|
|
211
|
+
--honey-text: #F5C451;
|
|
206
212
|
|
|
207
213
|
/* Avatar badges — the same in both themes: they mark the person, not the page. The white mark
|
|
208
214
|
on each passes 3:1 (super connector 3.3–6.0, warning 3.6). */
|
|
@@ -314,9 +320,13 @@ body {
|
|
|
314
320
|
a mouse click. A component's own `outline-none` + ring wins over it. Solid, not 40%, so it clears WCAG's
|
|
315
321
|
3:1 (7:1 light, 5:1 dark); decided 2026-11-03. Bridge OS's global `:focus-visible { outline: none }` is
|
|
316
322
|
not copied: it hid focus on anything without its own ring. */
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
323
|
+
/* In the base layer, so a component's own `outline-none` (a utility) wins; outside a layer this rule beat every
|
|
324
|
+
utility and drew a second outline on top of components' rings (fixed 2026-11-04). */
|
|
325
|
+
@layer base {
|
|
326
|
+
:where(a[href], button, input, select, textarea, summary, [tabindex]:not([tabindex="-1"]), [role="button"]):focus-visible {
|
|
327
|
+
outline: 2px solid var(--primary);
|
|
328
|
+
outline-offset: 2px;
|
|
329
|
+
}
|
|
320
330
|
}
|
|
321
331
|
|
|
322
332
|
/* SkipLink: off screen until it has keyboard focus, then top-left above everything. */
|
|
@@ -357,6 +367,8 @@ body {
|
|
|
357
367
|
*::before,
|
|
358
368
|
*::after {
|
|
359
369
|
animation-duration: 0.01ms !important;
|
|
370
|
+
/* Play once and stop: a looping animation cut to 0.01ms flickers (a skeleton's pulse did). */
|
|
371
|
+
animation-iteration-count: 1 !important;
|
|
360
372
|
transition-duration: 0.01ms !important;
|
|
361
373
|
}
|
|
362
374
|
}
|
|
@@ -499,6 +511,8 @@ body {
|
|
|
499
511
|
/* Here, not in Tailwind classes, because the glass rule outranks Tailwind's background, border and
|
|
500
512
|
shadow classes. A clickable card has an invisible link or button (the cover) across it; the content
|
|
501
513
|
sits on top and lets clicks fall through to the cover, except its own controls. */
|
|
514
|
+
/* Avatars on a card ring themselves in the card's surface, not the page's. */
|
|
515
|
+
[data-slot="card"] { --avatar-ring: var(--surface-elevated); }
|
|
502
516
|
[data-slot="card"] > [data-card-cover] {
|
|
503
517
|
position: absolute;
|
|
504
518
|
inset: 0;
|
|
@@ -543,12 +557,21 @@ body {
|
|
|
543
557
|
linear-gradient(color-mix(in srgb, var(--primary) 5%, transparent), color-mix(in srgb, var(--primary) 5%, transparent)),
|
|
544
558
|
var(--glass-bg);
|
|
545
559
|
}
|
|
560
|
+
/* The open card deepens a little on hover, so the pointer still shows. */
|
|
561
|
+
.liquid-glass[data-slot="card"][data-selected][data-clickable]:not([data-disabled]):hover {
|
|
562
|
+
background:
|
|
563
|
+
linear-gradient(color-mix(in srgb, var(--primary) 9%, transparent), color-mix(in srgb, var(--primary) 9%, transparent)),
|
|
564
|
+
var(--glass-bg);
|
|
565
|
+
}
|
|
546
566
|
[data-slot="card"][data-bare][data-clickable]:not([data-disabled]):not([data-selected]):hover {
|
|
547
567
|
background: var(--surface-secondary);
|
|
548
568
|
}
|
|
549
569
|
[data-slot="card"][data-bare][data-selected] {
|
|
550
570
|
background: color-mix(in srgb, var(--primary) 6%, transparent);
|
|
551
571
|
}
|
|
572
|
+
[data-slot="card"][data-bare][data-selected][data-clickable]:not([data-disabled]):hover {
|
|
573
|
+
background: color-mix(in srgb, var(--primary) 10%, transparent);
|
|
574
|
+
}
|
|
552
575
|
|
|
553
576
|
/* Ensure content sits above the highlight */
|
|
554
577
|
.liquid-glass > * {
|