@designa8/vibedesign-openai-internal-v1-2-176b 0.0.2 → 0.0.3
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/README.md +1 -1
- package/dist/index.cjs +168 -55
- package/dist/index.js +168 -55
- package/dist/styles.css +12 -0
- package/package.json +1 -1
- package/src/atoms/Sidebar/preview.tsx +90 -7
- package/src/atoms/SidebarDesktop/SidebarDesktop.tsx +125 -29
- package/src/atoms/SidebarMobile/SidebarMobile.tsx +112 -33
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# @designa8/vibedesign-openai-internal-v1-2-176b
|
|
2
2
|
|
|
3
|
-
Complete design system generated by Atoms Design, version **0.0.
|
|
3
|
+
Complete design system generated by Atoms Design, version **0.0.3**.
|
|
4
4
|
Tokens, atoms, molecules, organisms, and templates — import from the package root;
|
|
5
5
|
never hardcode visual values in consumer code.
|
|
6
6
|
|
package/dist/index.cjs
CHANGED
|
@@ -7588,6 +7588,7 @@ var defaultSidebarPromo = {
|
|
|
7588
7588
|
icon: "zap"
|
|
7589
7589
|
};
|
|
7590
7590
|
var focusRing2 = "focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-focus-blue";
|
|
7591
|
+
var countLabel = (count) => count > 9 ? "9+" : String(count);
|
|
7591
7592
|
var SidebarDesktop = React72.forwardRef(
|
|
7592
7593
|
({
|
|
7593
7594
|
brandName = "AI Platform",
|
|
@@ -7598,8 +7599,12 @@ var SidebarDesktop = React72.forwardRef(
|
|
|
7598
7599
|
sections = defaultSidebarSections,
|
|
7599
7600
|
promo = defaultSidebarPromo,
|
|
7600
7601
|
userName = "Alex Smith",
|
|
7602
|
+
userAvatarSrc,
|
|
7603
|
+
onUserClick,
|
|
7604
|
+
notificationCount = 0,
|
|
7601
7605
|
onSettingsClick,
|
|
7602
7606
|
onNotificationsClick,
|
|
7607
|
+
onNavigate,
|
|
7603
7608
|
folded: foldedProp,
|
|
7604
7609
|
defaultFolded = false,
|
|
7605
7610
|
onFoldedChange,
|
|
@@ -7616,6 +7621,9 @@ var SidebarDesktop = React72.forwardRef(
|
|
|
7616
7621
|
onFoldedChange?.(v);
|
|
7617
7622
|
};
|
|
7618
7623
|
const currentOrg = organizations.find((o) => o.value === org);
|
|
7624
|
+
const unread = notificationCount > 0;
|
|
7625
|
+
const bellLabel = unread ? `Notifications, ${notificationCount} unread` : "Notifications";
|
|
7626
|
+
const promoItem = promo ? { label: promo.title, icon: promo.icon ?? "zap", href: promo.href } : null;
|
|
7619
7627
|
return /* @__PURE__ */ (0, import_jsx_runtime72.jsxs)(
|
|
7620
7628
|
"aside",
|
|
7621
7629
|
{
|
|
@@ -7668,25 +7676,36 @@ var SidebarDesktop = React72.forwardRef(
|
|
|
7668
7676
|
) }),
|
|
7669
7677
|
/* @__PURE__ */ (0, import_jsx_runtime72.jsx)("nav", { id: navId, "aria-label": "Main", className: "min-h-0 flex-1 overflow-y-auto overscroll-contain pb-sm", children: sections.map((section, si) => /* @__PURE__ */ (0, import_jsx_runtime72.jsxs)("div", { className: cn63("flex flex-col gap-xxs", si > 0 && "mt-base"), children: [
|
|
7670
7678
|
section.label ? folded ? /* @__PURE__ */ (0, import_jsx_runtime72.jsx)("span", { className: "sr-only", children: section.label }) : /* @__PURE__ */ (0, import_jsx_runtime72.jsx)("span", { className: "px-base pb-xxs text-caption text-muted", children: section.label }) : null,
|
|
7671
|
-
/* @__PURE__ */ (0, import_jsx_runtime72.jsx)("ul", { className: cn63("flex flex-col gap-xxs", folded ? "items-center" : "px-sm"), children: section.items.map((item) =>
|
|
7672
|
-
"
|
|
7673
|
-
{
|
|
7674
|
-
|
|
7675
|
-
|
|
7676
|
-
|
|
7677
|
-
|
|
7678
|
-
|
|
7679
|
-
|
|
7680
|
-
|
|
7681
|
-
|
|
7682
|
-
|
|
7683
|
-
|
|
7684
|
-
|
|
7685
|
-
|
|
7686
|
-
|
|
7687
|
-
|
|
7688
|
-
|
|
7689
|
-
|
|
7679
|
+
/* @__PURE__ */ (0, import_jsx_runtime72.jsx)("ul", { className: cn63("flex flex-col gap-xxs", folded ? "items-center" : "px-sm"), children: section.items.map((item) => {
|
|
7680
|
+
const hasBadge = item.badge !== void 0 && item.badge !== null && item.badge !== "";
|
|
7681
|
+
return /* @__PURE__ */ (0, import_jsx_runtime72.jsx)("li", { className: folded ? void 0 : "w-full", children: /* @__PURE__ */ (0, import_jsx_runtime72.jsxs)(
|
|
7682
|
+
"a",
|
|
7683
|
+
{
|
|
7684
|
+
href: item.href,
|
|
7685
|
+
"aria-current": item.active ? "page" : void 0,
|
|
7686
|
+
"aria-label": folded ? item.label : void 0,
|
|
7687
|
+
title: folded ? item.label : void 0,
|
|
7688
|
+
onClick: onNavigate ? (event) => onNavigate(item, event) : void 0,
|
|
7689
|
+
className: cn63(
|
|
7690
|
+
"flex cursor-pointer items-center rounded-sm text-body-md transition-colors duration-150 ease-out",
|
|
7691
|
+
focusRing2,
|
|
7692
|
+
folded ? "relative size-9 justify-center" : "h-9 w-full gap-sm px-sm",
|
|
7693
|
+
item.active ? "bg-surface-strong text-ink" : "text-ink hover:bg-surface-soft active:bg-surface-strong"
|
|
7694
|
+
),
|
|
7695
|
+
children: [
|
|
7696
|
+
/* @__PURE__ */ (0, import_jsx_runtime72.jsx)(Icon, { name: item.icon, size: 18, className: "text-body" }),
|
|
7697
|
+
folded ? null : /* @__PURE__ */ (0, import_jsx_runtime72.jsx)("span", { className: hasBadge ? "min-w-0 flex-1 truncate" : "truncate", children: item.label }),
|
|
7698
|
+
hasBadge ? folded ? /* @__PURE__ */ (0, import_jsx_runtime72.jsx)(
|
|
7699
|
+
"span",
|
|
7700
|
+
{
|
|
7701
|
+
"aria-hidden": "true",
|
|
7702
|
+
className: "absolute right-xs top-xs h-2 w-2 rounded-full bg-primary"
|
|
7703
|
+
}
|
|
7704
|
+
) : /* @__PURE__ */ (0, import_jsx_runtime72.jsx)(Badge, { size: "sm", className: "ml-auto", children: item.badge }) : null
|
|
7705
|
+
]
|
|
7706
|
+
}
|
|
7707
|
+
) }, item.label);
|
|
7708
|
+
}) })
|
|
7690
7709
|
] }, section.label ?? si)) }),
|
|
7691
7710
|
/* @__PURE__ */ (0, import_jsx_runtime72.jsxs)("div", { className: cn63("flex shrink-0 flex-col gap-sm border-t border-hairline-soft py-sm", folded ? "items-center" : "px-sm"), children: [
|
|
7692
7711
|
promo ? /* @__PURE__ */ (0, import_jsx_runtime72.jsxs)(
|
|
@@ -7695,6 +7714,7 @@ var SidebarDesktop = React72.forwardRef(
|
|
|
7695
7714
|
href: promo.href,
|
|
7696
7715
|
"aria-label": folded ? promo.title : void 0,
|
|
7697
7716
|
title: folded ? promo.title : void 0,
|
|
7717
|
+
onClick: onNavigate && promoItem ? (event) => onNavigate(promoItem, event) : void 0,
|
|
7698
7718
|
className: cn63(
|
|
7699
7719
|
"group flex cursor-pointer items-center rounded-md transition-colors duration-150 ease-out hover:bg-surface-soft active:bg-surface-strong",
|
|
7700
7720
|
focusRing2,
|
|
@@ -7720,14 +7740,60 @@ var SidebarDesktop = React72.forwardRef(
|
|
|
7720
7740
|
}
|
|
7721
7741
|
) : null,
|
|
7722
7742
|
/* @__PURE__ */ (0, import_jsx_runtime72.jsxs)("div", { className: cn63("flex items-center", folded ? "flex-col gap-xs" : "justify-between gap-sm pl-xs"), children: [
|
|
7723
|
-
/* @__PURE__ */ (0, import_jsx_runtime72.
|
|
7724
|
-
|
|
7743
|
+
onUserClick ? folded ? /* @__PURE__ */ (0, import_jsx_runtime72.jsx)(
|
|
7744
|
+
Button,
|
|
7745
|
+
{
|
|
7746
|
+
variant: "ghost",
|
|
7747
|
+
size: "md",
|
|
7748
|
+
iconOnly: true,
|
|
7749
|
+
"aria-label": `Account: ${userName}`,
|
|
7750
|
+
onClick: onUserClick,
|
|
7751
|
+
className: "h-9 w-9",
|
|
7752
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime72.jsx)(Avatar, { name: userName, initials: userName.charAt(0), src: userAvatarSrc, size: "md" })
|
|
7753
|
+
}
|
|
7754
|
+
) : /* @__PURE__ */ (0, import_jsx_runtime72.jsxs)(
|
|
7755
|
+
Button,
|
|
7756
|
+
{
|
|
7757
|
+
variant: "ghost",
|
|
7758
|
+
size: "md",
|
|
7759
|
+
"aria-label": `Account: ${userName}`,
|
|
7760
|
+
onClick: onUserClick,
|
|
7761
|
+
className: "min-w-0 flex-1 justify-start gap-sm px-xs",
|
|
7762
|
+
children: [
|
|
7763
|
+
/* @__PURE__ */ (0, import_jsx_runtime72.jsx)(Avatar, { name: userName, initials: userName.charAt(0), src: userAvatarSrc, size: "md" }),
|
|
7764
|
+
/* @__PURE__ */ (0, import_jsx_runtime72.jsx)("span", { className: "min-w-0 truncate text-body-md text-ink", children: userName })
|
|
7765
|
+
]
|
|
7766
|
+
}
|
|
7767
|
+
) : /* @__PURE__ */ (0, import_jsx_runtime72.jsxs)("span", { className: "flex min-w-0 items-center gap-sm", children: [
|
|
7768
|
+
/* @__PURE__ */ (0, import_jsx_runtime72.jsx)(Avatar, { name: userName, initials: userName.charAt(0), src: userAvatarSrc, size: "md" }),
|
|
7725
7769
|
folded ? null : /* @__PURE__ */ (0, import_jsx_runtime72.jsx)("span", { className: "truncate text-body-md text-ink", children: userName })
|
|
7726
7770
|
] }),
|
|
7727
|
-
/* @__PURE__ */ (0, import_jsx_runtime72.jsxs)("span", { className: cn63("flex items-center gap-xxs", folded && "flex-col"), children: [
|
|
7728
|
-
/* @__PURE__ */ (0, import_jsx_runtime72.jsx)(IconButton, { icon: "settings", "aria-label": "Settings", variant: "ghost", size: "md", onClick: onSettingsClick }),
|
|
7729
|
-
/* @__PURE__ */ (0, import_jsx_runtime72.
|
|
7730
|
-
|
|
7771
|
+
onSettingsClick || onNotificationsClick ? /* @__PURE__ */ (0, import_jsx_runtime72.jsxs)("span", { className: cn63("flex items-center gap-xxs", folded && "flex-col"), children: [
|
|
7772
|
+
onSettingsClick ? /* @__PURE__ */ (0, import_jsx_runtime72.jsx)(IconButton, { icon: "settings", "aria-label": "Settings", variant: "ghost", size: "md", onClick: onSettingsClick }) : null,
|
|
7773
|
+
onNotificationsClick ? /* @__PURE__ */ (0, import_jsx_runtime72.jsxs)("span", { className: "relative inline-flex", children: [
|
|
7774
|
+
/* @__PURE__ */ (0, import_jsx_runtime72.jsx)(
|
|
7775
|
+
IconButton,
|
|
7776
|
+
{
|
|
7777
|
+
icon: "bell",
|
|
7778
|
+
"aria-label": bellLabel,
|
|
7779
|
+
variant: "ghost",
|
|
7780
|
+
size: "md",
|
|
7781
|
+
onClick: onNotificationsClick
|
|
7782
|
+
}
|
|
7783
|
+
),
|
|
7784
|
+
unread ? /* @__PURE__ */ (0, import_jsx_runtime72.jsx)(
|
|
7785
|
+
Badge,
|
|
7786
|
+
{
|
|
7787
|
+
"aria-hidden": "true",
|
|
7788
|
+
variant: "solid",
|
|
7789
|
+
tone: "error",
|
|
7790
|
+
size: "sm",
|
|
7791
|
+
className: "pointer-events-none absolute -right-xxs -top-xxs",
|
|
7792
|
+
children: countLabel(notificationCount)
|
|
7793
|
+
}
|
|
7794
|
+
) : null
|
|
7795
|
+
] }) : null
|
|
7796
|
+
] }) : null
|
|
7731
7797
|
] })
|
|
7732
7798
|
] })
|
|
7733
7799
|
]
|
|
@@ -7742,6 +7808,7 @@ var React73 = __toESM(require("react"));
|
|
|
7742
7808
|
var import_jsx_runtime73 = require("react/jsx-runtime");
|
|
7743
7809
|
var cn64 = (...parts) => parts.filter(Boolean).join(" ");
|
|
7744
7810
|
var focusRing3 = "focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-focus-blue";
|
|
7811
|
+
var countLabel2 = (count) => count > 9 ? "9+" : String(count);
|
|
7745
7812
|
var SidebarMobile = React73.forwardRef(
|
|
7746
7813
|
({
|
|
7747
7814
|
brandName = "AI Platform",
|
|
@@ -7752,8 +7819,14 @@ var SidebarMobile = React73.forwardRef(
|
|
|
7752
7819
|
sections = defaultSidebarSections,
|
|
7753
7820
|
promo = defaultSidebarPromo,
|
|
7754
7821
|
userName = "Alex Smith",
|
|
7822
|
+
userAvatarSrc,
|
|
7823
|
+
onUserClick,
|
|
7824
|
+
notificationCount = 0,
|
|
7755
7825
|
onSettingsClick,
|
|
7756
7826
|
onNotificationsClick,
|
|
7827
|
+
onNavigate,
|
|
7828
|
+
actions,
|
|
7829
|
+
drawerFooter,
|
|
7757
7830
|
open: openProp,
|
|
7758
7831
|
onOpenChange,
|
|
7759
7832
|
className,
|
|
@@ -7764,6 +7837,8 @@ var SidebarMobile = React73.forwardRef(
|
|
|
7764
7837
|
const open = openProp ?? inner;
|
|
7765
7838
|
const org = organization ?? orgInner;
|
|
7766
7839
|
const navId = React73.useId();
|
|
7840
|
+
const unread = notificationCount > 0;
|
|
7841
|
+
const bellLabel = unread ? `Notifications, ${notificationCount} unread` : "Notifications";
|
|
7767
7842
|
const setOpen = React73.useCallback(
|
|
7768
7843
|
(v) => {
|
|
7769
7844
|
if (openProp === void 0) setInner(v);
|
|
@@ -7771,8 +7846,49 @@ var SidebarMobile = React73.forwardRef(
|
|
|
7771
7846
|
},
|
|
7772
7847
|
[openProp, onOpenChange]
|
|
7773
7848
|
);
|
|
7849
|
+
const handleNavigate = (item, event) => {
|
|
7850
|
+
onNavigate?.(item, event);
|
|
7851
|
+
setOpen(false);
|
|
7852
|
+
};
|
|
7853
|
+
const promoItem = promo ? { label: promo.title, icon: promo.icon ?? "zap", href: promo.href } : null;
|
|
7854
|
+
const defaultFooter = /* @__PURE__ */ (0, import_jsx_runtime73.jsxs)("div", { className: "flex w-full items-center justify-between gap-sm", children: [
|
|
7855
|
+
onUserClick ? /* @__PURE__ */ (0, import_jsx_runtime73.jsxs)(
|
|
7856
|
+
Button,
|
|
7857
|
+
{
|
|
7858
|
+
variant: "ghost",
|
|
7859
|
+
size: "md",
|
|
7860
|
+
"aria-label": `Account: ${userName}`,
|
|
7861
|
+
onClick: onUserClick,
|
|
7862
|
+
className: "min-w-0 flex-1 justify-start gap-sm px-xs",
|
|
7863
|
+
children: [
|
|
7864
|
+
/* @__PURE__ */ (0, import_jsx_runtime73.jsx)(Avatar, { name: userName, initials: userName.charAt(0), src: userAvatarSrc, size: "md" }),
|
|
7865
|
+
/* @__PURE__ */ (0, import_jsx_runtime73.jsx)("span", { className: "min-w-0 truncate text-body-md text-ink", children: userName })
|
|
7866
|
+
]
|
|
7867
|
+
}
|
|
7868
|
+
) : /* @__PURE__ */ (0, import_jsx_runtime73.jsxs)("span", { className: "flex min-w-0 items-center gap-sm", children: [
|
|
7869
|
+
/* @__PURE__ */ (0, import_jsx_runtime73.jsx)(Avatar, { name: userName, initials: userName.charAt(0), src: userAvatarSrc, size: "md" }),
|
|
7870
|
+
/* @__PURE__ */ (0, import_jsx_runtime73.jsx)("span", { className: "truncate text-body-md text-ink", children: userName })
|
|
7871
|
+
] }),
|
|
7872
|
+
onSettingsClick || onNotificationsClick ? /* @__PURE__ */ (0, import_jsx_runtime73.jsxs)("span", { className: "flex items-center gap-xxs", children: [
|
|
7873
|
+
onSettingsClick ? /* @__PURE__ */ (0, import_jsx_runtime73.jsx)(IconButton, { icon: "settings", "aria-label": "Settings", variant: "ghost", size: "md", onClick: onSettingsClick }) : null,
|
|
7874
|
+
onNotificationsClick ? /* @__PURE__ */ (0, import_jsx_runtime73.jsxs)("span", { className: "relative inline-flex", children: [
|
|
7875
|
+
/* @__PURE__ */ (0, import_jsx_runtime73.jsx)(IconButton, { icon: "bell", "aria-label": bellLabel, variant: "ghost", size: "md", onClick: onNotificationsClick }),
|
|
7876
|
+
unread ? /* @__PURE__ */ (0, import_jsx_runtime73.jsx)(
|
|
7877
|
+
Badge,
|
|
7878
|
+
{
|
|
7879
|
+
"aria-hidden": "true",
|
|
7880
|
+
variant: "solid",
|
|
7881
|
+
tone: "error",
|
|
7882
|
+
size: "sm",
|
|
7883
|
+
className: "pointer-events-none absolute -right-xxs -top-xxs",
|
|
7884
|
+
children: countLabel2(notificationCount)
|
|
7885
|
+
}
|
|
7886
|
+
) : null
|
|
7887
|
+
] }) : null
|
|
7888
|
+
] }) : null
|
|
7889
|
+
] });
|
|
7774
7890
|
return /* @__PURE__ */ (0, import_jsx_runtime73.jsxs)("header", { ref, className: cn64("w-full", className), ...props, children: [
|
|
7775
|
-
/* @__PURE__ */ (0, import_jsx_runtime73.jsxs)("div", { className: "relative flex h-14 w-full items-center rounded-lg border border-hairline bg-canvas px-sm text-ink", children: [
|
|
7891
|
+
/* @__PURE__ */ (0, import_jsx_runtime73.jsxs)("div", { className: "relative flex h-14 w-full items-center justify-between rounded-lg border border-hairline bg-canvas px-sm text-ink", children: [
|
|
7776
7892
|
/* @__PURE__ */ (0, import_jsx_runtime73.jsx)(
|
|
7777
7893
|
Button,
|
|
7778
7894
|
{
|
|
@@ -7786,7 +7902,8 @@ var SidebarMobile = React73.forwardRef(
|
|
|
7786
7902
|
children: /* @__PURE__ */ (0, import_jsx_runtime73.jsx)(Icon, { name: "menu", size: 20 })
|
|
7787
7903
|
}
|
|
7788
7904
|
),
|
|
7789
|
-
/* @__PURE__ */ (0, import_jsx_runtime73.jsx)("span", { className: "pointer-events-none absolute inset-x-0 flex justify-center", children: /* @__PURE__ */ (0, import_jsx_runtime73.jsx)("span", { className: "pointer-events-auto", children: /* @__PURE__ */ (0, import_jsx_runtime73.jsx)(Logo, { name: brandName, href: brandHref, size: "md" }) }) })
|
|
7905
|
+
/* @__PURE__ */ (0, import_jsx_runtime73.jsx)("span", { className: "pointer-events-none absolute inset-x-0 flex justify-center", children: /* @__PURE__ */ (0, import_jsx_runtime73.jsx)("span", { className: "pointer-events-auto", children: /* @__PURE__ */ (0, import_jsx_runtime73.jsx)(Logo, { name: brandName, href: brandHref, size: "md" }) }) }),
|
|
7906
|
+
actions ? /* @__PURE__ */ (0, import_jsx_runtime73.jsx)("span", { className: "relative z-10 flex shrink-0 items-center gap-xs", children: actions }) : null
|
|
7790
7907
|
] }),
|
|
7791
7908
|
/* @__PURE__ */ (0, import_jsx_runtime73.jsx)(
|
|
7792
7909
|
Drawer,
|
|
@@ -7797,16 +7914,7 @@ var SidebarMobile = React73.forwardRef(
|
|
|
7797
7914
|
side: "left",
|
|
7798
7915
|
title: /* @__PURE__ */ (0, import_jsx_runtime73.jsx)(Logo, { name: brandName, size: "md" }),
|
|
7799
7916
|
"aria-label": brandName,
|
|
7800
|
-
footer:
|
|
7801
|
-
/* @__PURE__ */ (0, import_jsx_runtime73.jsxs)("span", { className: "flex min-w-0 items-center gap-sm", children: [
|
|
7802
|
-
/* @__PURE__ */ (0, import_jsx_runtime73.jsx)(Avatar, { name: userName, initials: userName.charAt(0), size: "md" }),
|
|
7803
|
-
/* @__PURE__ */ (0, import_jsx_runtime73.jsx)("span", { className: "truncate text-body-md text-ink", children: userName })
|
|
7804
|
-
] }),
|
|
7805
|
-
/* @__PURE__ */ (0, import_jsx_runtime73.jsxs)("span", { className: "flex items-center gap-xxs", children: [
|
|
7806
|
-
/* @__PURE__ */ (0, import_jsx_runtime73.jsx)(IconButton, { icon: "settings", "aria-label": "Settings", variant: "ghost", size: "md", onClick: onSettingsClick }),
|
|
7807
|
-
/* @__PURE__ */ (0, import_jsx_runtime73.jsx)(IconButton, { icon: "bell", "aria-label": "Notifications", variant: "ghost", size: "md", onClick: onNotificationsClick })
|
|
7808
|
-
] })
|
|
7809
|
-
] }),
|
|
7917
|
+
footer: drawerFooter ?? defaultFooter,
|
|
7810
7918
|
children: /* @__PURE__ */ (0, import_jsx_runtime73.jsxs)("div", { className: "flex flex-col gap-base", children: [
|
|
7811
7919
|
/* @__PURE__ */ (0, import_jsx_runtime73.jsx)(
|
|
7812
7920
|
Dropdown,
|
|
@@ -7822,28 +7930,33 @@ var SidebarMobile = React73.forwardRef(
|
|
|
7822
7930
|
),
|
|
7823
7931
|
/* @__PURE__ */ (0, import_jsx_runtime73.jsx)("nav", { "aria-label": "Main", className: "-mx-sm flex flex-col gap-base", children: sections.map((section, si) => /* @__PURE__ */ (0, import_jsx_runtime73.jsxs)("div", { className: "flex flex-col gap-xxs", children: [
|
|
7824
7932
|
section.label ? /* @__PURE__ */ (0, import_jsx_runtime73.jsx)("span", { className: "px-sm pb-xxs text-caption text-muted", children: section.label }) : null,
|
|
7825
|
-
/* @__PURE__ */ (0, import_jsx_runtime73.jsx)("ul", { className: "flex flex-col gap-xxs", children: section.items.map((item) =>
|
|
7826
|
-
"
|
|
7827
|
-
{
|
|
7828
|
-
|
|
7829
|
-
|
|
7830
|
-
|
|
7831
|
-
|
|
7832
|
-
|
|
7833
|
-
|
|
7834
|
-
|
|
7835
|
-
|
|
7836
|
-
|
|
7837
|
-
|
|
7838
|
-
|
|
7839
|
-
|
|
7840
|
-
|
|
7841
|
-
|
|
7933
|
+
/* @__PURE__ */ (0, import_jsx_runtime73.jsx)("ul", { className: "flex flex-col gap-xxs", children: section.items.map((item) => {
|
|
7934
|
+
const hasBadge = item.badge !== void 0 && item.badge !== null && item.badge !== "";
|
|
7935
|
+
return /* @__PURE__ */ (0, import_jsx_runtime73.jsx)("li", { children: /* @__PURE__ */ (0, import_jsx_runtime73.jsxs)(
|
|
7936
|
+
"a",
|
|
7937
|
+
{
|
|
7938
|
+
href: item.href,
|
|
7939
|
+
"aria-current": item.active ? "page" : void 0,
|
|
7940
|
+
onClick: (event) => handleNavigate(item, event),
|
|
7941
|
+
className: cn64(
|
|
7942
|
+
"flex h-9 w-full cursor-pointer items-center gap-sm rounded-sm px-sm text-body-md transition-colors duration-150 ease-out",
|
|
7943
|
+
focusRing3,
|
|
7944
|
+
item.active ? "bg-surface-strong text-ink" : "text-ink hover:bg-surface-soft active:bg-surface-strong"
|
|
7945
|
+
),
|
|
7946
|
+
children: [
|
|
7947
|
+
/* @__PURE__ */ (0, import_jsx_runtime73.jsx)(Icon, { name: item.icon, size: 18, className: "text-body" }),
|
|
7948
|
+
/* @__PURE__ */ (0, import_jsx_runtime73.jsx)("span", { className: "min-w-0 flex-1 truncate", children: item.label }),
|
|
7949
|
+
hasBadge ? /* @__PURE__ */ (0, import_jsx_runtime73.jsx)(Badge, { size: "sm", className: "ml-auto", children: item.badge }) : null
|
|
7950
|
+
]
|
|
7951
|
+
}
|
|
7952
|
+
) }, item.label);
|
|
7953
|
+
}) })
|
|
7842
7954
|
] }, section.label ?? si)) }),
|
|
7843
|
-
promo ? /* @__PURE__ */ (0, import_jsx_runtime73.jsxs)(
|
|
7955
|
+
promo && promoItem ? /* @__PURE__ */ (0, import_jsx_runtime73.jsxs)(
|
|
7844
7956
|
"a",
|
|
7845
7957
|
{
|
|
7846
7958
|
href: promo.href,
|
|
7959
|
+
onClick: (event) => handleNavigate(promoItem, event),
|
|
7847
7960
|
className: cn64(
|
|
7848
7961
|
"group flex cursor-pointer items-center gap-sm rounded-md border border-hairline px-md py-sm transition-colors duration-150 ease-out hover:bg-surface-soft active:bg-surface-strong",
|
|
7849
7962
|
focusRing3
|
package/dist/index.js
CHANGED
|
@@ -7463,6 +7463,7 @@ var defaultSidebarPromo = {
|
|
|
7463
7463
|
icon: "zap"
|
|
7464
7464
|
};
|
|
7465
7465
|
var focusRing2 = "focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-focus-blue";
|
|
7466
|
+
var countLabel = (count) => count > 9 ? "9+" : String(count);
|
|
7466
7467
|
var SidebarDesktop = React72.forwardRef(
|
|
7467
7468
|
({
|
|
7468
7469
|
brandName = "AI Platform",
|
|
@@ -7473,8 +7474,12 @@ var SidebarDesktop = React72.forwardRef(
|
|
|
7473
7474
|
sections = defaultSidebarSections,
|
|
7474
7475
|
promo = defaultSidebarPromo,
|
|
7475
7476
|
userName = "Alex Smith",
|
|
7477
|
+
userAvatarSrc,
|
|
7478
|
+
onUserClick,
|
|
7479
|
+
notificationCount = 0,
|
|
7476
7480
|
onSettingsClick,
|
|
7477
7481
|
onNotificationsClick,
|
|
7482
|
+
onNavigate,
|
|
7478
7483
|
folded: foldedProp,
|
|
7479
7484
|
defaultFolded = false,
|
|
7480
7485
|
onFoldedChange,
|
|
@@ -7491,6 +7496,9 @@ var SidebarDesktop = React72.forwardRef(
|
|
|
7491
7496
|
onFoldedChange?.(v);
|
|
7492
7497
|
};
|
|
7493
7498
|
const currentOrg = organizations.find((o) => o.value === org);
|
|
7499
|
+
const unread = notificationCount > 0;
|
|
7500
|
+
const bellLabel = unread ? `Notifications, ${notificationCount} unread` : "Notifications";
|
|
7501
|
+
const promoItem = promo ? { label: promo.title, icon: promo.icon ?? "zap", href: promo.href } : null;
|
|
7494
7502
|
return /* @__PURE__ */ jsxs67(
|
|
7495
7503
|
"aside",
|
|
7496
7504
|
{
|
|
@@ -7543,25 +7551,36 @@ var SidebarDesktop = React72.forwardRef(
|
|
|
7543
7551
|
) }),
|
|
7544
7552
|
/* @__PURE__ */ jsx72("nav", { id: navId, "aria-label": "Main", className: "min-h-0 flex-1 overflow-y-auto overscroll-contain pb-sm", children: sections.map((section, si) => /* @__PURE__ */ jsxs67("div", { className: cn63("flex flex-col gap-xxs", si > 0 && "mt-base"), children: [
|
|
7545
7553
|
section.label ? folded ? /* @__PURE__ */ jsx72("span", { className: "sr-only", children: section.label }) : /* @__PURE__ */ jsx72("span", { className: "px-base pb-xxs text-caption text-muted", children: section.label }) : null,
|
|
7546
|
-
/* @__PURE__ */ jsx72("ul", { className: cn63("flex flex-col gap-xxs", folded ? "items-center" : "px-sm"), children: section.items.map((item) =>
|
|
7547
|
-
"
|
|
7548
|
-
{
|
|
7549
|
-
|
|
7550
|
-
|
|
7551
|
-
|
|
7552
|
-
|
|
7553
|
-
|
|
7554
|
-
|
|
7555
|
-
|
|
7556
|
-
|
|
7557
|
-
|
|
7558
|
-
|
|
7559
|
-
|
|
7560
|
-
|
|
7561
|
-
|
|
7562
|
-
|
|
7563
|
-
|
|
7564
|
-
|
|
7554
|
+
/* @__PURE__ */ jsx72("ul", { className: cn63("flex flex-col gap-xxs", folded ? "items-center" : "px-sm"), children: section.items.map((item) => {
|
|
7555
|
+
const hasBadge = item.badge !== void 0 && item.badge !== null && item.badge !== "";
|
|
7556
|
+
return /* @__PURE__ */ jsx72("li", { className: folded ? void 0 : "w-full", children: /* @__PURE__ */ jsxs67(
|
|
7557
|
+
"a",
|
|
7558
|
+
{
|
|
7559
|
+
href: item.href,
|
|
7560
|
+
"aria-current": item.active ? "page" : void 0,
|
|
7561
|
+
"aria-label": folded ? item.label : void 0,
|
|
7562
|
+
title: folded ? item.label : void 0,
|
|
7563
|
+
onClick: onNavigate ? (event) => onNavigate(item, event) : void 0,
|
|
7564
|
+
className: cn63(
|
|
7565
|
+
"flex cursor-pointer items-center rounded-sm text-body-md transition-colors duration-150 ease-out",
|
|
7566
|
+
focusRing2,
|
|
7567
|
+
folded ? "relative size-9 justify-center" : "h-9 w-full gap-sm px-sm",
|
|
7568
|
+
item.active ? "bg-surface-strong text-ink" : "text-ink hover:bg-surface-soft active:bg-surface-strong"
|
|
7569
|
+
),
|
|
7570
|
+
children: [
|
|
7571
|
+
/* @__PURE__ */ jsx72(Icon, { name: item.icon, size: 18, className: "text-body" }),
|
|
7572
|
+
folded ? null : /* @__PURE__ */ jsx72("span", { className: hasBadge ? "min-w-0 flex-1 truncate" : "truncate", children: item.label }),
|
|
7573
|
+
hasBadge ? folded ? /* @__PURE__ */ jsx72(
|
|
7574
|
+
"span",
|
|
7575
|
+
{
|
|
7576
|
+
"aria-hidden": "true",
|
|
7577
|
+
className: "absolute right-xs top-xs h-2 w-2 rounded-full bg-primary"
|
|
7578
|
+
}
|
|
7579
|
+
) : /* @__PURE__ */ jsx72(Badge, { size: "sm", className: "ml-auto", children: item.badge }) : null
|
|
7580
|
+
]
|
|
7581
|
+
}
|
|
7582
|
+
) }, item.label);
|
|
7583
|
+
}) })
|
|
7565
7584
|
] }, section.label ?? si)) }),
|
|
7566
7585
|
/* @__PURE__ */ jsxs67("div", { className: cn63("flex shrink-0 flex-col gap-sm border-t border-hairline-soft py-sm", folded ? "items-center" : "px-sm"), children: [
|
|
7567
7586
|
promo ? /* @__PURE__ */ jsxs67(
|
|
@@ -7570,6 +7589,7 @@ var SidebarDesktop = React72.forwardRef(
|
|
|
7570
7589
|
href: promo.href,
|
|
7571
7590
|
"aria-label": folded ? promo.title : void 0,
|
|
7572
7591
|
title: folded ? promo.title : void 0,
|
|
7592
|
+
onClick: onNavigate && promoItem ? (event) => onNavigate(promoItem, event) : void 0,
|
|
7573
7593
|
className: cn63(
|
|
7574
7594
|
"group flex cursor-pointer items-center rounded-md transition-colors duration-150 ease-out hover:bg-surface-soft active:bg-surface-strong",
|
|
7575
7595
|
focusRing2,
|
|
@@ -7595,14 +7615,60 @@ var SidebarDesktop = React72.forwardRef(
|
|
|
7595
7615
|
}
|
|
7596
7616
|
) : null,
|
|
7597
7617
|
/* @__PURE__ */ jsxs67("div", { className: cn63("flex items-center", folded ? "flex-col gap-xs" : "justify-between gap-sm pl-xs"), children: [
|
|
7598
|
-
/* @__PURE__ */
|
|
7599
|
-
|
|
7618
|
+
onUserClick ? folded ? /* @__PURE__ */ jsx72(
|
|
7619
|
+
Button,
|
|
7620
|
+
{
|
|
7621
|
+
variant: "ghost",
|
|
7622
|
+
size: "md",
|
|
7623
|
+
iconOnly: true,
|
|
7624
|
+
"aria-label": `Account: ${userName}`,
|
|
7625
|
+
onClick: onUserClick,
|
|
7626
|
+
className: "h-9 w-9",
|
|
7627
|
+
children: /* @__PURE__ */ jsx72(Avatar, { name: userName, initials: userName.charAt(0), src: userAvatarSrc, size: "md" })
|
|
7628
|
+
}
|
|
7629
|
+
) : /* @__PURE__ */ jsxs67(
|
|
7630
|
+
Button,
|
|
7631
|
+
{
|
|
7632
|
+
variant: "ghost",
|
|
7633
|
+
size: "md",
|
|
7634
|
+
"aria-label": `Account: ${userName}`,
|
|
7635
|
+
onClick: onUserClick,
|
|
7636
|
+
className: "min-w-0 flex-1 justify-start gap-sm px-xs",
|
|
7637
|
+
children: [
|
|
7638
|
+
/* @__PURE__ */ jsx72(Avatar, { name: userName, initials: userName.charAt(0), src: userAvatarSrc, size: "md" }),
|
|
7639
|
+
/* @__PURE__ */ jsx72("span", { className: "min-w-0 truncate text-body-md text-ink", children: userName })
|
|
7640
|
+
]
|
|
7641
|
+
}
|
|
7642
|
+
) : /* @__PURE__ */ jsxs67("span", { className: "flex min-w-0 items-center gap-sm", children: [
|
|
7643
|
+
/* @__PURE__ */ jsx72(Avatar, { name: userName, initials: userName.charAt(0), src: userAvatarSrc, size: "md" }),
|
|
7600
7644
|
folded ? null : /* @__PURE__ */ jsx72("span", { className: "truncate text-body-md text-ink", children: userName })
|
|
7601
7645
|
] }),
|
|
7602
|
-
/* @__PURE__ */ jsxs67("span", { className: cn63("flex items-center gap-xxs", folded && "flex-col"), children: [
|
|
7603
|
-
/* @__PURE__ */ jsx72(IconButton, { icon: "settings", "aria-label": "Settings", variant: "ghost", size: "md", onClick: onSettingsClick }),
|
|
7604
|
-
/* @__PURE__ */
|
|
7605
|
-
|
|
7646
|
+
onSettingsClick || onNotificationsClick ? /* @__PURE__ */ jsxs67("span", { className: cn63("flex items-center gap-xxs", folded && "flex-col"), children: [
|
|
7647
|
+
onSettingsClick ? /* @__PURE__ */ jsx72(IconButton, { icon: "settings", "aria-label": "Settings", variant: "ghost", size: "md", onClick: onSettingsClick }) : null,
|
|
7648
|
+
onNotificationsClick ? /* @__PURE__ */ jsxs67("span", { className: "relative inline-flex", children: [
|
|
7649
|
+
/* @__PURE__ */ jsx72(
|
|
7650
|
+
IconButton,
|
|
7651
|
+
{
|
|
7652
|
+
icon: "bell",
|
|
7653
|
+
"aria-label": bellLabel,
|
|
7654
|
+
variant: "ghost",
|
|
7655
|
+
size: "md",
|
|
7656
|
+
onClick: onNotificationsClick
|
|
7657
|
+
}
|
|
7658
|
+
),
|
|
7659
|
+
unread ? /* @__PURE__ */ jsx72(
|
|
7660
|
+
Badge,
|
|
7661
|
+
{
|
|
7662
|
+
"aria-hidden": "true",
|
|
7663
|
+
variant: "solid",
|
|
7664
|
+
tone: "error",
|
|
7665
|
+
size: "sm",
|
|
7666
|
+
className: "pointer-events-none absolute -right-xxs -top-xxs",
|
|
7667
|
+
children: countLabel(notificationCount)
|
|
7668
|
+
}
|
|
7669
|
+
) : null
|
|
7670
|
+
] }) : null
|
|
7671
|
+
] }) : null
|
|
7606
7672
|
] })
|
|
7607
7673
|
] })
|
|
7608
7674
|
]
|
|
@@ -7617,6 +7683,7 @@ import * as React73 from "react";
|
|
|
7617
7683
|
import { jsx as jsx73, jsxs as jsxs68 } from "react/jsx-runtime";
|
|
7618
7684
|
var cn64 = (...parts) => parts.filter(Boolean).join(" ");
|
|
7619
7685
|
var focusRing3 = "focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-focus-blue";
|
|
7686
|
+
var countLabel2 = (count) => count > 9 ? "9+" : String(count);
|
|
7620
7687
|
var SidebarMobile = React73.forwardRef(
|
|
7621
7688
|
({
|
|
7622
7689
|
brandName = "AI Platform",
|
|
@@ -7627,8 +7694,14 @@ var SidebarMobile = React73.forwardRef(
|
|
|
7627
7694
|
sections = defaultSidebarSections,
|
|
7628
7695
|
promo = defaultSidebarPromo,
|
|
7629
7696
|
userName = "Alex Smith",
|
|
7697
|
+
userAvatarSrc,
|
|
7698
|
+
onUserClick,
|
|
7699
|
+
notificationCount = 0,
|
|
7630
7700
|
onSettingsClick,
|
|
7631
7701
|
onNotificationsClick,
|
|
7702
|
+
onNavigate,
|
|
7703
|
+
actions,
|
|
7704
|
+
drawerFooter,
|
|
7632
7705
|
open: openProp,
|
|
7633
7706
|
onOpenChange,
|
|
7634
7707
|
className,
|
|
@@ -7639,6 +7712,8 @@ var SidebarMobile = React73.forwardRef(
|
|
|
7639
7712
|
const open = openProp ?? inner;
|
|
7640
7713
|
const org = organization ?? orgInner;
|
|
7641
7714
|
const navId = React73.useId();
|
|
7715
|
+
const unread = notificationCount > 0;
|
|
7716
|
+
const bellLabel = unread ? `Notifications, ${notificationCount} unread` : "Notifications";
|
|
7642
7717
|
const setOpen = React73.useCallback(
|
|
7643
7718
|
(v) => {
|
|
7644
7719
|
if (openProp === void 0) setInner(v);
|
|
@@ -7646,8 +7721,49 @@ var SidebarMobile = React73.forwardRef(
|
|
|
7646
7721
|
},
|
|
7647
7722
|
[openProp, onOpenChange]
|
|
7648
7723
|
);
|
|
7724
|
+
const handleNavigate = (item, event) => {
|
|
7725
|
+
onNavigate?.(item, event);
|
|
7726
|
+
setOpen(false);
|
|
7727
|
+
};
|
|
7728
|
+
const promoItem = promo ? { label: promo.title, icon: promo.icon ?? "zap", href: promo.href } : null;
|
|
7729
|
+
const defaultFooter = /* @__PURE__ */ jsxs68("div", { className: "flex w-full items-center justify-between gap-sm", children: [
|
|
7730
|
+
onUserClick ? /* @__PURE__ */ jsxs68(
|
|
7731
|
+
Button,
|
|
7732
|
+
{
|
|
7733
|
+
variant: "ghost",
|
|
7734
|
+
size: "md",
|
|
7735
|
+
"aria-label": `Account: ${userName}`,
|
|
7736
|
+
onClick: onUserClick,
|
|
7737
|
+
className: "min-w-0 flex-1 justify-start gap-sm px-xs",
|
|
7738
|
+
children: [
|
|
7739
|
+
/* @__PURE__ */ jsx73(Avatar, { name: userName, initials: userName.charAt(0), src: userAvatarSrc, size: "md" }),
|
|
7740
|
+
/* @__PURE__ */ jsx73("span", { className: "min-w-0 truncate text-body-md text-ink", children: userName })
|
|
7741
|
+
]
|
|
7742
|
+
}
|
|
7743
|
+
) : /* @__PURE__ */ jsxs68("span", { className: "flex min-w-0 items-center gap-sm", children: [
|
|
7744
|
+
/* @__PURE__ */ jsx73(Avatar, { name: userName, initials: userName.charAt(0), src: userAvatarSrc, size: "md" }),
|
|
7745
|
+
/* @__PURE__ */ jsx73("span", { className: "truncate text-body-md text-ink", children: userName })
|
|
7746
|
+
] }),
|
|
7747
|
+
onSettingsClick || onNotificationsClick ? /* @__PURE__ */ jsxs68("span", { className: "flex items-center gap-xxs", children: [
|
|
7748
|
+
onSettingsClick ? /* @__PURE__ */ jsx73(IconButton, { icon: "settings", "aria-label": "Settings", variant: "ghost", size: "md", onClick: onSettingsClick }) : null,
|
|
7749
|
+
onNotificationsClick ? /* @__PURE__ */ jsxs68("span", { className: "relative inline-flex", children: [
|
|
7750
|
+
/* @__PURE__ */ jsx73(IconButton, { icon: "bell", "aria-label": bellLabel, variant: "ghost", size: "md", onClick: onNotificationsClick }),
|
|
7751
|
+
unread ? /* @__PURE__ */ jsx73(
|
|
7752
|
+
Badge,
|
|
7753
|
+
{
|
|
7754
|
+
"aria-hidden": "true",
|
|
7755
|
+
variant: "solid",
|
|
7756
|
+
tone: "error",
|
|
7757
|
+
size: "sm",
|
|
7758
|
+
className: "pointer-events-none absolute -right-xxs -top-xxs",
|
|
7759
|
+
children: countLabel2(notificationCount)
|
|
7760
|
+
}
|
|
7761
|
+
) : null
|
|
7762
|
+
] }) : null
|
|
7763
|
+
] }) : null
|
|
7764
|
+
] });
|
|
7649
7765
|
return /* @__PURE__ */ jsxs68("header", { ref, className: cn64("w-full", className), ...props, children: [
|
|
7650
|
-
/* @__PURE__ */ jsxs68("div", { className: "relative flex h-14 w-full items-center rounded-lg border border-hairline bg-canvas px-sm text-ink", children: [
|
|
7766
|
+
/* @__PURE__ */ jsxs68("div", { className: "relative flex h-14 w-full items-center justify-between rounded-lg border border-hairline bg-canvas px-sm text-ink", children: [
|
|
7651
7767
|
/* @__PURE__ */ jsx73(
|
|
7652
7768
|
Button,
|
|
7653
7769
|
{
|
|
@@ -7661,7 +7777,8 @@ var SidebarMobile = React73.forwardRef(
|
|
|
7661
7777
|
children: /* @__PURE__ */ jsx73(Icon, { name: "menu", size: 20 })
|
|
7662
7778
|
}
|
|
7663
7779
|
),
|
|
7664
|
-
/* @__PURE__ */ jsx73("span", { className: "pointer-events-none absolute inset-x-0 flex justify-center", children: /* @__PURE__ */ jsx73("span", { className: "pointer-events-auto", children: /* @__PURE__ */ jsx73(Logo, { name: brandName, href: brandHref, size: "md" }) }) })
|
|
7780
|
+
/* @__PURE__ */ jsx73("span", { className: "pointer-events-none absolute inset-x-0 flex justify-center", children: /* @__PURE__ */ jsx73("span", { className: "pointer-events-auto", children: /* @__PURE__ */ jsx73(Logo, { name: brandName, href: brandHref, size: "md" }) }) }),
|
|
7781
|
+
actions ? /* @__PURE__ */ jsx73("span", { className: "relative z-10 flex shrink-0 items-center gap-xs", children: actions }) : null
|
|
7665
7782
|
] }),
|
|
7666
7783
|
/* @__PURE__ */ jsx73(
|
|
7667
7784
|
Drawer,
|
|
@@ -7672,16 +7789,7 @@ var SidebarMobile = React73.forwardRef(
|
|
|
7672
7789
|
side: "left",
|
|
7673
7790
|
title: /* @__PURE__ */ jsx73(Logo, { name: brandName, size: "md" }),
|
|
7674
7791
|
"aria-label": brandName,
|
|
7675
|
-
footer:
|
|
7676
|
-
/* @__PURE__ */ jsxs68("span", { className: "flex min-w-0 items-center gap-sm", children: [
|
|
7677
|
-
/* @__PURE__ */ jsx73(Avatar, { name: userName, initials: userName.charAt(0), size: "md" }),
|
|
7678
|
-
/* @__PURE__ */ jsx73("span", { className: "truncate text-body-md text-ink", children: userName })
|
|
7679
|
-
] }),
|
|
7680
|
-
/* @__PURE__ */ jsxs68("span", { className: "flex items-center gap-xxs", children: [
|
|
7681
|
-
/* @__PURE__ */ jsx73(IconButton, { icon: "settings", "aria-label": "Settings", variant: "ghost", size: "md", onClick: onSettingsClick }),
|
|
7682
|
-
/* @__PURE__ */ jsx73(IconButton, { icon: "bell", "aria-label": "Notifications", variant: "ghost", size: "md", onClick: onNotificationsClick })
|
|
7683
|
-
] })
|
|
7684
|
-
] }),
|
|
7792
|
+
footer: drawerFooter ?? defaultFooter,
|
|
7685
7793
|
children: /* @__PURE__ */ jsxs68("div", { className: "flex flex-col gap-base", children: [
|
|
7686
7794
|
/* @__PURE__ */ jsx73(
|
|
7687
7795
|
Dropdown,
|
|
@@ -7697,28 +7805,33 @@ var SidebarMobile = React73.forwardRef(
|
|
|
7697
7805
|
),
|
|
7698
7806
|
/* @__PURE__ */ jsx73("nav", { "aria-label": "Main", className: "-mx-sm flex flex-col gap-base", children: sections.map((section, si) => /* @__PURE__ */ jsxs68("div", { className: "flex flex-col gap-xxs", children: [
|
|
7699
7807
|
section.label ? /* @__PURE__ */ jsx73("span", { className: "px-sm pb-xxs text-caption text-muted", children: section.label }) : null,
|
|
7700
|
-
/* @__PURE__ */ jsx73("ul", { className: "flex flex-col gap-xxs", children: section.items.map((item) =>
|
|
7701
|
-
"
|
|
7702
|
-
{
|
|
7703
|
-
|
|
7704
|
-
|
|
7705
|
-
|
|
7706
|
-
|
|
7707
|
-
|
|
7708
|
-
|
|
7709
|
-
|
|
7710
|
-
|
|
7711
|
-
|
|
7712
|
-
|
|
7713
|
-
|
|
7714
|
-
|
|
7715
|
-
|
|
7716
|
-
|
|
7808
|
+
/* @__PURE__ */ jsx73("ul", { className: "flex flex-col gap-xxs", children: section.items.map((item) => {
|
|
7809
|
+
const hasBadge = item.badge !== void 0 && item.badge !== null && item.badge !== "";
|
|
7810
|
+
return /* @__PURE__ */ jsx73("li", { children: /* @__PURE__ */ jsxs68(
|
|
7811
|
+
"a",
|
|
7812
|
+
{
|
|
7813
|
+
href: item.href,
|
|
7814
|
+
"aria-current": item.active ? "page" : void 0,
|
|
7815
|
+
onClick: (event) => handleNavigate(item, event),
|
|
7816
|
+
className: cn64(
|
|
7817
|
+
"flex h-9 w-full cursor-pointer items-center gap-sm rounded-sm px-sm text-body-md transition-colors duration-150 ease-out",
|
|
7818
|
+
focusRing3,
|
|
7819
|
+
item.active ? "bg-surface-strong text-ink" : "text-ink hover:bg-surface-soft active:bg-surface-strong"
|
|
7820
|
+
),
|
|
7821
|
+
children: [
|
|
7822
|
+
/* @__PURE__ */ jsx73(Icon, { name: item.icon, size: 18, className: "text-body" }),
|
|
7823
|
+
/* @__PURE__ */ jsx73("span", { className: "min-w-0 flex-1 truncate", children: item.label }),
|
|
7824
|
+
hasBadge ? /* @__PURE__ */ jsx73(Badge, { size: "sm", className: "ml-auto", children: item.badge }) : null
|
|
7825
|
+
]
|
|
7826
|
+
}
|
|
7827
|
+
) }, item.label);
|
|
7828
|
+
}) })
|
|
7717
7829
|
] }, section.label ?? si)) }),
|
|
7718
|
-
promo ? /* @__PURE__ */ jsxs68(
|
|
7830
|
+
promo && promoItem ? /* @__PURE__ */ jsxs68(
|
|
7719
7831
|
"a",
|
|
7720
7832
|
{
|
|
7721
7833
|
href: promo.href,
|
|
7834
|
+
onClick: (event) => handleNavigate(promoItem, event),
|
|
7722
7835
|
className: cn64(
|
|
7723
7836
|
"group flex cursor-pointer items-center gap-sm rounded-md border border-hairline px-md py-sm transition-colors duration-150 ease-out hover:bg-surface-soft active:bg-surface-strong",
|
|
7724
7837
|
focusRing3
|
package/dist/styles.css
CHANGED
|
@@ -326,6 +326,9 @@
|
|
|
326
326
|
.inset-y-xxs {
|
|
327
327
|
inset-block: var(--spacing-xxs);
|
|
328
328
|
}
|
|
329
|
+
.-top-xxs {
|
|
330
|
+
top: calc(var(--spacing-xxs) * -1);
|
|
331
|
+
}
|
|
329
332
|
.top-1\.5 {
|
|
330
333
|
top: calc(var(--spacing) * 1.5);
|
|
331
334
|
}
|
|
@@ -338,9 +341,15 @@
|
|
|
338
341
|
.top-sm {
|
|
339
342
|
top: var(--spacing-sm);
|
|
340
343
|
}
|
|
344
|
+
.top-xs {
|
|
345
|
+
top: var(--spacing-xs);
|
|
346
|
+
}
|
|
341
347
|
.top-xxs {
|
|
342
348
|
top: var(--spacing-xxs);
|
|
343
349
|
}
|
|
350
|
+
.-right-xxs {
|
|
351
|
+
right: calc(var(--spacing-xxs) * -1);
|
|
352
|
+
}
|
|
344
353
|
.right-0 {
|
|
345
354
|
right: 0;
|
|
346
355
|
}
|
|
@@ -350,6 +359,9 @@
|
|
|
350
359
|
.right-full {
|
|
351
360
|
right: 100%;
|
|
352
361
|
}
|
|
362
|
+
.right-xs {
|
|
363
|
+
right: var(--spacing-xs);
|
|
364
|
+
}
|
|
353
365
|
.-bottom-px {
|
|
354
366
|
bottom: -1px;
|
|
355
367
|
}
|
package/package.json
CHANGED
|
@@ -1,21 +1,104 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
2
|
import { Sidebar } from "./Sidebar";
|
|
3
|
+
import { SidebarMobile } from "../SidebarMobile";
|
|
4
|
+
import { type SidebarNavItem } from "../SidebarDesktop";
|
|
5
|
+
import { Button } from "../Button";
|
|
6
|
+
import { IconButton } from "../IconButton";
|
|
7
|
+
import { Avatar } from "../Avatar";
|
|
8
|
+
import { Badge } from "../Badge";
|
|
9
|
+
import { Icon } from "../Icon";
|
|
10
|
+
|
|
11
|
+
const sections = [
|
|
12
|
+
{
|
|
13
|
+
items: [
|
|
14
|
+
{ label: "Dashboard", icon: "house" as const, href: "#dashboard", active: true },
|
|
15
|
+
{ label: "Inbox", icon: "message-circle-more" as const, href: "#inbox", badge: 12 },
|
|
16
|
+
],
|
|
17
|
+
},
|
|
18
|
+
{
|
|
19
|
+
label: "Manage",
|
|
20
|
+
items: [
|
|
21
|
+
{ label: "Usage", icon: "chart-column" as const, href: "#usage" },
|
|
22
|
+
{ label: "API keys", icon: "key-round" as const, href: "#keys", badge: "New" },
|
|
23
|
+
],
|
|
24
|
+
},
|
|
25
|
+
];
|
|
3
26
|
|
|
4
27
|
export default function SidebarPreview() {
|
|
5
28
|
const [folded, setFolded] = React.useState(false);
|
|
6
|
-
const [
|
|
29
|
+
const [drawerOpen, setDrawerOpen] = React.useState(false);
|
|
30
|
+
const [lastRoute, setLastRoute] = React.useState<string>("nothing yet");
|
|
31
|
+
|
|
32
|
+
const onNavigate = (item: SidebarNavItem, event: React.MouseEvent<HTMLAnchorElement>) => {
|
|
33
|
+
event.preventDefault();
|
|
34
|
+
setLastRoute(item.label);
|
|
35
|
+
};
|
|
36
|
+
|
|
7
37
|
return (
|
|
8
|
-
<div className="w-full p-lg">
|
|
9
|
-
<div className="flex w-full flex-col gap-base md:h-[
|
|
38
|
+
<div className="mx-auto flex w-full max-w-4xl flex-col gap-base p-lg">
|
|
39
|
+
<div className="flex w-full flex-col gap-base md:h-[420px] md:flex-row">
|
|
10
40
|
<Sidebar
|
|
11
|
-
desktop={{
|
|
12
|
-
|
|
41
|
+
desktop={{
|
|
42
|
+
folded,
|
|
43
|
+
onFoldedChange: setFolded,
|
|
44
|
+
sections,
|
|
45
|
+
userAvatarSrc: "https://images.unsplash.com/photo-1494790108377-be9c29b29330?w=80&h=80&fit=crop",
|
|
46
|
+
onUserClick: () => setLastRoute("account menu"),
|
|
47
|
+
notificationCount: 12,
|
|
48
|
+
onSettingsClick: () => setLastRoute("settings"),
|
|
49
|
+
onNotificationsClick: () => setLastRoute("notifications"),
|
|
50
|
+
onNavigate,
|
|
51
|
+
}}
|
|
13
52
|
/>
|
|
14
|
-
<div className="flex min-h-40 min-w-0 flex-1 flex-col gap-
|
|
53
|
+
<div className="flex min-h-40 min-w-0 flex-1 flex-col gap-sm rounded-lg border border-hairline bg-canvas p-lg">
|
|
15
54
|
<span className="text-heading-sm text-ink">Dashboard</span>
|
|
16
|
-
<span className="text-body-md text-muted">
|
|
55
|
+
<span className="text-body-md text-muted">
|
|
56
|
+
Nav clicks route in the app without a page reload. Fold the rail to see badges collapse to dots.
|
|
57
|
+
</span>
|
|
58
|
+
<span className="mt-auto text-body-sm text-muted">Last action: {lastRoute}</span>
|
|
17
59
|
</div>
|
|
18
60
|
</div>
|
|
61
|
+
|
|
62
|
+
<div className="flex w-full flex-col gap-xs">
|
|
63
|
+
<span className="text-caption text-muted">
|
|
64
|
+
Mobile bar with app actions — the menu button opens a drawer with a custom footer
|
|
65
|
+
</span>
|
|
66
|
+
<SidebarMobile
|
|
67
|
+
open={drawerOpen}
|
|
68
|
+
onOpenChange={setDrawerOpen}
|
|
69
|
+
sections={sections}
|
|
70
|
+
onNavigate={onNavigate}
|
|
71
|
+
notificationCount={12}
|
|
72
|
+
actions={
|
|
73
|
+
<>
|
|
74
|
+
<IconButton icon="search" aria-label="Search" variant="ghost" size="md" />
|
|
75
|
+
<span className="relative inline-flex">
|
|
76
|
+
<IconButton icon="bell" aria-label="Notifications, 12 unread" variant="ghost" size="md" />
|
|
77
|
+
<Badge
|
|
78
|
+
aria-hidden="true"
|
|
79
|
+
variant="solid"
|
|
80
|
+
tone="error"
|
|
81
|
+
size="sm"
|
|
82
|
+
className="pointer-events-none absolute -right-xxs -top-xxs"
|
|
83
|
+
>
|
|
84
|
+
9+
|
|
85
|
+
</Badge>
|
|
86
|
+
</span>
|
|
87
|
+
<Avatar name="Alex Smith" initials="A" size="sm" />
|
|
88
|
+
</>
|
|
89
|
+
}
|
|
90
|
+
drawerFooter={
|
|
91
|
+
<div className="flex w-full items-center justify-between gap-sm">
|
|
92
|
+
<Button variant="ghost" size="md" leadingIcon={<Icon name="sun" size={16} />}>
|
|
93
|
+
Light
|
|
94
|
+
</Button>
|
|
95
|
+
<Button variant="ghost" size="md" leadingIcon={<Icon name="log-out" size={16} />}>
|
|
96
|
+
Sign out
|
|
97
|
+
</Button>
|
|
98
|
+
</div>
|
|
99
|
+
}
|
|
100
|
+
/>
|
|
101
|
+
</div>
|
|
19
102
|
</div>
|
|
20
103
|
);
|
|
21
104
|
}
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
2
|
import { Logo } from "../Logo";
|
|
3
3
|
import { IconButton } from "../IconButton";
|
|
4
|
+
import { Button } from "../Button";
|
|
5
|
+
import { Badge } from "../Badge";
|
|
4
6
|
import { Dropdown, type DropdownOption } from "../Dropdown";
|
|
5
7
|
import { Avatar } from "../Avatar";
|
|
6
8
|
import { Icon, type IconName } from "../Icon";
|
|
@@ -10,6 +12,8 @@ export interface SidebarNavItem {
|
|
|
10
12
|
icon: IconName;
|
|
11
13
|
href: string;
|
|
12
14
|
active?: boolean;
|
|
15
|
+
/** Small neutral count at the end of the row (a dot on the icon when folded). */
|
|
16
|
+
badge?: string | number;
|
|
13
17
|
}
|
|
14
18
|
|
|
15
19
|
export interface SidebarNavSection {
|
|
@@ -34,8 +38,16 @@ export interface SidebarDesktopProps extends React.HTMLAttributes<HTMLElement> {
|
|
|
34
38
|
sections?: SidebarNavSection[];
|
|
35
39
|
promo?: SidebarPromo | null;
|
|
36
40
|
userName?: string;
|
|
41
|
+
/** Photo for the footer avatar; falls back to initials. */
|
|
42
|
+
userAvatarSrc?: string;
|
|
43
|
+
/** Makes the footer avatar + name a button (opens an account menu). */
|
|
44
|
+
onUserClick?: () => void;
|
|
45
|
+
/** Unread count on the footer bell (`9+` above nine). */
|
|
46
|
+
notificationCount?: number;
|
|
37
47
|
onSettingsClick?: () => void;
|
|
38
48
|
onNotificationsClick?: () => void;
|
|
49
|
+
/** Router hook: called on a nav item or promo click, before the href is followed. */
|
|
50
|
+
onNavigate?: (item: SidebarNavItem, event: React.MouseEvent<HTMLAnchorElement>) => void;
|
|
39
51
|
/** Controlled fold state (icon rail when true). */
|
|
40
52
|
folded?: boolean;
|
|
41
53
|
defaultFolded?: boolean;
|
|
@@ -90,6 +102,9 @@ export const defaultSidebarPromo: SidebarPromo = {
|
|
|
90
102
|
|
|
91
103
|
const focusRing = "focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-focus-blue";
|
|
92
104
|
|
|
105
|
+
/** `9+` above nine, the raw number below. */
|
|
106
|
+
const countLabel = (count: number) => (count > 9 ? "9+" : String(count));
|
|
107
|
+
|
|
93
108
|
export const SidebarDesktop = React.forwardRef<HTMLElement, SidebarDesktopProps>(
|
|
94
109
|
(
|
|
95
110
|
{
|
|
@@ -101,8 +116,12 @@ export const SidebarDesktop = React.forwardRef<HTMLElement, SidebarDesktopProps>
|
|
|
101
116
|
sections = defaultSidebarSections,
|
|
102
117
|
promo = defaultSidebarPromo,
|
|
103
118
|
userName = "Alex Smith",
|
|
119
|
+
userAvatarSrc,
|
|
120
|
+
onUserClick,
|
|
121
|
+
notificationCount = 0,
|
|
104
122
|
onSettingsClick,
|
|
105
123
|
onNotificationsClick,
|
|
124
|
+
onNavigate,
|
|
106
125
|
folded: foldedProp,
|
|
107
126
|
defaultFolded = false,
|
|
108
127
|
onFoldedChange,
|
|
@@ -121,6 +140,11 @@ export const SidebarDesktop = React.forwardRef<HTMLElement, SidebarDesktopProps>
|
|
|
121
140
|
onFoldedChange?.(v);
|
|
122
141
|
};
|
|
123
142
|
const currentOrg = organizations.find((o) => o.value === org);
|
|
143
|
+
const unread = notificationCount > 0;
|
|
144
|
+
const bellLabel = unread ? `Notifications, ${notificationCount} unread` : "Notifications";
|
|
145
|
+
const promoItem: SidebarNavItem | null = promo
|
|
146
|
+
? { label: promo.title, icon: promo.icon ?? "zap", href: promo.href }
|
|
147
|
+
: null;
|
|
124
148
|
|
|
125
149
|
return (
|
|
126
150
|
<aside
|
|
@@ -182,27 +206,45 @@ export const SidebarDesktop = React.forwardRef<HTMLElement, SidebarDesktopProps>
|
|
|
182
206
|
)
|
|
183
207
|
) : null}
|
|
184
208
|
<ul className={cn("flex flex-col gap-xxs", folded ? "items-center" : "px-sm")}>
|
|
185
|
-
{section.items.map((item) =>
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
209
|
+
{section.items.map((item) => {
|
|
210
|
+
const hasBadge = item.badge !== undefined && item.badge !== null && item.badge !== "";
|
|
211
|
+
return (
|
|
212
|
+
<li key={item.label} className={folded ? undefined : "w-full"}>
|
|
213
|
+
<a
|
|
214
|
+
href={item.href}
|
|
215
|
+
aria-current={item.active ? "page" : undefined}
|
|
216
|
+
aria-label={folded ? item.label : undefined}
|
|
217
|
+
title={folded ? item.label : undefined}
|
|
218
|
+
onClick={onNavigate ? (event) => onNavigate(item, event) : undefined}
|
|
219
|
+
className={cn(
|
|
220
|
+
"flex cursor-pointer items-center rounded-sm text-body-md transition-colors duration-150 ease-out",
|
|
221
|
+
focusRing,
|
|
222
|
+
folded ? "relative size-9 justify-center" : "h-9 w-full gap-sm px-sm",
|
|
223
|
+
item.active
|
|
224
|
+
? "bg-surface-strong text-ink"
|
|
225
|
+
: "text-ink hover:bg-surface-soft active:bg-surface-strong",
|
|
226
|
+
)}
|
|
227
|
+
>
|
|
228
|
+
<Icon name={item.icon} size={18} className="text-body" />
|
|
229
|
+
{folded ? null : (
|
|
230
|
+
<span className={hasBadge ? "min-w-0 flex-1 truncate" : "truncate"}>{item.label}</span>
|
|
231
|
+
)}
|
|
232
|
+
{hasBadge ? (
|
|
233
|
+
folded ? (
|
|
234
|
+
<span
|
|
235
|
+
aria-hidden="true"
|
|
236
|
+
className="absolute right-xs top-xs h-2 w-2 rounded-full bg-primary"
|
|
237
|
+
/>
|
|
238
|
+
) : (
|
|
239
|
+
<Badge size="sm" className="ml-auto">
|
|
240
|
+
{item.badge}
|
|
241
|
+
</Badge>
|
|
242
|
+
)
|
|
243
|
+
) : null}
|
|
244
|
+
</a>
|
|
245
|
+
</li>
|
|
246
|
+
);
|
|
247
|
+
})}
|
|
206
248
|
</ul>
|
|
207
249
|
</div>
|
|
208
250
|
))}
|
|
@@ -214,6 +256,9 @@ export const SidebarDesktop = React.forwardRef<HTMLElement, SidebarDesktopProps>
|
|
|
214
256
|
href={promo.href}
|
|
215
257
|
aria-label={folded ? promo.title : undefined}
|
|
216
258
|
title={folded ? promo.title : undefined}
|
|
259
|
+
onClick={
|
|
260
|
+
onNavigate && promoItem ? (event) => onNavigate(promoItem, event) : undefined
|
|
261
|
+
}
|
|
217
262
|
className={cn(
|
|
218
263
|
"group flex cursor-pointer items-center rounded-md transition-colors duration-150 ease-out hover:bg-surface-soft active:bg-surface-strong",
|
|
219
264
|
focusRing,
|
|
@@ -240,14 +285,65 @@ export const SidebarDesktop = React.forwardRef<HTMLElement, SidebarDesktopProps>
|
|
|
240
285
|
) : null}
|
|
241
286
|
|
|
242
287
|
<div className={cn("flex items-center", folded ? "flex-col gap-xs" : "justify-between gap-sm pl-xs")}>
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
288
|
+
{onUserClick ? (
|
|
289
|
+
folded ? (
|
|
290
|
+
<Button
|
|
291
|
+
variant="ghost"
|
|
292
|
+
size="md"
|
|
293
|
+
iconOnly
|
|
294
|
+
aria-label={`Account: ${userName}`}
|
|
295
|
+
onClick={onUserClick}
|
|
296
|
+
className="h-9 w-9"
|
|
297
|
+
>
|
|
298
|
+
<Avatar name={userName} initials={userName.charAt(0)} src={userAvatarSrc} size="md" />
|
|
299
|
+
</Button>
|
|
300
|
+
) : (
|
|
301
|
+
<Button
|
|
302
|
+
variant="ghost"
|
|
303
|
+
size="md"
|
|
304
|
+
aria-label={`Account: ${userName}`}
|
|
305
|
+
onClick={onUserClick}
|
|
306
|
+
className="min-w-0 flex-1 justify-start gap-sm px-xs"
|
|
307
|
+
>
|
|
308
|
+
<Avatar name={userName} initials={userName.charAt(0)} src={userAvatarSrc} size="md" />
|
|
309
|
+
<span className="min-w-0 truncate text-body-md text-ink">{userName}</span>
|
|
310
|
+
</Button>
|
|
311
|
+
)
|
|
312
|
+
) : (
|
|
313
|
+
<span className="flex min-w-0 items-center gap-sm">
|
|
314
|
+
<Avatar name={userName} initials={userName.charAt(0)} src={userAvatarSrc} size="md" />
|
|
315
|
+
{folded ? null : <span className="truncate text-body-md text-ink">{userName}</span>}
|
|
316
|
+
</span>
|
|
317
|
+
)}
|
|
318
|
+
{onSettingsClick || onNotificationsClick ? (
|
|
319
|
+
<span className={cn("flex items-center gap-xxs", folded && "flex-col")}>
|
|
320
|
+
{onSettingsClick ? (
|
|
321
|
+
<IconButton icon="settings" aria-label="Settings" variant="ghost" size="md" onClick={onSettingsClick} />
|
|
322
|
+
) : null}
|
|
323
|
+
{onNotificationsClick ? (
|
|
324
|
+
<span className="relative inline-flex">
|
|
325
|
+
<IconButton
|
|
326
|
+
icon="bell"
|
|
327
|
+
aria-label={bellLabel}
|
|
328
|
+
variant="ghost"
|
|
329
|
+
size="md"
|
|
330
|
+
onClick={onNotificationsClick}
|
|
331
|
+
/>
|
|
332
|
+
{unread ? (
|
|
333
|
+
<Badge
|
|
334
|
+
aria-hidden="true"
|
|
335
|
+
variant="solid"
|
|
336
|
+
tone="error"
|
|
337
|
+
size="sm"
|
|
338
|
+
className="pointer-events-none absolute -right-xxs -top-xxs"
|
|
339
|
+
>
|
|
340
|
+
{countLabel(notificationCount)}
|
|
341
|
+
</Badge>
|
|
342
|
+
) : null}
|
|
343
|
+
</span>
|
|
344
|
+
) : null}
|
|
345
|
+
</span>
|
|
346
|
+
) : null}
|
|
251
347
|
</div>
|
|
252
348
|
</div>
|
|
253
349
|
</aside>
|
|
@@ -2,6 +2,7 @@ import * as React from "react";
|
|
|
2
2
|
import { Logo } from "../Logo";
|
|
3
3
|
import { Button } from "../Button";
|
|
4
4
|
import { IconButton } from "../IconButton";
|
|
5
|
+
import { Badge } from "../Badge";
|
|
5
6
|
import { Drawer } from "../Drawer";
|
|
6
7
|
import { Dropdown, type DropdownOption } from "../Dropdown";
|
|
7
8
|
import { Avatar } from "../Avatar";
|
|
@@ -11,6 +12,7 @@ import {
|
|
|
11
12
|
defaultSidebarOrganizations,
|
|
12
13
|
defaultSidebarPromo,
|
|
13
14
|
type SidebarNavSection,
|
|
15
|
+
type SidebarNavItem,
|
|
14
16
|
type SidebarPromo,
|
|
15
17
|
} from "../SidebarDesktop";
|
|
16
18
|
|
|
@@ -23,8 +25,20 @@ export interface SidebarMobileProps extends React.HTMLAttributes<HTMLElement> {
|
|
|
23
25
|
sections?: SidebarNavSection[];
|
|
24
26
|
promo?: SidebarPromo | null;
|
|
25
27
|
userName?: string;
|
|
28
|
+
/** Photo for the drawer footer avatar; falls back to initials. */
|
|
29
|
+
userAvatarSrc?: string;
|
|
30
|
+
/** Makes the drawer footer avatar + name a button (opens an account menu). */
|
|
31
|
+
onUserClick?: () => void;
|
|
32
|
+
/** Unread count on the drawer footer bell (`9+` above nine). */
|
|
33
|
+
notificationCount?: number;
|
|
26
34
|
onSettingsClick?: () => void;
|
|
27
35
|
onNotificationsClick?: () => void;
|
|
36
|
+
/** Router hook: called on a nav item or promo click, before the href is followed. */
|
|
37
|
+
onNavigate?: (item: SidebarNavItem, event: React.MouseEvent<HTMLAnchorElement>) => void;
|
|
38
|
+
/** Controls rendered at the right of the top bar, opposite the menu button. */
|
|
39
|
+
actions?: React.ReactNode;
|
|
40
|
+
/** Replaces the default drawer footer row (theme toggle, sign out…). */
|
|
41
|
+
drawerFooter?: React.ReactNode;
|
|
28
42
|
/** Controlled drawer state. */
|
|
29
43
|
open?: boolean;
|
|
30
44
|
onOpenChange?: (open: boolean) => void;
|
|
@@ -35,6 +49,9 @@ const cn = (...parts: Array<string | false | null | undefined>) =>
|
|
|
35
49
|
|
|
36
50
|
const focusRing = "focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-focus-blue";
|
|
37
51
|
|
|
52
|
+
/** `9+` above nine, the raw number below. */
|
|
53
|
+
const countLabel = (count: number) => (count > 9 ? "9+" : String(count));
|
|
54
|
+
|
|
38
55
|
export const SidebarMobile = React.forwardRef<HTMLElement, SidebarMobileProps>(
|
|
39
56
|
(
|
|
40
57
|
{
|
|
@@ -46,8 +63,14 @@ export const SidebarMobile = React.forwardRef<HTMLElement, SidebarMobileProps>(
|
|
|
46
63
|
sections = defaultSidebarSections,
|
|
47
64
|
promo = defaultSidebarPromo,
|
|
48
65
|
userName = "Alex Smith",
|
|
66
|
+
userAvatarSrc,
|
|
67
|
+
onUserClick,
|
|
68
|
+
notificationCount = 0,
|
|
49
69
|
onSettingsClick,
|
|
50
70
|
onNotificationsClick,
|
|
71
|
+
onNavigate,
|
|
72
|
+
actions,
|
|
73
|
+
drawerFooter,
|
|
51
74
|
open: openProp,
|
|
52
75
|
onOpenChange,
|
|
53
76
|
className,
|
|
@@ -60,6 +83,8 @@ export const SidebarMobile = React.forwardRef<HTMLElement, SidebarMobileProps>(
|
|
|
60
83
|
const open = openProp ?? inner;
|
|
61
84
|
const org = organization ?? orgInner;
|
|
62
85
|
const navId = React.useId();
|
|
86
|
+
const unread = notificationCount > 0;
|
|
87
|
+
const bellLabel = unread ? `Notifications, ${notificationCount} unread` : "Notifications";
|
|
63
88
|
const setOpen = React.useCallback(
|
|
64
89
|
(v: boolean) => {
|
|
65
90
|
if (openProp === undefined) setInner(v);
|
|
@@ -68,9 +93,63 @@ export const SidebarMobile = React.forwardRef<HTMLElement, SidebarMobileProps>(
|
|
|
68
93
|
[openProp, onOpenChange],
|
|
69
94
|
);
|
|
70
95
|
|
|
96
|
+
const handleNavigate = (item: SidebarNavItem, event: React.MouseEvent<HTMLAnchorElement>) => {
|
|
97
|
+
onNavigate?.(item, event);
|
|
98
|
+
setOpen(false);
|
|
99
|
+
};
|
|
100
|
+
|
|
101
|
+
const promoItem: SidebarNavItem | null = promo
|
|
102
|
+
? { label: promo.title, icon: promo.icon ?? "zap", href: promo.href }
|
|
103
|
+
: null;
|
|
104
|
+
|
|
105
|
+
const defaultFooter = (
|
|
106
|
+
<div className="flex w-full items-center justify-between gap-sm">
|
|
107
|
+
{onUserClick ? (
|
|
108
|
+
<Button
|
|
109
|
+
variant="ghost"
|
|
110
|
+
size="md"
|
|
111
|
+
aria-label={`Account: ${userName}`}
|
|
112
|
+
onClick={onUserClick}
|
|
113
|
+
className="min-w-0 flex-1 justify-start gap-sm px-xs"
|
|
114
|
+
>
|
|
115
|
+
<Avatar name={userName} initials={userName.charAt(0)} src={userAvatarSrc} size="md" />
|
|
116
|
+
<span className="min-w-0 truncate text-body-md text-ink">{userName}</span>
|
|
117
|
+
</Button>
|
|
118
|
+
) : (
|
|
119
|
+
<span className="flex min-w-0 items-center gap-sm">
|
|
120
|
+
<Avatar name={userName} initials={userName.charAt(0)} src={userAvatarSrc} size="md" />
|
|
121
|
+
<span className="truncate text-body-md text-ink">{userName}</span>
|
|
122
|
+
</span>
|
|
123
|
+
)}
|
|
124
|
+
{onSettingsClick || onNotificationsClick ? (
|
|
125
|
+
<span className="flex items-center gap-xxs">
|
|
126
|
+
{onSettingsClick ? (
|
|
127
|
+
<IconButton icon="settings" aria-label="Settings" variant="ghost" size="md" onClick={onSettingsClick} />
|
|
128
|
+
) : null}
|
|
129
|
+
{onNotificationsClick ? (
|
|
130
|
+
<span className="relative inline-flex">
|
|
131
|
+
<IconButton icon="bell" aria-label={bellLabel} variant="ghost" size="md" onClick={onNotificationsClick} />
|
|
132
|
+
{unread ? (
|
|
133
|
+
<Badge
|
|
134
|
+
aria-hidden="true"
|
|
135
|
+
variant="solid"
|
|
136
|
+
tone="error"
|
|
137
|
+
size="sm"
|
|
138
|
+
className="pointer-events-none absolute -right-xxs -top-xxs"
|
|
139
|
+
>
|
|
140
|
+
{countLabel(notificationCount)}
|
|
141
|
+
</Badge>
|
|
142
|
+
) : null}
|
|
143
|
+
</span>
|
|
144
|
+
) : null}
|
|
145
|
+
</span>
|
|
146
|
+
) : null}
|
|
147
|
+
</div>
|
|
148
|
+
);
|
|
149
|
+
|
|
71
150
|
return (
|
|
72
151
|
<header ref={ref} className={cn("w-full", className)} {...props}>
|
|
73
|
-
<div className="relative flex h-14 w-full items-center rounded-lg border border-hairline bg-canvas px-sm text-ink">
|
|
152
|
+
<div className="relative flex h-14 w-full items-center justify-between rounded-lg border border-hairline bg-canvas px-sm text-ink">
|
|
74
153
|
<Button
|
|
75
154
|
variant="ghost"
|
|
76
155
|
size="lg"
|
|
@@ -87,6 +166,7 @@ export const SidebarMobile = React.forwardRef<HTMLElement, SidebarMobileProps>(
|
|
|
87
166
|
<Logo name={brandName} href={brandHref} size="md" />
|
|
88
167
|
</span>
|
|
89
168
|
</span>
|
|
169
|
+
{actions ? <span className="relative z-10 flex shrink-0 items-center gap-xs">{actions}</span> : null}
|
|
90
170
|
</div>
|
|
91
171
|
|
|
92
172
|
<Drawer
|
|
@@ -96,18 +176,7 @@ export const SidebarMobile = React.forwardRef<HTMLElement, SidebarMobileProps>(
|
|
|
96
176
|
side="left"
|
|
97
177
|
title={<Logo name={brandName} size="md" />}
|
|
98
178
|
aria-label={brandName}
|
|
99
|
-
footer={
|
|
100
|
-
<div className="flex w-full items-center justify-between gap-sm">
|
|
101
|
-
<span className="flex min-w-0 items-center gap-sm">
|
|
102
|
-
<Avatar name={userName} initials={userName.charAt(0)} size="md" />
|
|
103
|
-
<span className="truncate text-body-md text-ink">{userName}</span>
|
|
104
|
-
</span>
|
|
105
|
-
<span className="flex items-center gap-xxs">
|
|
106
|
-
<IconButton icon="settings" aria-label="Settings" variant="ghost" size="md" onClick={onSettingsClick} />
|
|
107
|
-
<IconButton icon="bell" aria-label="Notifications" variant="ghost" size="md" onClick={onNotificationsClick} />
|
|
108
|
-
</span>
|
|
109
|
-
</div>
|
|
110
|
-
}
|
|
179
|
+
footer={drawerFooter ?? defaultFooter}
|
|
111
180
|
>
|
|
112
181
|
<div className="flex flex-col gap-base">
|
|
113
182
|
<Dropdown
|
|
@@ -126,32 +195,42 @@ export const SidebarMobile = React.forwardRef<HTMLElement, SidebarMobileProps>(
|
|
|
126
195
|
<span className="px-sm pb-xxs text-caption text-muted">{section.label}</span>
|
|
127
196
|
) : null}
|
|
128
197
|
<ul className="flex flex-col gap-xxs">
|
|
129
|
-
{section.items.map((item) =>
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
198
|
+
{section.items.map((item) => {
|
|
199
|
+
const hasBadge =
|
|
200
|
+
item.badge !== undefined && item.badge !== null && item.badge !== "";
|
|
201
|
+
return (
|
|
202
|
+
<li key={item.label}>
|
|
203
|
+
<a
|
|
204
|
+
href={item.href}
|
|
205
|
+
aria-current={item.active ? "page" : undefined}
|
|
206
|
+
onClick={(event) => handleNavigate(item, event)}
|
|
207
|
+
className={cn(
|
|
208
|
+
"flex h-9 w-full cursor-pointer items-center gap-sm rounded-sm px-sm text-body-md transition-colors duration-150 ease-out",
|
|
209
|
+
focusRing,
|
|
210
|
+
item.active
|
|
211
|
+
? "bg-surface-strong text-ink"
|
|
212
|
+
: "text-ink hover:bg-surface-soft active:bg-surface-strong",
|
|
213
|
+
)}
|
|
214
|
+
>
|
|
215
|
+
<Icon name={item.icon} size={18} className="text-body" />
|
|
216
|
+
<span className="min-w-0 flex-1 truncate">{item.label}</span>
|
|
217
|
+
{hasBadge ? (
|
|
218
|
+
<Badge size="sm" className="ml-auto">
|
|
219
|
+
{item.badge}
|
|
220
|
+
</Badge>
|
|
221
|
+
) : null}
|
|
222
|
+
</a>
|
|
223
|
+
</li>
|
|
224
|
+
);
|
|
225
|
+
})}
|
|
148
226
|
</ul>
|
|
149
227
|
</div>
|
|
150
228
|
))}
|
|
151
229
|
</nav>
|
|
152
|
-
{promo ? (
|
|
230
|
+
{promo && promoItem ? (
|
|
153
231
|
<a
|
|
154
232
|
href={promo.href}
|
|
233
|
+
onClick={(event) => handleNavigate(promoItem, event)}
|
|
155
234
|
className={cn(
|
|
156
235
|
"group flex cursor-pointer items-center gap-sm rounded-md border border-hairline px-md py-sm transition-colors duration-150 ease-out hover:bg-surface-soft active:bg-surface-strong",
|
|
157
236
|
focusRing,
|