@orangecheck/design 0.15.0 → 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';
@@ -1096,11 +1096,11 @@ function OcAccountMenuView({
1096
1096
  "aria-haspopup": "menu",
1097
1097
  "aria-expanded": open,
1098
1098
  "aria-label": `Signed in as ${account.didOc}. Open account menu.`,
1099
- 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",
1100
1100
  "data-oc-account-menu-trigger": "",
1101
1101
  children: [
1102
- /* @__PURE__ */ jsx("span", { className: "bg-primary inline-block size-1.5 rounded-full", "aria-hidden": true }),
1103
- /* @__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 }),
1104
1104
  /* @__PURE__ */ jsx(
1105
1105
  "svg",
1106
1106
  {
@@ -1502,54 +1502,146 @@ function isActive(pathname, link) {
1502
1502
  if (link.href === "/") return pathname === "/";
1503
1503
  return pathname === link.href || pathname.startsWith(link.href + "/");
1504
1504
  }
1505
+ function ExternalGlyph() {
1506
+ return /* @__PURE__ */ jsx("span", { "aria-hidden": true, className: "text-muted-foreground/60 ml-1 text-[9px]", children: "\u2197" });
1507
+ }
1505
1508
  function OcPrimaryNav({
1506
1509
  activePath,
1507
1510
  links,
1508
1511
  className
1509
1512
  }) {
1510
- return /* @__PURE__ */ jsx(
1511
- "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",
1512
1601
  {
1513
- "aria-label": "primary",
1514
- 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 ?? ""),
1515
1604
  "data-oc-primary-nav": "",
1516
- children: links.map((link) => {
1517
- const active = isActive(activePath, link);
1518
- 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");
1519
- const content = /* @__PURE__ */ jsxs(Fragment, { children: [
1520
- link.label,
1521
- link.external ? /* @__PURE__ */ jsx(
1522
- "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",
1523
1617
  {
1524
- "aria-hidden": true,
1525
- className: "text-muted-foreground/60 ml-1 text-[9px]",
1526
- 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 })
1527
1627
  }
1528
- ) : null
1529
- ] });
1530
- return link.external ? /* @__PURE__ */ jsx(
1531
- "a",
1532
- {
1533
- href: link.href,
1534
- target: "_blank",
1535
- rel: "noreferrer",
1536
- className: className2,
1537
- "data-oc-primary-nav-item": "",
1538
- children: content
1539
- },
1540
- link.href
1541
- ) : /* @__PURE__ */ jsx(
1542
- Link5,
1543
- {
1544
- href: link.href,
1545
- "aria-current": active ? "page" : void 0,
1546
- className: className2,
1547
- "data-oc-primary-nav-item": active ? "active" : "sibling",
1548
- children: content
1549
- },
1550
- link.href
1551
- );
1552
- })
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
+ ]
1553
1645
  }
1554
1646
  );
1555
1647
  }
@@ -1846,13 +1938,19 @@ function LayoutSubHeader({
1846
1938
  noHeartbeat = false,
1847
1939
  className
1848
1940
  }) {
1849
- 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: [
1850
- /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-3", children: [
1851
- !noHeartbeat && /* @__PURE__ */ jsx("span", { className: "bg-primary inline-block h-1.5 w-1.5 animate-pulse rounded-full" }),
1852
- /* @__PURE__ */ jsx("span", { className: "text-muted-foreground tracking-widest uppercase", children: status }),
1853
- /* @__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 })
1854
1952
  ] }),
1855
- 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)) })
1856
1954
  ] }) });
1857
1955
  }
1858
1956
  function OcAppBar({