@orangecheck/design 0.14.1 → 0.16.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.
@@ -1,5 +1,5 @@
1
1
  import * as Popover from '@radix-ui/react-popover';
2
- import { HelpCircle, Boxes, ChevronDown, Check, CornerDownLeft, Plus, Loader2, Copy } from 'lucide-react';
2
+ import { HelpCircle, Boxes, ChevronDown, Check, CornerDownLeft, Plus, Loader2, X, Menu, Copy } from 'lucide-react';
3
3
  import { clsx } from 'clsx';
4
4
  import { twMerge } from 'tailwind-merge';
5
5
  import { jsxs, jsx, Fragment as Fragment$1 } from 'react/jsx-runtime';
@@ -1241,7 +1241,11 @@ function OcAccountMenu(props) {
1241
1241
  // context (oc-www) can opt in incrementally.
1242
1242
  roster: session.roster,
1243
1243
  switchAccount: session.switchAccount,
1244
- addAccountUrl: session.addAccountUrl
1244
+ addAccountUrl: session.addAccountUrl,
1245
+ // Structural read keeps the auth-client peer floor at
1246
+ // ^2.17.0 — `tabPinned` ships in 2.18.0 and is simply
1247
+ // undefined (no hint) on older providers.
1248
+ tabPinned: session.tabPinned
1245
1249
  }
1246
1250
  }
1247
1251
  );
