@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.
@@ -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';
@@ -1345,11 +1345,11 @@ function OcAccountMenuView({
1345
1345
  "aria-haspopup": "menu",
1346
1346
  "aria-expanded": open,
1347
1347
  "aria-label": `Signed in as ${account.didOc}. Open account menu.`,
1348
- 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",
1349
1349
  "data-oc-account-menu-trigger": "",
1350
1350
  children: [
1351
- /* @__PURE__ */ jsx("span", { className: "bg-primary inline-block size-1.5 rounded-full", "aria-hidden": true }),
1352
- /* @__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 }),
1353
1353
  /* @__PURE__ */ jsx(
1354
1354
  "svg",
1355
1355
  {
@@ -1751,54 +1751,146 @@ function isActive(pathname, link) {
1751
1751
  if (link.href === "/") return pathname === "/";
1752
1752
  return pathname === link.href || pathname.startsWith(link.href + "/");
1753
1753
  }
1754
+ function ExternalGlyph() {
1755
+ return /* @__PURE__ */ jsx("span", { "aria-hidden": true, className: "text-muted-foreground/60 ml-1 text-[9px]", children: "\u2197" });
1756
+ }
1754
1757
  function OcPrimaryNav({
1755
1758
  activePath,
1756
1759
  links,
1757
1760
  className
1758
1761
  }) {
1759
- return /* @__PURE__ */ jsx(
1760
- "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",
1761
1850
  {
1762
- "aria-label": "primary",
1763
- 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 ?? ""),
1764
1853
  "data-oc-primary-nav": "",
1765
- children: links.map((link) => {
1766
- const active = isActive(activePath, link);
1767
- 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");
1768
- const content = /* @__PURE__ */ jsxs(Fragment$1, { children: [
1769
- link.label,
1770
- link.external ? /* @__PURE__ */ jsx(
1771
- "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",
1772
1866
  {
1773
- "aria-hidden": true,
1774
- className: "text-muted-foreground/60 ml-1 text-[9px]",
1775
- 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 })
1776
1876
  }
1777
- ) : null
1778
- ] });
1779
- return link.external ? /* @__PURE__ */ jsx(
1780
- "a",
1781
- {
1782
- href: link.href,
1783
- target: "_blank",
1784
- rel: "noreferrer",
1785
- className: className2,
1786
- "data-oc-primary-nav-item": "",
1787
- children: content
1788
- },
1789
- link.href
1790
- ) : /* @__PURE__ */ jsx(
1791
- Link6,
1792
- {
1793
- href: link.href,
1794
- "aria-current": active ? "page" : void 0,
1795
- className: className2,
1796
- "data-oc-primary-nav-item": active ? "active" : "sibling",
1797
- children: content
1798
- },
1799
- link.href
1800
- );
1801
- })
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
+ ]
1802
1894
  }
1803
1895
  );
1804
1896
  }
@@ -2095,13 +2187,19 @@ function LayoutSubHeader({
2095
2187
  noHeartbeat = false,
2096
2188
  className
2097
2189
  }) {
2098
- 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: [
2099
- /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-3", children: [
2100
- !noHeartbeat && /* @__PURE__ */ jsx("span", { className: "bg-primary inline-block h-1.5 w-1.5 animate-pulse rounded-full" }),
2101
- /* @__PURE__ */ jsx("span", { className: "text-muted-foreground tracking-widest uppercase", children: status }),
2102
- /* @__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 })
2103
2201
  ] }),
2104
- 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)) })
2105
2203
  ] }) });
2106
2204
  }
2107
2205
  function OcAppBar({