@brdgapp/ui 0.1.2 → 1.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/CHANGELOG.md +141 -0
- package/README.md +37 -201
- package/components/action-menu.d.ts +72 -0
- package/components/action-menu.js +57 -0
- package/components/avatar.d.ts +50 -0
- package/components/avatar.js +93 -0
- package/components/badge.d.ts +12 -0
- package/components/badge.js +24 -0
- package/components/bottom-sheet.d.ts +34 -0
- package/components/bottom-sheet.js +96 -0
- package/components/brand-mark.d.ts +20 -0
- package/components/brand-mark.js +44 -0
- package/components/button-group.d.ts +25 -0
- package/components/button-group.js +53 -0
- package/components/button.d.ts +33 -0
- package/components/button.js +84 -0
- package/components/card.d.ts +78 -0
- package/components/card.js +75 -0
- package/components/checkbox.d.ts +22 -0
- package/components/checkbox.js +35 -0
- package/components/collapsible.d.ts +29 -0
- package/components/collapsible.js +39 -0
- package/components/column-filter-menu.d.ts +16 -0
- package/components/column-filter-menu.js +31 -0
- package/components/column-sort-button.d.ts +24 -0
- package/components/column-sort-button.js +24 -0
- package/components/confirm-dialog.d.ts +28 -0
- package/components/confirm-dialog.js +52 -0
- package/components/copy-field.d.ts +17 -0
- package/components/copy-field.js +38 -0
- package/components/data-state.d.ts +44 -0
- package/components/data-state.js +25 -0
- package/components/data-table.d.ts +114 -0
- package/components/data-table.js +133 -0
- package/components/dialog.d.ts +43 -0
- package/components/dialog.js +34 -0
- package/components/drawer.d.ts +31 -0
- package/components/drawer.js +34 -0
- package/components/expandable-bio.d.ts +8 -0
- package/components/expandable-bio.js +27 -0
- package/components/field.d.ts +29 -0
- package/components/field.js +27 -0
- package/components/filter-chip.d.ts +11 -0
- package/components/filter-chip.js +11 -0
- package/components/filter-pill.d.ts +34 -0
- package/components/filter-pill.js +35 -0
- package/components/hover-card.d.ts +21 -0
- package/components/hover-card.js +22 -0
- package/components/icon-button.d.ts +16 -0
- package/components/icon-button.js +37 -0
- package/components/illustration.d.ts +33 -0
- package/components/illustration.js +70 -0
- package/components/info-hint.d.ts +36 -0
- package/components/info-hint.js +57 -0
- package/components/input.d.ts +9 -0
- package/components/input.js +15 -0
- package/components/network-graph.d.ts +48 -0
- package/components/network-graph.js +37 -0
- package/components/page-banner.d.ts +20 -0
- package/components/page-banner.js +35 -0
- package/components/scene.d.ts +14 -0
- package/components/scene.js +7 -0
- package/components/search-input.d.ts +8 -0
- package/components/search-input.js +35 -0
- package/components/segmented-control.d.ts +18 -0
- package/components/segmented-control.js +18 -0
- package/components/skeleton.d.ts +12 -0
- package/components/skeleton.js +23 -0
- package/components/skip-link.d.ts +8 -0
- package/components/skip-link.js +9 -0
- package/components/stat-box.d.ts +41 -0
- package/components/stat-box.js +46 -0
- package/components/switch.d.ts +13 -0
- package/components/switch.js +12 -0
- package/components/tabs.d.ts +6 -0
- package/components/tabs.js +33 -0
- package/components/tag-input.d.ts +17 -0
- package/components/tag-input.js +59 -0
- package/components/tag.d.ts +27 -0
- package/components/tag.js +37 -0
- package/components/textarea.d.ts +12 -0
- package/components/textarea.js +78 -0
- package/components/theme-switch.d.ts +6 -0
- package/components/theme-switch.js +16 -0
- package/components/toast.d.ts +29 -0
- package/components/toast.js +49 -0
- package/hooks/use-is-mobile.d.ts +2 -0
- package/hooks/use-is-mobile.js +16 -0
- package/hooks/use-mock-query.d.ts +23 -0
- package/hooks/use-mock-query.js +36 -0
- package/hooks/use-theme.d.ts +11 -0
- package/hooks/use-theme.js +34 -0
- package/lib/demo-controls.d.ts +24 -0
- package/lib/demo-controls.js +24 -0
- package/lib/format.d.ts +17 -0
- package/lib/format.js +55 -0
- package/lib/layout.d.ts +19 -0
- package/lib/layout.js +24 -0
- package/lib/motion.d.ts +16 -0
- package/lib/motion.js +18 -0
- package/lib/theme.d.ts +21 -0
- package/lib/theme.js +63 -0
- package/lib/utils.d.ts +22 -0
- package/lib/utils.js +27 -0
- package/package.json +32 -16
- package/styles/globals.css +618 -0
- package/src/index.ts +0 -18
- package/src/network-people-helper/README.md +0 -130
- package/src/network-people-helper/api.ts +0 -174
- package/src/network-people-helper/contact-avatar.tsx +0 -63
- package/src/network-people-helper/domain.ts +0 -14
- package/src/network-people-helper/icons.tsx +0 -130
- package/src/network-people-helper/index.ts +0 -6
- package/src/network-people-helper/network-people-helper.tsx +0 -397
- package/src/network-people-helper/network-people-nudge.tsx +0 -98
- package/src/network-people-helper/open-helper.ts +0 -22
- package/src/network-people-helper/person-menu.tsx +0 -211
- package/src/network-people-helper/styles.css +0 -848
- package/src/network-people-helper/types.ts +0 -23
- package/src/network-people-helper/use-network-people-list.ts +0 -122
- package/src/network-people-helper/use-network-preview.ts +0 -43
- package/src/provider.tsx +0 -59
- package/src/styles.css +0 -1
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { Avatar as AvatarPrimitive } from "@base-ui/react/avatar";
|
|
4
|
+
import { cva } from "class-variance-authority";
|
|
5
|
+
import { cn } from "@brdgapp/ui/lib/utils";
|
|
6
|
+
// A person's photo in a circle, or their initials when there's no photo, with an optional corner badge.
|
|
7
|
+
// Started from shadcn's Base UI avatar, then fitted to the Bridge apps, which draw this by hand in over
|
|
8
|
+
// 100 places across 12 repos. Base UI shows the initials while the photo loads and keeps them if the
|
|
9
|
+
// photo fails, so a broken URL never shows a broken image.
|
|
10
|
+
//
|
|
11
|
+
// Decisions (2026-11-03, after checking all 12 app repos):
|
|
12
|
+
// - Initials on light blue (`--info-bg`), letters in `--info` (not `--primary`: 3.3:1 in dark).
|
|
13
|
+
// - Sizes 16, 24, 32, 40, 48, 64: stacks and chips 16–24, lists 32, rows 40, cards 48, profile headers 64.
|
|
14
|
+
// - Badges, as in Bridge OS contact-card.tsx and app-cc avatar-status-badge.tsx: a blue tick for a Bridge
|
|
15
|
+
// member, a purple award for a Super Connector (replaces the tick), an amber "!" when the account is
|
|
16
|
+
// deactivated or its emails fail. The warning amber is darker than app-cc's #E19500, which gave the
|
|
17
|
+
// white mark 2.5:1; #B87A00 gives 3.6:1.
|
|
18
|
+
// - AvatarGroup: 3 faces then "+N", overlapping a little less than the apps do, a ring between faces (app-directories, together,
|
|
19
|
+
// app-portfolio, raise, bridge-jobs).
|
|
20
|
+
const avatarVariants = cva("relative inline-flex shrink-0 rounded-full bg-[var(--info-bg)] align-middle select-none", {
|
|
21
|
+
variants: {
|
|
22
|
+
size: {
|
|
23
|
+
xs: "size-4 text-[8px]",
|
|
24
|
+
sm: "size-6 text-[10px]",
|
|
25
|
+
md: "size-8 text-12",
|
|
26
|
+
lg: "size-10 text-14",
|
|
27
|
+
xl: "size-12 text-16",
|
|
28
|
+
"2xl": "size-16 text-[20px]",
|
|
29
|
+
},
|
|
30
|
+
},
|
|
31
|
+
defaultVariants: { size: "md" },
|
|
32
|
+
});
|
|
33
|
+
const BADGE_LABEL = {
|
|
34
|
+
member: "Bridge member",
|
|
35
|
+
"super-connector": "Super Connector",
|
|
36
|
+
warning: "Account needs attention",
|
|
37
|
+
};
|
|
38
|
+
// Badge diameter for each avatar size. None at 16px: too small to read.
|
|
39
|
+
const BADGE_SIZE = {
|
|
40
|
+
xs: null,
|
|
41
|
+
sm: "size-2.5 ring-1",
|
|
42
|
+
md: "size-3 ring-[1.5px]",
|
|
43
|
+
lg: "size-3.5 ring-2",
|
|
44
|
+
xl: "size-[18px] ring-2",
|
|
45
|
+
"2xl": "size-5 ring-2",
|
|
46
|
+
};
|
|
47
|
+
/** "Priya Natarajan" → "PN", "Priya" → "P", "" → "?". First and last word, so middle names don't crowd it. */
|
|
48
|
+
// Rings (between stacked faces, round a badge) take the color of what the avatar sits on: the page by
|
|
49
|
+
// default, a card's surface inside a Card (globals.css sets --avatar-ring there), so no dark or white halo shows.
|
|
50
|
+
function initialsOf(name) {
|
|
51
|
+
const words = (name ?? "").trim().split(/\s+/).filter(Boolean);
|
|
52
|
+
const first = words[0]?.[0] ?? "";
|
|
53
|
+
const last = words.length > 1 ? (words[words.length - 1]?.[0] ?? "") : "";
|
|
54
|
+
return (first + last).toUpperCase() || "?";
|
|
55
|
+
}
|
|
56
|
+
function BadgeMark({ badge }) {
|
|
57
|
+
if (badge === "member") {
|
|
58
|
+
return (_jsx("svg", { viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "4", strokeLinecap: "round", strokeLinejoin: "round", className: "size-[60%]", children: _jsx("polyline", { points: "20 6 9 17 4 12" }) }));
|
|
59
|
+
}
|
|
60
|
+
if (badge === "super-connector") {
|
|
61
|
+
// The award glyph from the Arch Design System, via Bridge OS super-connector-badge.tsx.
|
|
62
|
+
return (_jsx("svg", { viewBox: "0 0 8.24323 14.1285", fill: "currentColor", className: "h-[60%] w-auto", children: _jsx("path", { fillRule: "evenodd", clipRule: "evenodd", d: "M0.136812 0.00229937H3.11564L5.79901 4.88271C5.85649 4.98618 5.94042 5.06781 6.03584 5.11954H2.03034L0.136812 0V0.00229937ZM4.12162 5.88523C6.39799 5.88523 8.24323 7.73047 8.24323 10.0068C8.24323 12.2832 6.39799 14.1285 4.12162 14.1285C1.84524 14.1273 0 12.2821 0 10.0057C0 7.72932 1.84524 5.88523 4.12162 5.88523ZM4.12162 7.627L4.81028 9.30784L6.62333 9.44465L5.23566 10.6219L5.66679 12.3855L4.12162 11.4279L2.57644 12.3855L3.00757 10.6219L1.61875 9.4435L3.43181 9.30669L4.12162 7.627ZM4.48722 0.00229937H7.97306L6.57044 3.79396L4.48722 0.00229937Z" }) }));
|
|
63
|
+
}
|
|
64
|
+
return (_jsxs("svg", { viewBox: "0 0 16 16", fill: "currentColor", className: "size-[70%]", children: [_jsx("path", { d: "M8 3.2c-.59 0-1.05.5-1.02 1.08l.25 4a.77.77 0 0 0 1.53 0l.25-4A1.02 1.02 0 0 0 8 3.2Z" }), _jsx("circle", { cx: "8", cy: "11.6", r: "0.95" })] }));
|
|
65
|
+
}
|
|
66
|
+
const BADGE_FILL = {
|
|
67
|
+
member: "bg-[var(--primary-solid)]",
|
|
68
|
+
"super-connector": "bg-linear-to-l from-[var(--super-connector-from)] to-[var(--super-connector-to)]",
|
|
69
|
+
warning: "bg-[var(--badge-warning)]",
|
|
70
|
+
};
|
|
71
|
+
function Avatar({ name, src, size = "md", badge, standalone = false, className, style }) {
|
|
72
|
+
const badgeSize = badge ? BADGE_SIZE[size] : null;
|
|
73
|
+
const label = badge ? BADGE_LABEL[badge] : null;
|
|
74
|
+
return (_jsxs(AvatarPrimitive.Root, { "data-slot": "avatar", "data-size": size, className: cn(avatarVariants({ size }), className), style: style, ...(standalone ? { role: "img", "aria-label": [name || "Unknown person", label].filter(Boolean).join(", ") } : {}), children: [_jsxs("span", { className: "block size-full overflow-hidden rounded-full", "aria-hidden": "true", children: [src ? _jsx(AvatarPrimitive.Image, { "data-slot": "avatar-image", src: src, alt: "", className: "size-full object-cover" }) : null, _jsx(AvatarPrimitive.Fallback, { "data-slot": "avatar-fallback", className: "flex size-full items-center justify-center leading-none font-bold text-[var(--info)]", children: initialsOf(name) })] }), badge && badgeSize ? (_jsx("span", { "data-slot": "avatar-badge", "data-badge": badge, "aria-hidden": "true", className: cn("absolute -right-0.5 -bottom-0.5 flex items-center justify-center rounded-full text-white ring-[var(--avatar-ring,var(--surface-primary))]", BADGE_FILL[badge], badgeSize), children: _jsx(BadgeMark, { badge: badge }) })) : null, badge && !standalone ? _jsx("span", { className: "sr-only", children: label }) : null] }));
|
|
75
|
+
}
|
|
76
|
+
// How far each face tucks under the one before it: a quarter of the face less the ring, so two-letter
|
|
77
|
+
// initials stay readable (the apps' 6px at 24px hid the first letter).
|
|
78
|
+
const OVERLAP = {
|
|
79
|
+
xs: "-ml-0.5",
|
|
80
|
+
sm: "-ml-1",
|
|
81
|
+
md: "-ml-1.5",
|
|
82
|
+
lg: "-ml-2",
|
|
83
|
+
xl: "-ml-2.5",
|
|
84
|
+
"2xl": "-ml-3",
|
|
85
|
+
};
|
|
86
|
+
function AvatarGroup({ people, max = 3, size = "sm", decorative = false, className }) {
|
|
87
|
+
const shown = people.slice(0, max);
|
|
88
|
+
const extra = people.length - shown.length;
|
|
89
|
+
const names = shown.map((p) => p.name || "Unknown person");
|
|
90
|
+
const label = extra > 0 ? `${names.join(", ")} and ${extra} ${extra === 1 ? "other" : "others"}` : names.join(", ");
|
|
91
|
+
return (_jsxs("span", { "data-slot": "avatar-group", className: cn("inline-flex items-center align-middle", className), ...(decorative ? { "aria-hidden": true } : { role: "img", "aria-label": label }), children: [shown.map((p, i) => (_jsx(Avatar, { name: p.name, src: p.src, size: size, className: cn("ring-2 ring-[var(--avatar-ring,var(--surface-primary))]", i > 0 && OVERLAP[size]), style: { zIndex: shown.length - i } }, `${p.name}-${i}`))), extra > 0 ? (_jsxs("span", { "data-slot": "avatar-group-count", className: cn(avatarVariants({ size }), OVERLAP[size], "items-center justify-center bg-[var(--surface-tertiary)] leading-none font-semibold text-[var(--text-secondary)] ring-2 ring-[var(--avatar-ring,var(--surface-primary))]"), children: ["+", extra] })) : null] }));
|
|
92
|
+
}
|
|
93
|
+
export { Avatar, AvatarGroup, avatarVariants, initialsOf };
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type * as React from "react";
|
|
2
|
+
import { type VariantProps } from "class-variance-authority";
|
|
3
|
+
declare const badgeVariants: (props?: ({
|
|
4
|
+
style?: "outline" | "alum" | "solid-red" | "solid-dark" | null | undefined;
|
|
5
|
+
} & import("class-variance-authority/types").ClassProp) | undefined) => string;
|
|
6
|
+
type BadgeProps = VariantProps<typeof badgeVariants> & {
|
|
7
|
+
className?: string;
|
|
8
|
+
children: React.ReactNode;
|
|
9
|
+
};
|
|
10
|
+
declare function Badge({ style, className, children }: BadgeProps): React.JSX.Element;
|
|
11
|
+
export { Badge, badgeVariants };
|
|
12
|
+
export type { BadgeProps };
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { cva } from "class-variance-authority";
|
|
3
|
+
import { cn } from "@brdgapp/ui/lib/utils";
|
|
4
|
+
// The "Solid label" sticker from the Arch Design System: 8px, bold, uppercase. Ported from Bridge OS
|
|
5
|
+
// src/components/ui/badge.tsx. Rounded 4px, never a pill. For soft status and category labels use Tag.
|
|
6
|
+
// Two fixes over Bridge OS: solid-red fills with --danger-solid (white on --error fails AA at 4.41:1), and
|
|
7
|
+
// solid-dark's text uses --surface-primary so it stays readable in dark mode (white on light grey didn't).
|
|
8
|
+
// ALUM's text is --honey-text, a deeper gold that reaches 4.7:1 on white; the border stays --honey (2026-11-04).
|
|
9
|
+
const badgeVariants = cva("inline-flex items-center rounded-[4px] px-[7px] py-1 text-[8px] leading-[8px] font-bold tracking-[1px] uppercase", {
|
|
10
|
+
variants: {
|
|
11
|
+
// Named `style` to match Bridge OS's API. It is not React's style prop: Badge takes no CSS styles.
|
|
12
|
+
style: {
|
|
13
|
+
outline: "border border-[var(--text-disabled)] text-[var(--text-muted)]",
|
|
14
|
+
alum: "border border-[var(--honey)] text-[var(--honey-text)]",
|
|
15
|
+
"solid-red": "bg-[var(--danger-solid)] text-white",
|
|
16
|
+
"solid-dark": "bg-[var(--text-secondary)] text-[var(--surface-primary)]",
|
|
17
|
+
},
|
|
18
|
+
},
|
|
19
|
+
defaultVariants: { style: "outline" },
|
|
20
|
+
});
|
|
21
|
+
function Badge({ style, className, children }) {
|
|
22
|
+
return (_jsx("span", { "data-slot": "badge", className: cn(badgeVariants({ style }), className), children: children }));
|
|
23
|
+
}
|
|
24
|
+
export { Badge, badgeVariants };
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import type { DialogAction } from "@brdgapp/ui/components/dialog";
|
|
3
|
+
type BottomSheetProps = {
|
|
4
|
+
open: boolean;
|
|
5
|
+
onClose: () => void;
|
|
6
|
+
/** What's being chosen: "Degree", "Sort by". */
|
|
7
|
+
title: React.ReactNode;
|
|
8
|
+
/** The options: a BottomSheetOptions holding BottomSheetOption rows. */
|
|
9
|
+
children: React.ReactNode;
|
|
10
|
+
/** For several choices: the footer's filled button, like "Apply". One choice needs none: picking closes the sheet. */
|
|
11
|
+
primaryAction?: DialogAction;
|
|
12
|
+
/** The footer button that closes without applying. Default "Cancel". Shown with `primaryAction`. */
|
|
13
|
+
cancelLabel?: string;
|
|
14
|
+
};
|
|
15
|
+
declare function BottomSheet({ open, onClose, title, children, primaryAction, cancelLabel }: BottomSheetProps): React.JSX.Element;
|
|
16
|
+
/**
|
|
17
|
+
* The options in a sheet. One choice (default): a list where ↑ and ↓ move and Enter picks; Tab enters at the
|
|
18
|
+
* chosen row. `multiple`: a checkbox per row, ticked and unticked until Apply.
|
|
19
|
+
*/
|
|
20
|
+
declare function BottomSheetOptions({ multiple, children }: {
|
|
21
|
+
multiple?: boolean;
|
|
22
|
+
children: React.ReactNode;
|
|
23
|
+
}): React.JSX.Element;
|
|
24
|
+
/**
|
|
25
|
+
* One option: a 44px row. In a one-choice sheet it shows a blue tick when chosen, and picking it should
|
|
26
|
+
* close the sheet. In a `multiple` sheet it is a Checkbox.
|
|
27
|
+
*/
|
|
28
|
+
declare function BottomSheetOption({ selected, onSelect, children }: {
|
|
29
|
+
selected?: boolean;
|
|
30
|
+
onSelect: () => void;
|
|
31
|
+
children: React.ReactNode;
|
|
32
|
+
}): React.JSX.Element;
|
|
33
|
+
export { BottomSheet, BottomSheetOption, BottomSheetOptions };
|
|
34
|
+
export type { BottomSheetProps };
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import * as React from "react";
|
|
4
|
+
import { Dialog as DialogPrimitive } from "@base-ui/react/dialog";
|
|
5
|
+
import { Check } from "lucide-react";
|
|
6
|
+
import { Button } from "@brdgapp/ui/components/button";
|
|
7
|
+
import { Checkbox } from "@brdgapp/ui/components/checkbox";
|
|
8
|
+
import { cn } from "@brdgapp/ui/lib/utils";
|
|
9
|
+
const SheetContext = React.createContext({ titleId: "" });
|
|
10
|
+
/** How far down, as a share of the sheet's height, a swipe has to go to close it. */
|
|
11
|
+
const CLOSE_AT = 1 / 3;
|
|
12
|
+
/** Or how fast, in px per ms: a quick flick closes it from anywhere. */
|
|
13
|
+
const FLICK = 0.5;
|
|
14
|
+
function BottomSheet({ open, onClose, title, children, primaryAction, cancelLabel = "Cancel" }) {
|
|
15
|
+
const titleId = React.useId();
|
|
16
|
+
const popup = React.useRef(null);
|
|
17
|
+
const start = React.useRef(null);
|
|
18
|
+
// How far the sheet has been dragged down (px), and whether a finger is on it now.
|
|
19
|
+
const [drag, setDrag] = React.useState(null);
|
|
20
|
+
const [dragging, setDragging] = React.useState(false);
|
|
21
|
+
function endDrag(clientY) {
|
|
22
|
+
if (!start.current)
|
|
23
|
+
return;
|
|
24
|
+
const dy = Math.max(0, clientY - start.current.y);
|
|
25
|
+
const speed = dy / Math.max(1, performance.now() - start.current.t);
|
|
26
|
+
const height = popup.current?.offsetHeight ?? 1;
|
|
27
|
+
start.current = null;
|
|
28
|
+
setDragging(false);
|
|
29
|
+
if (dy > height * CLOSE_AT || speed > FLICK) {
|
|
30
|
+
// Carry on down from where the finger let go, rather than jumping back first.
|
|
31
|
+
setDrag(height);
|
|
32
|
+
onClose();
|
|
33
|
+
}
|
|
34
|
+
else {
|
|
35
|
+
setDrag(null);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
return (_jsx(DialogPrimitive.Root, { open: open, onOpenChange: (next) => !next && onClose(), onOpenChangeComplete: (isOpen) => {
|
|
39
|
+
if (!isOpen)
|
|
40
|
+
setDrag(null);
|
|
41
|
+
}, children: _jsxs(DialogPrimitive.Portal, { children: [_jsx(DialogPrimitive.Backdrop, { className: "fixed inset-0 z-[80] bg-black/30 transition-opacity duration-300 ease-out data-[ending-style]:duration-200 data-[starting-style]:opacity-0 data-[ending-style]:opacity-0" }), _jsxs(DialogPrimitive.Popup, { ref: popup, "data-slot": "bottom-sheet", "aria-labelledby": titleId, style: drag === null ? undefined : { translate: `0 ${drag}px`, transition: dragging ? "none" : undefined }, className: cn("fixed inset-x-0 bottom-0 z-[80] flex max-h-[85dvh] flex-col rounded-t-2xl border-t border-[var(--border-default)] bg-[var(--surface-elevated)] shadow-[var(--shadow-dialog)] outline-none", primaryAction ? null : "pb-[max(12px,env(safe-area-inset-bottom))]", "transition-[translate] duration-300 ease-out data-[ending-style]:duration-200 data-[starting-style]:translate-y-full data-[ending-style]:translate-y-full motion-reduce:transition-none"), children: [_jsxs("div", { "data-slot": "bottom-sheet-grab", className: "shrink-0 cursor-grab touch-none select-none active:cursor-grabbing", onPointerDown: (e) => {
|
|
42
|
+
if (e.button !== 0)
|
|
43
|
+
return;
|
|
44
|
+
start.current = { y: e.clientY, t: performance.now() };
|
|
45
|
+
setDragging(true);
|
|
46
|
+
e.currentTarget.setPointerCapture(e.pointerId);
|
|
47
|
+
}, onPointerMove: (e) => {
|
|
48
|
+
if (start.current)
|
|
49
|
+
setDrag(Math.max(0, e.clientY - start.current.y));
|
|
50
|
+
}, onPointerUp: (e) => endDrag(e.clientY), onPointerCancel: (e) => endDrag(e.clientY), children: [_jsx("div", { "aria-hidden": "true", className: "mx-auto mt-2 h-1 w-10 rounded-full bg-[var(--border-hover)]" }), _jsx(DialogPrimitive.Title, { id: titleId, className: "px-5 pt-3 pb-2 text-16 font-bold tracking-tight text-[var(--text-primary)]", children: title })] }), _jsx("div", { "data-slot": "bottom-sheet-body", className: "min-h-0 flex-1 overflow-y-auto overscroll-contain", children: _jsx(SheetContext.Provider, { value: { titleId }, children: children }) }), primaryAction ? (_jsxs("footer", { "data-slot": "bottom-sheet-footer", className: "flex shrink-0 gap-2 border-t border-[var(--border-divider)] px-5 pt-3 pb-[max(12px,env(safe-area-inset-bottom))]", children: [_jsx(Button, { variant: "secondary", size: "md", onClick: onClose, className: "flex-1", children: cancelLabel }), _jsx(Button, { size: "md", disabled: primaryAction.disabled, icon: primaryAction.icon, onClick: primaryAction.onClick, className: "flex-1", children: primaryAction.label })] })) : null] })] }) }));
|
|
51
|
+
}
|
|
52
|
+
const OptionsContext = React.createContext({ multiple: false, tabStop: 0, index: 0 });
|
|
53
|
+
/**
|
|
54
|
+
* The options in a sheet. One choice (default): a list where ↑ and ↓ move and Enter picks; Tab enters at the
|
|
55
|
+
* chosen row. `multiple`: a checkbox per row, ticked and unticked until Apply.
|
|
56
|
+
*/
|
|
57
|
+
function BottomSheetOptions({ multiple = false, children }) {
|
|
58
|
+
const { titleId } = React.useContext(SheetContext);
|
|
59
|
+
const rows = React.Children.toArray(children).filter(React.isValidElement);
|
|
60
|
+
const chosen = rows.findIndex((r) => r.props.selected);
|
|
61
|
+
const tabStop = chosen === -1 ? 0 : chosen;
|
|
62
|
+
function onKeyDown(e) {
|
|
63
|
+
const keys = {
|
|
64
|
+
ArrowDown: (i, n) => (i + 1) % n,
|
|
65
|
+
ArrowUp: (i, n) => (i - 1 + n) % n,
|
|
66
|
+
Home: () => 0,
|
|
67
|
+
End: (_, n) => n - 1,
|
|
68
|
+
};
|
|
69
|
+
const move = keys[e.key];
|
|
70
|
+
if (!move)
|
|
71
|
+
return;
|
|
72
|
+
const items = Array.from(e.currentTarget.querySelectorAll("[data-slot=bottom-sheet-option], [data-slot=checkbox]"));
|
|
73
|
+
if (items.length === 0)
|
|
74
|
+
return;
|
|
75
|
+
e.preventDefault();
|
|
76
|
+
const at = items.findIndex((el) => el === document.activeElement || el.contains(document.activeElement));
|
|
77
|
+
items[move(at === -1 ? 0 : at, items.length)]?.focus();
|
|
78
|
+
}
|
|
79
|
+
return (_jsx("div", { "data-slot": "bottom-sheet-options", role: multiple ? "group" : "listbox", "aria-labelledby": titleId || undefined, onKeyDown: onKeyDown, className: "flex flex-col", children: rows.map((row, index) => (_jsx(OptionsContext.Provider, { value: { multiple, tabStop, index }, children: row }, row.key ?? index))) }));
|
|
80
|
+
}
|
|
81
|
+
// Hover is the menus' light grey. Keyboard focus adds the blue inner ring table rows use, since the grey alone
|
|
82
|
+
// is too faint on the white sheet; a checkbox row's box draws its own ring.
|
|
83
|
+
const ROW = "flex min-h-11 w-full items-center gap-3 px-5 text-left text-14 leading-normal outline-none transition-colors hover:bg-[var(--surface-secondary)] active:bg-[var(--surface-tertiary)] focus-visible:bg-[var(--surface-secondary)] focus-visible:ring-2 focus-visible:ring-[var(--primary)] focus-visible:ring-inset";
|
|
84
|
+
/**
|
|
85
|
+
* One option: a 44px row. In a one-choice sheet it shows a blue tick when chosen, and picking it should
|
|
86
|
+
* close the sheet. In a `multiple` sheet it is a Checkbox.
|
|
87
|
+
*/
|
|
88
|
+
function BottomSheetOption({ selected = false, onSelect, children }) {
|
|
89
|
+
const { multiple, tabStop, index } = React.useContext(OptionsContext);
|
|
90
|
+
if (multiple) {
|
|
91
|
+
// Focus is on the box inside the row, so the row lights up with `has-[:focus-visible]`.
|
|
92
|
+
return (_jsx(Checkbox, { label: children, checked: selected, onCheckedChange: onSelect, className: cn(ROW, "text-[var(--text-primary)] has-[:focus-visible]:bg-[var(--surface-secondary)]") }));
|
|
93
|
+
}
|
|
94
|
+
return (_jsxs("button", { type: "button", role: "option", "aria-selected": selected, tabIndex: index === tabStop ? 0 : -1, onClick: onSelect, "data-slot": "bottom-sheet-option", className: cn(ROW, "justify-between", selected ? "font-semibold text-[var(--text-primary)]" : "text-[var(--text-body)]"), children: [_jsx("span", { className: "truncate", children: children }), selected ? _jsx(Check, { "aria-hidden": "true", className: "size-4 shrink-0 text-[var(--primary)]", strokeWidth: 2.5 }) : null] }));
|
|
95
|
+
}
|
|
96
|
+
export { BottomSheet, BottomSheetOption, BottomSheetOptions };
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
export type Brand = "linkedin" | "google" | "microsoft" | "apple" | "whatsapp" | "telegram" | "chrome";
|
|
2
|
+
declare const NAME: Record<Brand, string>;
|
|
3
|
+
type BrandMarkProps = {
|
|
4
|
+
brand: Brand;
|
|
5
|
+
/**
|
|
6
|
+
* Say the company's name to screen readers. Leave it off when its name is already written next to it
|
|
7
|
+
* ("Sign in with Google"): the mark is then hidden from them. Set it when the mark stands alone.
|
|
8
|
+
*/
|
|
9
|
+
label?: boolean;
|
|
10
|
+
/**
|
|
11
|
+
* One color that follows the text, for a quiet mark in a row of links. LinkedIn, WhatsApp and Telegram
|
|
12
|
+
* only; Google, Microsoft and Chrome stay in color, and Apple is always one color.
|
|
13
|
+
*/
|
|
14
|
+
mono?: boolean;
|
|
15
|
+
/** Size and layout only: `size-3.5`, `shrink-0`. 16px by default, like an icon. */
|
|
16
|
+
className?: string;
|
|
17
|
+
};
|
|
18
|
+
/** A company's logo at icon size, in its own colors. Not an icon: Lucide has none of these. */
|
|
19
|
+
declare function BrandMark({ brand, label, mono, className }: BrandMarkProps): import("react").JSX.Element;
|
|
20
|
+
export { BrandMark, NAME as BRAND_NAMES };
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { cn } from "@brdgapp/ui/lib/utils";
|
|
3
|
+
/** Brands whose own rules allow a one-color version. Google, Microsoft and Chrome are always in color. */
|
|
4
|
+
const CAN_BE_MONO = new Set(["linkedin", "whatsapp", "telegram", "apple"]);
|
|
5
|
+
const NAME = {
|
|
6
|
+
linkedin: "LinkedIn",
|
|
7
|
+
google: "Google",
|
|
8
|
+
microsoft: "Microsoft",
|
|
9
|
+
apple: "Apple",
|
|
10
|
+
whatsapp: "WhatsApp",
|
|
11
|
+
telegram: "Telegram",
|
|
12
|
+
chrome: "Chrome",
|
|
13
|
+
};
|
|
14
|
+
const LINKEDIN = "M20.447 20.452h-3.554v-5.569c0-1.328-.027-3.037-1.852-3.037-1.853 0-2.136 1.445-2.136 2.939v5.667H9.351V9h3.414v1.561h.046c.477-.9 1.637-1.85 3.37-1.85 3.601 0 4.267 2.37 4.267 5.455v6.286zM5.337 7.433c-1.144 0-2.063-.926-2.063-2.065 0-1.138.92-2.063 2.063-2.063 1.14 0 2.064.925 2.064 2.063 0 1.139-.925 2.065-2.064 2.065zm1.782 13.019H3.555V9h3.564v11.452zM22.225 0H1.771C.792 0 0 .774 0 1.729v20.542C0 23.227.792 24 1.771 24h20.451C23.2 24 24 23.227 24 22.271V1.729C24 .774 23.2 0 22.222 0h.003z";
|
|
15
|
+
const APPLE = "M16.365 1.43c0 1.14-.415 2.205-1.19 3.03-.81.87-2.145 1.54-3.28 1.45-.145-1.09.42-2.24 1.17-3.02.81-.85 2.205-1.47 3.3-1.46zM20.7 17.39c-.52 1.2-.77 1.73-1.44 2.79-.94 1.45-2.26 3.26-3.9 3.28-1.46.02-1.84-.95-3.82-.94-1.99.01-2.4.96-3.86.94-1.64-.02-2.89-1.65-3.83-3.1C1.88 17.42.5 12.84 2.4 9.64c.95-1.6 2.45-2.61 4.14-2.61 1.54 0 2.51.99 3.79.99 1.24 0 2-.99 3.8-.99 1.52 0 3.13.83 4.07 2.26-3.58 1.97-3 7.1.5 8.1z";
|
|
16
|
+
const WHATSAPP_RING = "M360,0C161.18,0,0,161.18,0,360c0,65.41,17.45,126.75,47.94,179.61L0,720l187.02-44.21c51.34,28.18,110.28,44.21,172.98,44.21,198.82,0,360-161.18,360-360S558.82,0,360,0ZM360,655.52c-60.17,0-116.13-17.98-162.82-48.87l-110.49,28.14,30.99-105.61c-33.53-47.93-53.2-106.26-53.2-169.19,0-163.21,132.31-295.52,295.52-295.52s295.52,132.31,295.52,295.52-132.31,295.52-295.52,295.52Z";
|
|
17
|
+
const WHATSAPP_PHONE = "M444.35,407.52l87.1,41.06c4,1.88,6.56,5.94,6.2,10.34-.94,11.46-5.54,34.43-26.13,55.02-58.12,58.12-162.49-7.64-166.74-10.18-25.67-13.79-50.06-32.24-73.19-55.36-23.12-23.12-41.58-47.52-55.37-73.19-2.55-4.24-68.31-108.61-10.18-166.74,20.59-20.59,43.56-25.19,55.02-26.13,4.41-.36,8.46,2.2,10.34,6.2l41.07,87.1c1.94,4.12,1.09,9.02-2.13,12.24l-30.61,30.61c-6.62,6.62-8.56,16.93-4,25.11,11.17,20.03,26.19,39.32,43.59,57.07,17.75,17.4,37.04,32.43,57.07,43.59,8.18,4.56,18.48,2.62,25.11-4l30.61-30.61c3.22-3.22,8.12-4.08,12.24-2.13Z";
|
|
18
|
+
const TELEGRAM_PLANE = "M5.4 11.7 16.9 7.3c.5-.2 1 .1.8.9l-2 9.3c-.1.6-.5.8-1 .5l-2.9-2.1-1.4 1.3c-.2.2-.3.3-.6.3l.2-3 5.4-4.9c.2-.2 0-.3-.3-.1l-6.7 4.2-2.9-.9c-.6-.2-.6-.6.1-.9Z";
|
|
19
|
+
const CIRCLE_24 = "M12 0a12 12 0 1 0 0 24 12 12 0 0 0 0-24Z";
|
|
20
|
+
function Drawing({ brand, mono }) {
|
|
21
|
+
switch (brand) {
|
|
22
|
+
case "linkedin":
|
|
23
|
+
return (_jsxs("svg", { viewBox: "0 0 24 24", children: [mono ? null : _jsx("rect", { x: "2", y: "2", width: "20", height: "20", fill: "#fff" }), _jsx("path", { d: LINKEDIN, fill: mono ? "currentColor" : "#0A66C2" })] }));
|
|
24
|
+
case "google":
|
|
25
|
+
return (_jsxs("svg", { viewBox: "0 0 48 48", children: [_jsx("path", { fill: "#FFC107", d: "M43.611 20.083H42V20H24v8h11.303c-1.649 4.657-6.08 8-11.303 8-6.627 0-12-5.373-12-12s5.373-12 12-12c3.059 0 5.842 1.154 7.961 3.039l5.657-5.657C34.046 6.053 29.268 4 24 4 12.955 4 4 12.955 4 24s8.955 20 20 20 20-8.955 20-20c0-1.341-.138-2.65-.389-3.917z" }), _jsx("path", { fill: "#FF3D00", d: "M6.306 14.691l6.571 4.819C14.655 15.108 18.961 12 24 12c3.059 0 5.842 1.154 7.961 3.039l5.657-5.657C34.046 6.053 29.268 4 24 4 16.318 4 9.656 8.337 6.306 14.691z" }), _jsx("path", { fill: "#4CAF50", d: "M24 44c5.166 0 9.86-1.977 13.409-5.192l-6.19-5.238C29.211 35.091 26.715 36 24 36c-5.202 0-9.619-3.317-11.283-7.946l-6.522 5.025C9.505 39.556 16.227 44 24 44z" }), _jsx("path", { fill: "#1976D2", d: "M43.611 20.083H42V20H24v8h11.303c-.792 2.237-2.231 4.166-4.087 5.571.001-.001.002-.001.003-.002l6.19 5.238C36.971 39.205 44 34 44 24c0-1.341-.138-2.65-.389-3.917z" })] }));
|
|
26
|
+
case "microsoft":
|
|
27
|
+
return (_jsxs("svg", { viewBox: "0 0 23 23", children: [_jsx("path", { d: "M1 1h10v10H1V1z", fill: "#F25022" }), _jsx("path", { d: "M12 1h10v10H12V1z", fill: "#7FBA00" }), _jsx("path", { d: "M1 12h10v10H1V12z", fill: "#00A4EF" }), _jsx("path", { d: "M12 12h10v10H12V12z", fill: "#FFB900" })] }));
|
|
28
|
+
case "apple":
|
|
29
|
+
// Apple's mark is one color: it follows the text, so it's black on light and white on dark.
|
|
30
|
+
return (_jsx("svg", { viewBox: "0 0 24 24", children: _jsx("path", { d: APPLE, fill: "currentColor" }) }));
|
|
31
|
+
case "whatsapp":
|
|
32
|
+
return (_jsxs("svg", { viewBox: "0 0 720 720", fill: mono ? "currentColor" : "#25D366", children: [_jsx("path", { d: WHATSAPP_RING }), _jsx("path", { d: WHATSAPP_PHONE })] }));
|
|
33
|
+
case "telegram":
|
|
34
|
+
return mono ? (_jsx("svg", { viewBox: "0 0 24 24", children: _jsx("path", { d: `${CIRCLE_24}${TELEGRAM_PLANE}`, fill: "currentColor", fillRule: "evenodd" }) })) : (_jsxs("svg", { viewBox: "0 0 24 24", children: [_jsx("circle", { cx: "12", cy: "12", r: "12", fill: "#2AABEE" }), _jsx("path", { d: TELEGRAM_PLANE, fill: "#fff" })] }));
|
|
35
|
+
case "chrome":
|
|
36
|
+
return (_jsxs("svg", { viewBox: "2 2 44 44", children: [_jsx("path", { fill: "#EA4335", d: "M15.34 29 5.542 12.029A22 22 0 0 1 43.596 14H24a10 10 0 0 0-8.66 15Z" }), _jsx("path", { fill: "#FBBC04", d: "M24 14h19.596a22 22 0 0 1-20.734 31.971L32.66 29A10 10 0 0 0 24 14Z" }), _jsx("path", { fill: "#34A853", d: "M32.66 29 22.862 45.971A22 22 0 0 1 5.542 12.029L15.34 29a10 10 0 0 0 17.32 0Z" }), _jsx("circle", { cx: "24", cy: "24", r: "10", fill: "#fff" }), _jsx("circle", { cx: "24", cy: "24", r: "8", fill: "#1A73E8" })] }));
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
/** A company's logo at icon size, in its own colors. Not an icon: Lucide has none of these. */
|
|
40
|
+
function BrandMark({ brand, label = false, mono = false, className }) {
|
|
41
|
+
const oneColor = mono && CAN_BE_MONO.has(brand);
|
|
42
|
+
return (_jsx("span", { "data-slot": "brand-mark", role: label ? "img" : undefined, "aria-label": label ? NAME[brand] : undefined, "aria-hidden": label ? undefined : true, className: cn("inline-flex size-4 shrink-0 [&>svg]:size-full", className), children: _jsx(Drawing, { brand: brand, mono: oneColor }) }));
|
|
43
|
+
}
|
|
44
|
+
export { BrandMark, NAME as BRAND_NAMES };
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type * as React from "react";
|
|
2
|
+
import { Button as ButtonPrimitive } from "@base-ui/react/button";
|
|
3
|
+
type ButtonGroupVariant = "secondary" | "primary";
|
|
4
|
+
declare const buttonGroupVariants: (props?: ({
|
|
5
|
+
variant?: "primary" | "secondary" | null | undefined;
|
|
6
|
+
} & import("class-variance-authority/types").ClassProp) | undefined) => string;
|
|
7
|
+
declare function ButtonGroup({ variant, className, children, ...props }: {
|
|
8
|
+
variant?: ButtonGroupVariant;
|
|
9
|
+
/** Name the group for screen readers when the actions need context: "Intro actions". */
|
|
10
|
+
"aria-label"?: string;
|
|
11
|
+
className?: string;
|
|
12
|
+
children: React.ReactNode;
|
|
13
|
+
}): React.JSX.Element;
|
|
14
|
+
declare const buttonGroupItemVariants: (props?: ({
|
|
15
|
+
variant?: "primary" | "secondary" | null | undefined;
|
|
16
|
+
iconOnly?: boolean | null | undefined;
|
|
17
|
+
} & import("class-variance-authority/types").ClassProp) | undefined) => string;
|
|
18
|
+
type ButtonGroupItemProps = Omit<ButtonPrimitive.Props, "className"> & {
|
|
19
|
+
/** Tighter padding for a segment that is only an icon. It then needs an `aria-label`. */
|
|
20
|
+
iconOnly?: boolean;
|
|
21
|
+
className?: string;
|
|
22
|
+
};
|
|
23
|
+
declare function ButtonGroupItem({ iconOnly, className, render, children, ...props }: ButtonGroupItemProps): React.JSX.Element;
|
|
24
|
+
export { ButtonGroup, ButtonGroupItem, buttonGroupVariants, buttonGroupItemVariants };
|
|
25
|
+
export type { ButtonGroupVariant, ButtonGroupItemProps };
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
|
+
import { createContext, useContext } from "react";
|
|
4
|
+
import { Button as ButtonPrimitive } from "@base-ui/react/button";
|
|
5
|
+
import { mergeProps } from "@base-ui/react/merge-props";
|
|
6
|
+
import { useRender } from "@base-ui/react/use-render";
|
|
7
|
+
import { cva } from "class-variance-authority";
|
|
8
|
+
import { cn } from "@brdgapp/ui/lib/utils";
|
|
9
|
+
const ButtonGroupContext = createContext("secondary");
|
|
10
|
+
const buttonGroupVariants = cva(
|
|
11
|
+
// Ends are rounded on the children, not by clipping, so a segment's tooltip is never cut off.
|
|
12
|
+
"inline-flex items-stretch rounded-full [&>*+*]:border-l [&>*:first-child]:rounded-l-full [&>*:last-child]:rounded-r-full", {
|
|
13
|
+
variants: {
|
|
14
|
+
variant: {
|
|
15
|
+
secondary: "border border-[var(--text-disabled)] bg-[var(--surface-elevated)] [&>*+*]:border-[var(--border-divider)]",
|
|
16
|
+
primary: "border border-[var(--primary-solid)] bg-[var(--primary-solid)] [&>*+*]:border-white/25",
|
|
17
|
+
},
|
|
18
|
+
},
|
|
19
|
+
defaultVariants: { variant: "secondary" },
|
|
20
|
+
});
|
|
21
|
+
function ButtonGroup({ variant = "secondary", className, children, ...props }) {
|
|
22
|
+
return (_jsx(ButtonGroupContext.Provider, { value: variant, children: _jsx("div", { "data-slot": "button-group", role: "group", className: cn(buttonGroupVariants({ variant }), className), ...props, children: children }) }));
|
|
23
|
+
}
|
|
24
|
+
const buttonGroupItemVariants = cva([
|
|
25
|
+
"inline-flex h-8 items-center justify-center gap-1.5 text-14 font-semibold tracking-[0.4px]",
|
|
26
|
+
"transition-colors duration-150 outline-none focus-visible:ring-2 focus-visible:ring-inset",
|
|
27
|
+
"disabled:pointer-events-none disabled:opacity-50 [&_svg]:size-[15px] [&_svg]:shrink-0",
|
|
28
|
+
], {
|
|
29
|
+
variants: {
|
|
30
|
+
variant: {
|
|
31
|
+
secondary: "text-[var(--text-secondary)] hover:bg-[var(--surface-secondary)] hover:text-[var(--text-primary)] focus-visible:ring-[var(--primary)]",
|
|
32
|
+
primary: "text-white hover:bg-[var(--primary-solid-hover)] active:bg-[var(--primary-active)] focus-visible:ring-white",
|
|
33
|
+
},
|
|
34
|
+
iconOnly: { true: "px-2.5", false: "px-3.5" },
|
|
35
|
+
},
|
|
36
|
+
// Only the secondary icon-only segment mutes its glyph; on primary it stays white.
|
|
37
|
+
compoundVariants: [{ variant: "secondary", iconOnly: true, className: "text-[var(--text-muted)]" }],
|
|
38
|
+
defaultVariants: { variant: "secondary", iconOnly: false },
|
|
39
|
+
});
|
|
40
|
+
function ButtonGroupItem({ iconOnly = false, className, render, children, ...props }) {
|
|
41
|
+
const variant = useContext(ButtonGroupContext);
|
|
42
|
+
const classes = cn(buttonGroupItemVariants({ variant, iconOnly }), className);
|
|
43
|
+
// With `render` (a Next Link), the segment keeps link semantics.
|
|
44
|
+
const rendered = useRender({
|
|
45
|
+
render: render,
|
|
46
|
+
enabled: render !== undefined,
|
|
47
|
+
props: mergeProps({ className: classes, "data-slot": "button-group-item" }, props, { children }),
|
|
48
|
+
});
|
|
49
|
+
if (rendered)
|
|
50
|
+
return rendered;
|
|
51
|
+
return (_jsx(ButtonPrimitive, { "data-slot": "button-group-item", className: classes, ...props, children: children }));
|
|
52
|
+
}
|
|
53
|
+
export { ButtonGroup, ButtonGroupItem, buttonGroupVariants, buttonGroupItemVariants };
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import type * as React from "react";
|
|
2
|
+
import { Button as ButtonPrimitive } from "@base-ui/react/button";
|
|
3
|
+
import { type VariantProps } from "class-variance-authority";
|
|
4
|
+
declare const buttonVariants: (props?: ({
|
|
5
|
+
variant?: "link" | "primary" | "secondary" | "ghost" | "destructive" | "danger-ghost" | null | undefined;
|
|
6
|
+
size?: "xs" | "sm" | "md" | "lg" | null | undefined;
|
|
7
|
+
fullWidth?: boolean | null | undefined;
|
|
8
|
+
} & import("class-variance-authority/types").ClassProp) | undefined) => string;
|
|
9
|
+
type ButtonProps = Omit<ButtonPrimitive.Props, "className"> & VariantProps<typeof buttonVariants> & {
|
|
10
|
+
className?: string;
|
|
11
|
+
/** A leading icon. Pass a bare Lucide icon; it is sized for you and hidden from screen readers. */
|
|
12
|
+
icon?: React.ReactNode;
|
|
13
|
+
/** The action is running: shows a spinner, disables the button and sets `aria-busy`. */
|
|
14
|
+
loading?: boolean;
|
|
15
|
+
};
|
|
16
|
+
declare function Button({ className, variant, size, fullWidth, icon, loading, disabled, render, children, ...props }: ButtonProps): React.JSX.Element;
|
|
17
|
+
declare const buttonSkeletonHeights: {
|
|
18
|
+
readonly xs: "h-7";
|
|
19
|
+
readonly sm: "h-8";
|
|
20
|
+
readonly md: "h-11 md:h-10";
|
|
21
|
+
readonly lg: "h-12";
|
|
22
|
+
};
|
|
23
|
+
/**
|
|
24
|
+
* Placeholder for a button whose data hasn't loaded yet. Same height as the real button, so swapping
|
|
25
|
+
* it in causes no layout shift. Not the same as `loading`, which is an action already running.
|
|
26
|
+
*/
|
|
27
|
+
declare function ButtonSkeleton({ size, width, className, }: {
|
|
28
|
+
size?: keyof typeof buttonSkeletonHeights;
|
|
29
|
+
width?: number | string;
|
|
30
|
+
className?: string;
|
|
31
|
+
}): React.JSX.Element;
|
|
32
|
+
export { Button, ButtonSkeleton, buttonVariants };
|
|
33
|
+
export type { ButtonProps };
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { Button as ButtonPrimitive } from "@base-ui/react/button";
|
|
4
|
+
import { mergeProps } from "@base-ui/react/merge-props";
|
|
5
|
+
import { useRender } from "@base-ui/react/use-render";
|
|
6
|
+
import { cva } from "class-variance-authority";
|
|
7
|
+
import { Loader2 } from "lucide-react";
|
|
8
|
+
import { cn } from "@brdgapp/ui/lib/utils";
|
|
9
|
+
// Started from shadcn's Base UI button (style base-nova), then moved onto Bridge's tokens and API.
|
|
10
|
+
// Look and API match Bridge OS src/components/ui/button.tsx (components.md, 2026-10-29); `asChild`
|
|
11
|
+
// became `render`. Fills use the AA-verified --primary-solid / --danger-solid, never --primary / --error.
|
|
12
|
+
const buttonVariants = cva([
|
|
13
|
+
"group/button inline-flex items-center gap-1.5 whitespace-nowrap font-semibold tracking-[0.4px]",
|
|
14
|
+
"transition-all duration-150 ease-out outline-none select-none",
|
|
15
|
+
"disabled:pointer-events-none disabled:opacity-50",
|
|
16
|
+
"[&_svg]:pointer-events-none [&_svg]:shrink-0",
|
|
17
|
+
], {
|
|
18
|
+
variants: {
|
|
19
|
+
variant: {
|
|
20
|
+
primary: "bg-[var(--primary-solid)] text-white hover:bg-[var(--primary-solid-hover)] active:bg-[var(--primary-active)] focus-visible:ring-[var(--primary)]",
|
|
21
|
+
// Bordered variants sit on a solid raised fill, never transparent, so page glow never shows
|
|
22
|
+
// through. The label names the control, so the grey border is decorative.
|
|
23
|
+
secondary: "border border-[var(--text-disabled)] bg-[var(--surface-elevated)] text-[var(--text-primary)] hover:border-[var(--text-muted)] hover:bg-[var(--surface-secondary)] focus-visible:ring-[var(--primary)]",
|
|
24
|
+
ghost: "bg-transparent text-[var(--text-secondary)] hover:bg-[var(--surface-tertiary)] focus-visible:ring-[var(--primary)]",
|
|
25
|
+
destructive: "bg-[var(--danger-solid)] text-white hover:bg-[var(--danger-solid-hover)] focus-visible:ring-[var(--error)]",
|
|
26
|
+
"danger-ghost": "bg-transparent text-[var(--danger-text)] hover:bg-[var(--error-bg)] focus-visible:ring-[var(--error)]",
|
|
27
|
+
// Inline text action: no pill, no padding, primary colour, underline on hover.
|
|
28
|
+
link: "justify-start bg-transparent p-0 text-[var(--primary)] underline-offset-2 hover:text-[var(--primary-hover)] hover:underline focus-visible:underline disabled:no-underline",
|
|
29
|
+
},
|
|
30
|
+
// xs (28px) is the smallest button with words. Only IconButton `xs` goes to 24px, WCAG's minimum target.
|
|
31
|
+
size: {
|
|
32
|
+
xs: "text-12 [&_svg:not([class*='size-'])]:size-3.5",
|
|
33
|
+
sm: "text-14 [&_svg:not([class*='size-'])]:size-4",
|
|
34
|
+
md: "text-14 [&_svg:not([class*='size-'])]:size-4",
|
|
35
|
+
lg: "text-16 [&_svg:not([class*='size-'])]:size-[18px]",
|
|
36
|
+
},
|
|
37
|
+
fullWidth: {
|
|
38
|
+
true: "w-full",
|
|
39
|
+
false: "",
|
|
40
|
+
},
|
|
41
|
+
},
|
|
42
|
+
compoundVariants: [
|
|
43
|
+
// Every variant except `link` is a pill with a fixed height and padding.
|
|
44
|
+
{
|
|
45
|
+
variant: ["primary", "secondary", "ghost", "destructive", "danger-ghost"],
|
|
46
|
+
className: "justify-center rounded-full active:scale-[0.98] focus-visible:ring-2 focus-visible:ring-offset-2 focus-visible:ring-offset-[var(--surface-primary)]",
|
|
47
|
+
},
|
|
48
|
+
{ variant: ["primary", "secondary", "ghost", "destructive", "danger-ghost"], size: "xs", className: "h-7 px-3" },
|
|
49
|
+
{ variant: ["primary", "secondary", "ghost", "destructive", "danger-ghost"], size: "sm", className: "h-8 px-[14px] py-1" },
|
|
50
|
+
{ variant: ["primary", "secondary", "ghost", "destructive", "danger-ghost"], size: "md", className: "h-11 px-5 md:h-10" },
|
|
51
|
+
{ variant: ["primary", "secondary", "ghost", "destructive", "danger-ghost"], size: "lg", className: "h-12 px-6 py-3" },
|
|
52
|
+
// A link reads as text, so it never stretches.
|
|
53
|
+
{ variant: "link", fullWidth: true, className: "w-auto" },
|
|
54
|
+
// The line height links have always had (1.625), after the size so it isn't dropped: a link keeps its height.
|
|
55
|
+
{ variant: "link", className: "leading-[1.625]" },
|
|
56
|
+
],
|
|
57
|
+
defaultVariants: {
|
|
58
|
+
variant: "primary",
|
|
59
|
+
size: "sm",
|
|
60
|
+
fullWidth: false,
|
|
61
|
+
},
|
|
62
|
+
});
|
|
63
|
+
function Button({ className, variant, size, fullWidth, icon, loading = false, disabled, render, children, ...props }) {
|
|
64
|
+
const classes = cn(buttonVariants({ variant, size, fullWidth }), className);
|
|
65
|
+
// With `render` (for example a Next `Link`), the element keeps its own semantics: a link stays a
|
|
66
|
+
// link. It owns its content, so `icon` and `loading` don't apply.
|
|
67
|
+
const rendered = useRender({
|
|
68
|
+
render: render,
|
|
69
|
+
enabled: render !== undefined,
|
|
70
|
+
props: mergeProps({ className: classes, "data-slot": "button" }, props, { children }),
|
|
71
|
+
});
|
|
72
|
+
if (rendered)
|
|
73
|
+
return rendered;
|
|
74
|
+
return (_jsxs(ButtonPrimitive, { "data-slot": "button", className: classes, disabled: disabled || loading, "aria-busy": loading || undefined, ...props, children: [loading ? (_jsx(Loader2, { "data-slot": "button-spinner", className: "animate-spin", "aria-hidden": "true" })) : icon ? (_jsx("span", { "data-slot": "button-icon", className: "inline-flex shrink-0", "aria-hidden": "true", children: icon })) : null, children] }));
|
|
75
|
+
}
|
|
76
|
+
const buttonSkeletonHeights = { xs: "h-7", sm: "h-8", md: "h-11 md:h-10", lg: "h-12" };
|
|
77
|
+
/**
|
|
78
|
+
* Placeholder for a button whose data hasn't loaded yet. Same height as the real button, so swapping
|
|
79
|
+
* it in causes no layout shift. Not the same as `loading`, which is an action already running.
|
|
80
|
+
*/
|
|
81
|
+
function ButtonSkeleton({ size = "sm", width = "7rem", className, }) {
|
|
82
|
+
return (_jsx("span", { "data-slot": "button-skeleton", "aria-hidden": "true", style: { width }, className: cn("inline-block animate-pulse rounded-full bg-[var(--skeleton)] motion-reduce:animate-none", buttonSkeletonHeights[size], className) }));
|
|
83
|
+
}
|
|
84
|
+
export { Button, ButtonSkeleton, buttonVariants };
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { type VariantProps } from "class-variance-authority";
|
|
3
|
+
declare const cardVariants: (props?: ({
|
|
4
|
+
size?: "sm" | "md" | "lg" | null | undefined;
|
|
5
|
+
} & import("class-variance-authority/types").ClassProp) | undefined) => string;
|
|
6
|
+
type CardProps = VariantProps<typeof cardVariants> & {
|
|
7
|
+
/** No padding: for a table or list that runs edge to edge. A table's card has no header (the page names it). */
|
|
8
|
+
flush?: boolean;
|
|
9
|
+
/** No glass and no side padding: a row inside another card or pane, split from its neighbours by dividers. */
|
|
10
|
+
bare?: boolean;
|
|
11
|
+
/** The whole card goes to this page. It rises on hover. */
|
|
12
|
+
href?: string;
|
|
13
|
+
/** Your router's link (Next `Link`) for `href`. A plain `<a>` by default. */
|
|
14
|
+
linkAs?: React.ElementType;
|
|
15
|
+
/** The whole card picks this item, usually to open it in a pane. It tints on hover. */
|
|
16
|
+
onSelect?: () => void;
|
|
17
|
+
/** The picked card: blue border and tint. Use with `onSelect`. */
|
|
18
|
+
selected?: boolean;
|
|
19
|
+
/** Can't be clicked; faded. */
|
|
20
|
+
disabled?: boolean;
|
|
21
|
+
/** What the card is called, when it has no CardHeader to take the name from. Clickable cards need a name. */
|
|
22
|
+
label?: string;
|
|
23
|
+
/** Layout only: `w-full`, `max-w-md`, `col-span-2`. */
|
|
24
|
+
className?: string;
|
|
25
|
+
children?: React.ReactNode;
|
|
26
|
+
};
|
|
27
|
+
declare function Card({ size, flush, bare, href, linkAs: LinkComponent, onSelect, selected, disabled, label, className, children, }: CardProps): React.JSX.Element;
|
|
28
|
+
declare const ICON_COLOR: {
|
|
29
|
+
readonly blue: "bg-[var(--primary)]/8 text-[var(--primary)]";
|
|
30
|
+
readonly green: "bg-[var(--success)]/8 text-[var(--success-text)]";
|
|
31
|
+
readonly amber: "bg-[var(--warning)]/10 text-[var(--warning-text)]";
|
|
32
|
+
readonly purple: "bg-[var(--purple)]/8 text-[var(--purple)]";
|
|
33
|
+
};
|
|
34
|
+
type CardHeaderProps = {
|
|
35
|
+
/** The card's name. 16px bold; 14px in a strip or a `sm` card. */
|
|
36
|
+
title: React.ReactNode;
|
|
37
|
+
/** A bare Lucide icon, set in a 36px blue square. */
|
|
38
|
+
icon?: React.ReactNode;
|
|
39
|
+
/** The icon square's color, by topic. */
|
|
40
|
+
iconColor?: keyof typeof ICON_COLOR;
|
|
41
|
+
/** A short explanation in an ⓘ beside the title: what a number counts, what a term means. */
|
|
42
|
+
hint?: string;
|
|
43
|
+
/** Anything else in front of the title: an Avatar, a company logo. Use instead of `icon`. */
|
|
44
|
+
leading?: React.ReactNode;
|
|
45
|
+
/** One muted line under the title. */
|
|
46
|
+
description?: React.ReactNode;
|
|
47
|
+
/** Small things at the top right, before the action: a date, a "New" Tag. */
|
|
48
|
+
meta?: React.ReactNode;
|
|
49
|
+
/** One control on the right: a link button, an IconButton or an ActionMenu. */
|
|
50
|
+
action?: React.ReactNode;
|
|
51
|
+
/** A tinted band across the top of the card, split from the body by a line. For dense cards; never over a table. */
|
|
52
|
+
strip?: boolean;
|
|
53
|
+
/** The title's heading level. Match the page: `h2` under the page title. */
|
|
54
|
+
as?: "h2" | "h3" | "h4";
|
|
55
|
+
/** 14px title, for `sm` cards and rows. */
|
|
56
|
+
compact?: boolean;
|
|
57
|
+
};
|
|
58
|
+
declare function CardHeader({ title, icon, iconColor, hint, leading, description, meta, action, strip, as: Heading, compact }: CardHeaderProps): React.JSX.Element;
|
|
59
|
+
type CardMediaProps = {
|
|
60
|
+
/** The picture. */
|
|
61
|
+
src: string;
|
|
62
|
+
/** What it shows, or "" when it's decoration. */
|
|
63
|
+
alt: string;
|
|
64
|
+
/** Height in pixels. */
|
|
65
|
+
height?: number;
|
|
66
|
+
};
|
|
67
|
+
/** A picture across the top of the card, edge to edge. Put it first. */
|
|
68
|
+
declare function CardMedia({ src, alt, height }: CardMediaProps): React.JSX.Element;
|
|
69
|
+
type CardFooterProps = {
|
|
70
|
+
/** Buttons, lined up on the right, main one last. */
|
|
71
|
+
children: React.ReactNode;
|
|
72
|
+
/** Layout only. */
|
|
73
|
+
className?: string;
|
|
74
|
+
};
|
|
75
|
+
/** A row of buttons under a line, at the bottom of the card. */
|
|
76
|
+
declare function CardFooter({ children, className }: CardFooterProps): React.JSX.Element;
|
|
77
|
+
export { Card, CardFooter, CardHeader, CardMedia, cardVariants };
|
|
78
|
+
export type { CardFooterProps, CardHeaderProps, CardMediaProps, CardProps };
|