@@ -1270,7 +1274,8 @@ function OcAccountMenuView({
1270
1274
  setDisplayIdentity,
1271
1275
  roster,
1272
1276
  switchAccount,
1273
- addAccountUrl
1277
+ addAccountUrl,
1278
+ tabPinned
1274
1279
  } = session;
1275
1280
  const [hydrated, setHydrated] = useState(false);
1276
1281
  const [open, setOpen] = useState(false);
@@ -1340,11 +1345,11 @@ function OcAccountMenuView({
1340
1345
  "aria-haspopup": "menu",
1341
1346
  "aria-expanded": open,
1342
1347
  "aria-label": `Signed in as ${account.didOc}. Open account menu.`,
1343
- className: triggerClassName ?? "border-primary/40 bg-card hover:bg-accent inline-flex h-8 items-center gap-1.5 rounded-md border px-3 font-mono text-[11px] tracking-wide transition-colors",
1348
+ className: triggerClassName ?? "border-primary/40 bg-card hover:bg-accent inline-flex h-8 items-center gap-1.5 rounded-md border px-2 font-mono text-[11px] tracking-wide transition-colors sm:px-3",
1344
1349
  "data-oc-account-menu-trigger": "",
1345
1350
  children: [
1346
- /* @__PURE__ */ jsx("span", { className: "bg-primary inline-block size-1.5 rounded-full", "aria-hidden": true }),
1347
- /* @__PURE__ */ jsx("span", { className: "text-foreground", children: label }),
1351
+ /* @__PURE__ */ jsx("span", { className: "bg-primary inline-block size-1.5 shrink-0 rounded-full", "aria-hidden": true }),
1352
+ /* @__PURE__ */ jsx("span", { className: "text-foreground hidden max-w-[16ch] truncate sm:inline", children: label }),
1348
1353
  /* @__PURE__ */ jsx(
1349
1354
  "svg",
1350
1355
  {
@@ -1379,7 +1384,19 @@ function OcAccountMenuView({
1379
1384
  /* @__PURE__ */ jsxs("div", { className: "border-border border-b p-3", children: [
1380
1385
  /* @__PURE__ */ jsxs("div", { className: "text-primary mb-1 font-mono text-[10px] tracking-widest uppercase", children: [
1381
1386
  "\xA7 signed in \xB7 ",
1382
- hostname
1387
+ hostname,
1388
+ tabPinned ? /* @__PURE__ */ jsxs(
1389
+ "span",
1390
+ {
1391
+ className: "text-muted-foreground/70 normal-case",
1392
+ "data-oc-account-menu-tab-pin": "",
1393
+ title: "This tab keeps this account even if you switch accounts in another tab",
1394
+ children: [
1395
+ " ",
1396
+ "\xB7 this tab"
1397
+ ]
1398
+ }
1399
+ ) : null
1383
1400
  ] }),
1384
1401
  /* @__PURE__ */ jsx(CopyableDid, { did: account.didOc }),
1385
1402
  displayName ? /* @__PURE__ */ jsx("div", { className: "text-muted-foreground/80 mt-1 font-mono text-[10px] tracking-wide", children: displayName }) : null
@@ -1734,54 +1751,146 @@ function isActive(pathname, link) {
1734
1751
  if (link.href === "/") return pathname === "/";
1735
1752
  return pathname === link.href || pathname.startsWith(link.href + "/");
1736
1753
  }
1754
+ function ExternalGlyph() {
1755
+ return /* @__PURE__ */ jsx("span", { "aria-hidden": true, className: "text-muted-foreground/60 ml-1 text-[9px]", children: "\u2197" });
1756
+ }
1737
1757
  function OcPrimaryNav({
1738
1758
  activePath,
1739
1759
  links,
1740
1760
  className
1741
1761
  }) {
1742
- return /* @__PURE__ */ jsx(
1743
- "nav",
1762
+ const [open, setOpen] = useState(false);
1763
+ const ref = useRef(null);
1764
+ const menuId = useId();
1765
+ useEffect(() => {
1766
+ setOpen(false);
1767
+ }, [activePath]);
1768
+ useEffect(() => {
1769
+ if (!open) return;
1770
+ const onClick = (e) => {
1771
+ if (ref.current && !ref.current.contains(e.target)) setOpen(false);
1772
+ };
1773
+ const onKey = (e) => {
1774
+ if (e.key === "Escape") setOpen(false);
1775
+ };
1776
+ document.addEventListener("mousedown", onClick);
1777
+ document.addEventListener("keydown", onKey);
1778
+ return () => {
1779
+ document.removeEventListener("mousedown", onClick);
1780
+ document.removeEventListener("keydown", onKey);
1781
+ };
1782
+ }, [open]);
1783
+ const inlineClass = (active) => "font-display shrink-0 px-2 py-1 sm:px-3 text-[11px] sm:text-[12px] font-semibold tracking-wider uppercase transition-colors " + (active ? "text-primary" : "text-muted-foreground hover:text-foreground");
1784
+ const rowClass = (active) => "font-display flex items-center gap-2 px-3 py-2 text-[12px] font-semibold tracking-wider uppercase transition-colors " + (active ? "text-primary" : "text-muted-foreground hover:text-foreground hover:bg-accent");
1785
+ function renderInline(link) {
1786
+ const active = isActive(activePath, link);
1787
+ const inner = /* @__PURE__ */ jsxs(Fragment$1, { children: [
1788
+ link.label,
1789
+ link.external ? /* @__PURE__ */ jsx(ExternalGlyph, {}) : null
1790
+ ] });
1791
+ return link.external ? /* @__PURE__ */ jsx(
1792
+ "a",
1793
+ {
1794
+ href: link.href,
1795
+ target: "_blank",
1796
+ rel: "noreferrer",
1797
+ className: inlineClass(false),
1798
+ "data-oc-primary-nav-item": "",
1799
+ children: inner
1800
+ },
1801
+ link.href
1802
+ ) : /* @__PURE__ */ jsx(
1803
+ Link6,
1804
+ {
1805
+ href: link.href,
1806
+ "aria-current": active ? "page" : void 0,
1807
+ className: inlineClass(active),
1808
+ "data-oc-primary-nav-item": active ? "active" : "sibling",
1809
+ children: inner
1810
+ },
1811
+ link.href
1812
+ );
1813
+ }
1814
+ function renderRow(link) {
1815
+ const active = isActive(activePath, link);
1816
+ const inner = /* @__PURE__ */ jsxs(Fragment$1, { children: [
1817
+ /* @__PURE__ */ jsx("span", { className: "text-muted-foreground", "aria-hidden": true, children: "\u2192" }),
1818
+ /* @__PURE__ */ jsx("span", { className: "flex-1", children: link.label }),
1819
+ link.external ? /* @__PURE__ */ jsx(ExternalGlyph, {}) : null
1820
+ ] });
1821
+ return link.external ? /* @__PURE__ */ jsx(
1822
+ "a",
1823
+ {
1824
+ href: link.href,
1825
+ target: "_blank",
1826
+ rel: "noreferrer",
1827
+ role: "menuitem",
1828
+ onClick: () => setOpen(false),
1829
+ className: rowClass(false),
1830
+ "data-oc-primary-nav-item": "",
1831
+ children: inner
1832
+ },
1833
+ link.href
1834
+ ) : /* @__PURE__ */ jsx(
1835
+ Link6,
1836
+ {
1837
+ href: link.href,
1838
+ role: "menuitem",
1839
+ "aria-current": active ? "page" : void 0,
1840
+ onClick: () => setOpen(false),
1841
+ className: rowClass(active),
1842
+ "data-oc-primary-nav-item": active ? "active" : "sibling",
1843
+ children: inner
1844
+ },
1845
+ link.href
1846
+ );
1847
+ }
1848
+ return /* @__PURE__ */ jsxs(
1849
+ "div",
1744
1850
  {
1745
- "aria-label": "primary",
1746
- className: "flex min-w-0 items-center justify-start overflow-x-auto gap-0.5 sm:gap-1 whitespace-nowrap [scrollbar-width:none] [&::-webkit-scrollbar]:hidden " + (className ?? ""),
1851
+ ref,
1852
+ className: "relative flex items-center justify-center " + (className ?? ""),
1747
1853
  "data-oc-primary-nav": "",
1748
- children: links.map((link) => {
1749
- const active = isActive(activePath, link);
1750
- const className2 = "font-display shrink-0 px-2 py-1 sm:px-3 text-[11px] sm:text-[12px] font-semibold tracking-wider uppercase transition-colors " + (active ? "text-primary" : "text-muted-foreground hover:text-foreground");
1751
- const content = /* @__PURE__ */ jsxs(Fragment$1, { children: [
1752
- link.label,
1753
- link.external ? /* @__PURE__ */ jsx(
1754
- "span",
1854
+ children: [
1855
+ /* @__PURE__ */ jsx(
1856
+ "nav",
1857
+ {
1858
+ "aria-label": "primary",
1859
+ className: "hidden items-center gap-0.5 sm:gap-1 md:flex",
1860
+ children: links.map(renderInline)
1861
+ }
1862
+ ),
1863
+ /* @__PURE__ */ jsxs("div", { className: "md:hidden", children: [
1864
+ /* @__PURE__ */ jsx(
1865
+ "button",
1755
1866
  {
1756
- "aria-hidden": true,
1757
- className: "text-muted-foreground/60 ml-1 text-[9px]",
1758
- children: "\u2197"
1867
+ type: "button",
1868
+ onClick: () => setOpen((v) => !v),
1869
+ "aria-haspopup": "menu",
1870
+ "aria-expanded": open,
1871
+ "aria-controls": menuId,
1872
+ "aria-label": "site navigation",
1873
+ className: "border-input bg-background hover:bg-accent text-muted-foreground inline-flex size-8 items-center justify-center rounded-md border transition-colors",
1874
+ "data-oc-primary-nav-toggle": "",
1875
+ children: open ? /* @__PURE__ */ jsx(X, { className: "size-4", "aria-hidden": true }) : /* @__PURE__ */ jsx(Menu, { className: "size-4", "aria-hidden": true })
1759
1876
  }
1760
- ) : null
1761
- ] });
1762
- return link.external ? /* @__PURE__ */ jsx(
1763
- "a",
1764
- {
1765
- href: link.href,
1766
- target: "_blank",
1767
- rel: "noreferrer",
1768
- className: className2,
1769
- "data-oc-primary-nav-item": "",
1770
- children: content
1771
- },
1772
- link.href
1773
- ) : /* @__PURE__ */ jsx(
1774
- Link6,
1775
- {
1776
- href: link.href,
1777
- "aria-current": active ? "page" : void 0,
1778
- className: className2,
1779
- "data-oc-primary-nav-item": active ? "active" : "sibling",
1780
- children: content
1781
- },
1782
- link.href
1783
- );
1784
- })
1877
+ ),
1878
+ open && /* @__PURE__ */ jsxs(
1879
+ "div",
1880
+ {
1881
+ id: menuId,
1882
+ role: "menu",
1883
+ "aria-label": "primary",
1884
+ className: "border-border bg-popover text-popover-foreground absolute top-[calc(100%+8px)] left-1/2 z-50 w-[min(15rem,calc(100vw-1rem))] -translate-x-1/2 border p-1 shadow-xl",
1885
+ "data-oc-primary-nav-popover": "",
1886
+ children: [
1887
+ /* @__PURE__ */ jsx("div", { className: "text-muted-foreground/60 px-3 pt-2 pb-1 font-mono text-[10px] tracking-widest uppercase", children: "\xA7 navigate" }),
1888
+ links.map(renderRow)
1889
+ ]
1890
+ }
1891
+ )
1892
+ ] })
1893
+ ]
1785
1894
  }
1786
1895
  );
1787
1896
  }
@@ -2078,13 +2187,19 @@ function LayoutSubHeader({
2078
2187
  noHeartbeat = false,
2079
2188
  className
2080
2189
  }) {
2081
- return /* @__PURE__ */ jsx("div", { className: cn("border-b", className), children: /* @__PURE__ */ jsxs("div", { className: "container flex flex-wrap items-center justify-between gap-x-6 gap-y-1 py-2 font-mono text-[11px]", children: [
2082
- /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-3", children: [
2083
- !noHeartbeat && /* @__PURE__ */ jsx("span", { className: "bg-primary inline-block h-1.5 w-1.5 animate-pulse rounded-full" }),
2084
- /* @__PURE__ */ jsx("span", { className: "text-muted-foreground tracking-widest uppercase", children: status }),
2085
- /* @__PURE__ */ jsx("span", { className: "text-foreground", children: product })
2190
+ return /* @__PURE__ */ jsx("div", { className: cn("oc-substrip border-b", className), children: /* @__PURE__ */ jsxs("div", { className: "container flex items-center justify-between gap-x-6 py-2 font-mono text-[11px]", children: [
2191
+ /* @__PURE__ */ jsxs("div", { className: "flex min-w-0 items-center gap-2.5", children: [
2192
+ !noHeartbeat && /* @__PURE__ */ jsx(
2193
+ "span",
2194
+ {
2195
+ className: "bg-primary inline-block size-1.5 shrink-0 animate-pulse rounded-full ring-2 ring-[color-mix(in_oklch,var(--primary),transparent_78%)]",
2196
+ "aria-hidden": true
2197
+ }
2198
+ ),
2199
+ /* @__PURE__ */ jsx("span", { className: "text-muted-foreground hidden tracking-widest whitespace-nowrap uppercase sm:inline", children: status }),
2200
+ /* @__PURE__ */ jsx("span", { className: "text-foreground truncate", children: product })
2086
2201
  ] }),
2087
- tags.length > 0 && /* @__PURE__ */ jsx("div", { className: "text-muted-foreground flex flex-wrap items-center gap-x-4 gap-y-1 tracking-widest uppercase", children: tags.map((tag, i) => /* @__PURE__ */ jsx("span", { className: tag.hideBelow ? HIDE[tag.hideBelow] : void 0, children: tag.label }, i)) })
2202
+ tags.length > 0 && /* @__PURE__ */ jsx("div", { className: "text-muted-foreground/55 hidden shrink-0 items-center gap-x-3 tracking-wider whitespace-nowrap uppercase sm:flex", children: tags.map((tag, i) => /* @__PURE__ */ jsx("span", { className: tag.hideBelow ? HIDE[tag.hideBelow] : void 0, children: tag.label }, i)) })
2088
2203
  ] }) });
2089
2204
  }
2090
2205
  function OcAppBar({