@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.
package/dist/chrome.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import { Boxes, ChevronDown, Check, CornerDownLeft, Plus, Loader2, Copy } from 'lucide-react';
1
+ import { Boxes, ChevronDown, Check, CornerDownLeft, Plus, Loader2, X, Menu, Copy } from 'lucide-react';
2
2
  import Link5 from 'next/link';
3
3
  import * as React from 'react';
4
4
  import { useState, useRef, useEffect, useId } from 'react';
@@ -992,7 +992,11 @@ function OcAccountMenu(props) {
992
992
  // context (oc-www) can opt in incrementally.
993
993
  roster: session.roster,
994
994
  switchAccount: session.switchAccount,
995
- addAccountUrl: session.addAccountUrl
995
+ addAccountUrl: session.addAccountUrl,
996
+ // Structural read keeps the auth-client peer floor at
997
+ // ^2.17.0 — `tabPinned` ships in 2.18.0 and is simply
998
+ // undefined (no hint) on older providers.
999
+ tabPinned: session.tabPinned
996
1000
  }
997
1001
  }
998
1002
  );
@@ -1021,7 +1025,8 @@ function OcAccountMenuView({
1021
1025
  setDisplayIdentity,
1022
1026
  roster,
1023
1027
  switchAccount,
1024
- addAccountUrl
1028
+ addAccountUrl,
1029
+ tabPinned
1025
1030
  } = session;
1026
1031
  const [hydrated, setHydrated] = useState(false);
1027
1032
  const [open, setOpen] = useState(false);
@@ -1091,11 +1096,11 @@ function OcAccountMenuView({
1091
1096
  "aria-haspopup": "menu",
1092
1097
  "aria-expanded": open,
1093
1098
  "aria-label": `Signed in as ${account.didOc}. Open account menu.`,
1094
- 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",
1099
+ 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",
1095
1100
  "data-oc-account-menu-trigger": "",
1096
1101
  children: [
1097
- /* @__PURE__ */ jsx("span", { className: "bg-primary inline-block size-1.5 rounded-full", "aria-hidden": true }),
1098
- /* @__PURE__ */ jsx("span", { className: "text-foreground", children: label }),
1102
+ /* @__PURE__ */ jsx("span", { className: "bg-primary inline-block size-1.5 shrink-0 rounded-full", "aria-hidden": true }),
1103
+ /* @__PURE__ */ jsx("span", { className: "text-foreground hidden max-w-[16ch] truncate sm:inline", children: label }),
1099
1104
  /* @__PURE__ */ jsx(
1100
1105
  "svg",
1101
1106
  {
@@ -1130,7 +1135,19 @@ function OcAccountMenuView({
1130
1135
  /* @__PURE__ */ jsxs("div", { className: "border-border border-b p-3", children: [
1131
1136
  /* @__PURE__ */ jsxs("div", { className: "text-primary mb-1 font-mono text-[10px] tracking-widest uppercase", children: [
1132
1137
  "\xA7 signed in \xB7 ",
1133
- hostname
1138
+ hostname,
1139
+ tabPinned ? /* @__PURE__ */ jsxs(
1140
+ "span",
1141
+ {
1142
+ className: "text-muted-foreground/70 normal-case",
1143
+ "data-oc-account-menu-tab-pin": "",
1144
+ title: "This tab keeps this account even if you switch accounts in another tab",
1145
+ children: [
1146
+ " ",
1147
+ "\xB7 this tab"
1148
+ ]
1149
+ }
1150
+ ) : null
1134
1151
  ] }),
1135
1152
  /* @__PURE__ */ jsx(CopyableDid, { did: account.didOc }),
1136
1153
  displayName ? /* @__PURE__ */ jsx("div", { className: "text-muted-foreground/80 mt-1 font-mono text-[10px] tracking-wide", children: displayName }) : null
@@ -1485,54 +1502,146 @@ function isActive(pathname, link) {
1485
1502
  if (link.href === "/") return pathname === "/";
1486
1503
  return pathname === link.href || pathname.startsWith(link.href + "/");
1487
1504
  }
1505
+ function ExternalGlyph() {
1506
+ return /* @__PURE__ */ jsx("span", { "aria-hidden": true, className: "text-muted-foreground/60 ml-1 text-[9px]", children: "\u2197" });
1507
+ }
1488
1508
  function OcPrimaryNav({
1489
1509
  activePath,
1490
1510
  links,
1491
1511
  className
1492
1512
  }) {
1493
- return /* @__PURE__ */ jsx(
1494
- "nav",
1513
+ const [open, setOpen] = useState(false);
1514
+ const ref = useRef(null);
1515
+ const menuId = useId();
1516
+ useEffect(() => {
1517
+ setOpen(false);
1518
+ }, [activePath]);
1519
+ useEffect(() => {
1520
+ if (!open) return;
1521
+ const onClick = (e) => {
1522
+ if (ref.current && !ref.current.contains(e.target)) setOpen(false);
1523
+ };
1524
+ const onKey = (e) => {
1525
+ if (e.key === "Escape") setOpen(false);
1526
+ };
1527
+ document.addEventListener("mousedown", onClick);
1528
+ document.addEventListener("keydown", onKey);
1529
+ return () => {
1530
+ document.removeEventListener("mousedown", onClick);
1531
+ document.removeEventListener("keydown", onKey);
1532
+ };
1533
+ }, [open]);
1534
+ 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");
1535
+ 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");
1536
+ function renderInline(link) {
1537
+ const active = isActive(activePath, link);
1538
+ const inner = /* @__PURE__ */ jsxs(Fragment, { children: [
1539
+ link.label,
1540
+ link.external ? /* @__PURE__ */ jsx(ExternalGlyph, {}) : null
1541
+ ] });
1542
+ return link.external ? /* @__PURE__ */ jsx(
1543
+ "a",
1544
+ {
1545
+ href: link.href,
1546
+ target: "_blank",
1547
+ rel: "noreferrer",
1548
+ className: inlineClass(false),
1549
+ "data-oc-primary-nav-item": "",
1550
+ children: inner
1551
+ },
1552
+ link.href
1553
+ ) : /* @__PURE__ */ jsx(
1554
+ Link5,
1555
+ {
1556
+ href: link.href,
1557
+ "aria-current": active ? "page" : void 0,
1558
+ className: inlineClass(active),
1559
+ "data-oc-primary-nav-item": active ? "active" : "sibling",
1560
+ children: inner
1561
+ },
1562
+ link.href
1563
+ );
1564
+ }
1565
+ function renderRow(link) {
1566
+ const active = isActive(activePath, link);
1567
+ const inner = /* @__PURE__ */ jsxs(Fragment, { children: [
1568
+ /* @__PURE__ */ jsx("span", { className: "text-muted-foreground", "aria-hidden": true, children: "\u2192" }),
1569
+ /* @__PURE__ */ jsx("span", { className: "flex-1", children: link.label }),
1570
+ link.external ? /* @__PURE__ */ jsx(ExternalGlyph, {}) : null
1571
+ ] });
1572
+ return link.external ? /* @__PURE__ */ jsx(
1573
+ "a",
1574
+ {
1575
+ href: link.href,
1576
+ target: "_blank",
1577
+ rel: "noreferrer",
1578
+ role: "menuitem",
1579
+ onClick: () => setOpen(false),
1580
+ className: rowClass(false),
1581
+ "data-oc-primary-nav-item": "",
1582
+ children: inner
1583
+ },
1584
+ link.href
1585
+ ) : /* @__PURE__ */ jsx(
1586
+ Link5,
1587
+ {
1588
+ href: link.href,
1589
+ role: "menuitem",
1590
+ "aria-current": active ? "page" : void 0,
1591
+ onClick: () => setOpen(false),
1592
+ className: rowClass(active),
1593
+ "data-oc-primary-nav-item": active ? "active" : "sibling",
1594
+ children: inner
1595
+ },
1596
+ link.href
1597
+ );
1598
+ }
1599
+ return /* @__PURE__ */ jsxs(
1600
+ "div",
1495
1601
  {
1496
- "aria-label": "primary",
1497
- 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 ?? ""),
1602
+ ref,
1603
+ className: "relative flex items-center justify-center " + (className ?? ""),
1498
1604
  "data-oc-primary-nav": "",
1499
- children: links.map((link) => {
1500
- const active = isActive(activePath, link);
1501
- 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");
1502
- const content = /* @__PURE__ */ jsxs(Fragment, { children: [
1503
- link.label,
1504
- link.external ? /* @__PURE__ */ jsx(
1505
- "span",
1605
+ children: [
1606
+ /* @__PURE__ */ jsx(
1607
+ "nav",
1608
+ {
1609
+ "aria-label": "primary",
1610
+ className: "hidden items-center gap-0.5 sm:gap-1 md:flex",
1611
+ children: links.map(renderInline)
1612
+ }
1613
+ ),
1614
+ /* @__PURE__ */ jsxs("div", { className: "md:hidden", children: [
1615
+ /* @__PURE__ */ jsx(
1616
+ "button",
1506
1617
  {
1507
- "aria-hidden": true,
1508
- className: "text-muted-foreground/60 ml-1 text-[9px]",
1509
- children: "\u2197"
1618
+ type: "button",
1619
+ onClick: () => setOpen((v) => !v),
1620
+ "aria-haspopup": "menu",
1621
+ "aria-expanded": open,
1622
+ "aria-controls": menuId,
1623
+ "aria-label": "site navigation",
1624
+ className: "border-input bg-background hover:bg-accent text-muted-foreground inline-flex size-8 items-center justify-center rounded-md border transition-colors",
1625
+ "data-oc-primary-nav-toggle": "",
1626
+ children: open ? /* @__PURE__ */ jsx(X, { className: "size-4", "aria-hidden": true }) : /* @__PURE__ */ jsx(Menu, { className: "size-4", "aria-hidden": true })
1510
1627
  }
1511
- ) : null
1512
- ] });
1513
- return link.external ? /* @__PURE__ */ jsx(
1514
- "a",
1515
- {
1516
- href: link.href,
1517
- target: "_blank",
1518
- rel: "noreferrer",
1519
- className: className2,
1520
- "data-oc-primary-nav-item": "",
1521
- children: content
1522
- },
1523
- link.href
1524
- ) : /* @__PURE__ */ jsx(
1525
- Link5,
1526
- {
1527
- href: link.href,
1528
- "aria-current": active ? "page" : void 0,
1529
- className: className2,
1530
- "data-oc-primary-nav-item": active ? "active" : "sibling",
1531
- children: content
1532
- },
1533
- link.href
1534
- );
1535
- })
1628
+ ),
1629
+ open && /* @__PURE__ */ jsxs(
1630
+ "div",
1631
+ {
1632
+ id: menuId,
1633
+ role: "menu",
1634
+ "aria-label": "primary",
1635
+ 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",
1636
+ "data-oc-primary-nav-popover": "",
1637
+ children: [
1638
+ /* @__PURE__ */ jsx("div", { className: "text-muted-foreground/60 px-3 pt-2 pb-1 font-mono text-[10px] tracking-widest uppercase", children: "\xA7 navigate" }),
1639
+ links.map(renderRow)
1640
+ ]
1641
+ }
1642
+ )
1643
+ ] })
1644
+ ]
1536
1645
  }
1537
1646
  );
1538
1647
  }
@@ -1829,13 +1938,19 @@ function LayoutSubHeader({
1829
1938
  noHeartbeat = false,
1830
1939
  className
1831
1940
  }) {
1832
- 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: [
1833
- /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-3", children: [
1834
- !noHeartbeat && /* @__PURE__ */ jsx("span", { className: "bg-primary inline-block h-1.5 w-1.5 animate-pulse rounded-full" }),
1835
- /* @__PURE__ */ jsx("span", { className: "text-muted-foreground tracking-widest uppercase", children: status }),
1836
- /* @__PURE__ */ jsx("span", { className: "text-foreground", children: product })
1941
+ 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: [
1942
+ /* @__PURE__ */ jsxs("div", { className: "flex min-w-0 items-center gap-2.5", children: [
1943
+ !noHeartbeat && /* @__PURE__ */ jsx(
1944
+ "span",
1945
+ {
1946
+ 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%)]",
1947
+ "aria-hidden": true
1948
+ }
1949
+ ),
1950
+ /* @__PURE__ */ jsx("span", { className: "text-muted-foreground hidden tracking-widest whitespace-nowrap uppercase sm:inline", children: status }),
1951
+ /* @__PURE__ */ jsx("span", { className: "text-foreground truncate", children: product })
1837
1952
  ] }),
1838
- 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)) })
1953
+ 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)) })
1839
1954
  ] }) });
1840
1955
  }
1841
1956
  function OcAppBar({