@designa8/vibedesign-linear-internal-v1-b737 0.12.4 → 0.12.5
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 +78 -13
- package/dist/index.js +78 -13
- package/package.json +1 -1
- package/src/organisms/Sidebar/Sidebar.tsx +10 -0
- package/src/organisms/Sidebar/preview.tsx +51 -23
- package/src/organisms/SidebarDesktop/SidebarDesktop.tsx +64 -13
- package/src/organisms/SidebarMobile/SidebarMobile.tsx +48 -3
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# @designa8/vibedesign-linear-internal-v1-b737
|
|
2
2
|
|
|
3
|
-
Complete design system generated by Atoms Design, version **0.12.
|
|
3
|
+
Complete design system generated by Atoms Design, version **0.12.5**.
|
|
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
|
@@ -11711,6 +11711,8 @@ var SidebarDesktop = React91.forwardRef(
|
|
|
11711
11711
|
workspaceName,
|
|
11712
11712
|
workspaceAvatarSrc,
|
|
11713
11713
|
onWorkspaceClick,
|
|
11714
|
+
workspaceMenuItems,
|
|
11715
|
+
workspaceMenuHeader,
|
|
11714
11716
|
workspacePlacement = "top",
|
|
11715
11717
|
headerActions,
|
|
11716
11718
|
sections,
|
|
@@ -11738,6 +11740,7 @@ var SidebarDesktop = React91.forwardRef(
|
|
|
11738
11740
|
if (collapsedProp === void 0) setInnerCollapsed(next);
|
|
11739
11741
|
onCollapsedChange?.(next);
|
|
11740
11742
|
};
|
|
11743
|
+
const [workspaceMenuOpen, setWorkspaceMenuOpen] = React91.useState(false);
|
|
11741
11744
|
const [expanded, setExpanded] = React91.useState(
|
|
11742
11745
|
() => new Set(
|
|
11743
11746
|
defaultExpanded ?? sections.filter((s) => s.label).map((s) => s.id)
|
|
@@ -11847,6 +11850,23 @@ var SidebarDesktop = React91.forwardRef(
|
|
|
11847
11850
|
const renderItem = (link) => link.children?.length ? renderGroup(link) : renderLink(link);
|
|
11848
11851
|
const showWorkspaceRow = Boolean(workspaceName) || !collapsed && headerActions != null;
|
|
11849
11852
|
const workspaceAtBottom = workspacePlacement === "bottom";
|
|
11853
|
+
const workspaceMenuMode = workspaceMenuItems !== void 0;
|
|
11854
|
+
const workspaceOnClick = workspaceMenuMode ? void 0 : onWorkspaceClick;
|
|
11855
|
+
const workspaceChevronOpen = workspaceMenuMode && workspaceMenuOpen;
|
|
11856
|
+
const withWorkspaceMenu = (button, wrapperClassName) => workspaceMenuMode ? /* @__PURE__ */ (0, import_jsx_runtime91.jsx)(
|
|
11857
|
+
DropdownMenu,
|
|
11858
|
+
{
|
|
11859
|
+
trigger: button,
|
|
11860
|
+
items: workspaceMenuItems ?? [],
|
|
11861
|
+
header: workspaceMenuHeader,
|
|
11862
|
+
align: "start",
|
|
11863
|
+
side: workspaceAtBottom ? "top" : "bottom",
|
|
11864
|
+
open: workspaceMenuOpen,
|
|
11865
|
+
onOpenChange: setWorkspaceMenuOpen,
|
|
11866
|
+
"aria-label": "Workspace",
|
|
11867
|
+
className: wrapperClassName
|
|
11868
|
+
}
|
|
11869
|
+
) : button;
|
|
11850
11870
|
const workspaceRow = showWorkspaceRow ? /* @__PURE__ */ (0, import_jsx_runtime91.jsxs)(
|
|
11851
11871
|
"div",
|
|
11852
11872
|
{
|
|
@@ -11856,16 +11876,32 @@ var SidebarDesktop = React91.forwardRef(
|
|
|
11856
11876
|
workspaceAtBottom ? "border-t border-hairline py-sm" : "pb-sm"
|
|
11857
11877
|
),
|
|
11858
11878
|
children: [
|
|
11859
|
-
workspaceName ? collapsed ?
|
|
11860
|
-
Button,
|
|
11861
|
-
|
|
11862
|
-
|
|
11863
|
-
|
|
11864
|
-
|
|
11865
|
-
|
|
11866
|
-
|
|
11867
|
-
|
|
11868
|
-
|
|
11879
|
+
workspaceName ? collapsed ? withWorkspaceMenu(
|
|
11880
|
+
/* @__PURE__ */ (0, import_jsx_runtime91.jsx)(Button, { variant: "ghost", iconOnly: true, "aria-label": workspaceName, onClick: workspaceOnClick, children: /* @__PURE__ */ (0, import_jsx_runtime91.jsx)(Avatar, { name: workspaceName, src: workspaceAvatarSrc, size: "sm" }) }),
|
|
11881
|
+
"shrink-0"
|
|
11882
|
+
) : withWorkspaceMenu(
|
|
11883
|
+
/* @__PURE__ */ (0, import_jsx_runtime91.jsx)(
|
|
11884
|
+
Button,
|
|
11885
|
+
{
|
|
11886
|
+
variant: "ghost",
|
|
11887
|
+
onClick: workspaceOnClick,
|
|
11888
|
+
className: "min-w-0 flex-1 justify-start px-sm",
|
|
11889
|
+
leadingIcon: /* @__PURE__ */ (0, import_jsx_runtime91.jsx)(Avatar, { name: workspaceName, src: workspaceAvatarSrc, size: "sm" }),
|
|
11890
|
+
trailingIcon: /* @__PURE__ */ (0, import_jsx_runtime91.jsx)(
|
|
11891
|
+
Icon,
|
|
11892
|
+
{
|
|
11893
|
+
name: "chevron-down",
|
|
11894
|
+
size: 14,
|
|
11895
|
+
className: cn70(
|
|
11896
|
+
"text-muted transition-transform duration-200 ease-out",
|
|
11897
|
+
workspaceChevronOpen && "rotate-180"
|
|
11898
|
+
)
|
|
11899
|
+
}
|
|
11900
|
+
),
|
|
11901
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime91.jsx)("span", { className: "min-w-0 truncate text-ink", children: workspaceName })
|
|
11902
|
+
}
|
|
11903
|
+
),
|
|
11904
|
+
"min-w-0 flex-1"
|
|
11869
11905
|
) : /* @__PURE__ */ (0, import_jsx_runtime91.jsx)("span", { className: "min-w-0 flex-1" }),
|
|
11870
11906
|
!collapsed && headerActions != null && /* @__PURE__ */ (0, import_jsx_runtime91.jsx)("div", { className: "flex shrink-0 items-center gap-xxs", children: headerActions })
|
|
11871
11907
|
]
|
|
@@ -11980,6 +12016,8 @@ var SidebarMobile = React92.forwardRef(
|
|
|
11980
12016
|
workspaceName,
|
|
11981
12017
|
workspaceAvatarSrc,
|
|
11982
12018
|
onWorkspaceClick,
|
|
12019
|
+
workspaceMenuItems,
|
|
12020
|
+
workspaceMenuHeader,
|
|
11983
12021
|
workspacePlacement = "top",
|
|
11984
12022
|
mobileActions,
|
|
11985
12023
|
sections,
|
|
@@ -12018,6 +12056,7 @@ var SidebarMobile = React92.forwardRef(
|
|
|
12018
12056
|
else next.add(id);
|
|
12019
12057
|
return next;
|
|
12020
12058
|
});
|
|
12059
|
+
const [workspaceMenuOpen, setWorkspaceMenuOpen] = React92.useState(false);
|
|
12021
12060
|
const showHelpAction = onHelpClick !== void 0;
|
|
12022
12061
|
const showSettingsAction = onSettingsClick !== void 0;
|
|
12023
12062
|
const showFooterActions = showHelpAction || showSettingsAction;
|
|
@@ -12086,17 +12125,43 @@ var SidebarMobile = React92.forwardRef(
|
|
|
12086
12125
|
)
|
|
12087
12126
|
] }, link.id);
|
|
12088
12127
|
};
|
|
12089
|
-
const
|
|
12128
|
+
const workspaceMenuMode = workspaceMenuItems !== void 0;
|
|
12129
|
+
const workspaceButtonNode = workspaceName ? /* @__PURE__ */ (0, import_jsx_runtime92.jsx)(
|
|
12090
12130
|
Button,
|
|
12091
12131
|
{
|
|
12092
12132
|
variant: "ghost",
|
|
12093
|
-
onClick: onWorkspaceClick,
|
|
12133
|
+
onClick: workspaceMenuMode ? void 0 : onWorkspaceClick,
|
|
12094
12134
|
className: "px-sm",
|
|
12135
|
+
fullWidth: workspaceMenuMode,
|
|
12095
12136
|
leadingIcon: /* @__PURE__ */ (0, import_jsx_runtime92.jsx)(Avatar, { name: workspaceName, src: workspaceAvatarSrc, size: "sm" }),
|
|
12096
|
-
trailingIcon: /* @__PURE__ */ (0, import_jsx_runtime92.jsx)(
|
|
12137
|
+
trailingIcon: /* @__PURE__ */ (0, import_jsx_runtime92.jsx)(
|
|
12138
|
+
Icon,
|
|
12139
|
+
{
|
|
12140
|
+
name: "chevron-down",
|
|
12141
|
+
size: 14,
|
|
12142
|
+
className: cn71(
|
|
12143
|
+
"text-muted transition-transform duration-200 ease-out",
|
|
12144
|
+
workspaceMenuMode && workspaceMenuOpen && "rotate-180"
|
|
12145
|
+
)
|
|
12146
|
+
}
|
|
12147
|
+
),
|
|
12097
12148
|
children: /* @__PURE__ */ (0, import_jsx_runtime92.jsx)("span", { className: "text-ink", children: workspaceName })
|
|
12098
12149
|
}
|
|
12099
12150
|
) : null;
|
|
12151
|
+
const workspaceButton = workspaceButtonNode && workspaceMenuMode ? /* @__PURE__ */ (0, import_jsx_runtime92.jsx)(
|
|
12152
|
+
DropdownMenu,
|
|
12153
|
+
{
|
|
12154
|
+
trigger: workspaceButtonNode,
|
|
12155
|
+
items: workspaceMenuItems ?? [],
|
|
12156
|
+
header: workspaceMenuHeader,
|
|
12157
|
+
align: "start",
|
|
12158
|
+
side: workspaceAtBottom ? "top" : "bottom",
|
|
12159
|
+
open: workspaceMenuOpen,
|
|
12160
|
+
onOpenChange: setWorkspaceMenuOpen,
|
|
12161
|
+
"aria-label": "Workspace",
|
|
12162
|
+
className: "w-full"
|
|
12163
|
+
}
|
|
12164
|
+
) : workspaceButtonNode;
|
|
12100
12165
|
const userRow = showFooterRow ? /* @__PURE__ */ (0, import_jsx_runtime92.jsxs)("div", { className: "flex w-full items-center justify-between", children: [
|
|
12101
12166
|
userName ? /* @__PURE__ */ (0, import_jsx_runtime92.jsx)(Avatar, { name: userName, src: userAvatarSrc, size: "sm" }) : /* @__PURE__ */ (0, import_jsx_runtime92.jsx)("span", {}),
|
|
12102
12167
|
showFooterActions && /* @__PURE__ */ (0, import_jsx_runtime92.jsxs)("div", { className: "flex items-center gap-xxs", children: [
|
package/dist/index.js
CHANGED
|
@@ -11566,6 +11566,8 @@ var SidebarDesktop = React91.forwardRef(
|
|
|
11566
11566
|
workspaceName,
|
|
11567
11567
|
workspaceAvatarSrc,
|
|
11568
11568
|
onWorkspaceClick,
|
|
11569
|
+
workspaceMenuItems,
|
|
11570
|
+
workspaceMenuHeader,
|
|
11569
11571
|
workspacePlacement = "top",
|
|
11570
11572
|
headerActions,
|
|
11571
11573
|
sections,
|
|
@@ -11593,6 +11595,7 @@ var SidebarDesktop = React91.forwardRef(
|
|
|
11593
11595
|
if (collapsedProp === void 0) setInnerCollapsed(next);
|
|
11594
11596
|
onCollapsedChange?.(next);
|
|
11595
11597
|
};
|
|
11598
|
+
const [workspaceMenuOpen, setWorkspaceMenuOpen] = React91.useState(false);
|
|
11596
11599
|
const [expanded, setExpanded] = React91.useState(
|
|
11597
11600
|
() => new Set(
|
|
11598
11601
|
defaultExpanded ?? sections.filter((s) => s.label).map((s) => s.id)
|
|
@@ -11702,6 +11705,23 @@ var SidebarDesktop = React91.forwardRef(
|
|
|
11702
11705
|
const renderItem = (link) => link.children?.length ? renderGroup(link) : renderLink(link);
|
|
11703
11706
|
const showWorkspaceRow = Boolean(workspaceName) || !collapsed && headerActions != null;
|
|
11704
11707
|
const workspaceAtBottom = workspacePlacement === "bottom";
|
|
11708
|
+
const workspaceMenuMode = workspaceMenuItems !== void 0;
|
|
11709
|
+
const workspaceOnClick = workspaceMenuMode ? void 0 : onWorkspaceClick;
|
|
11710
|
+
const workspaceChevronOpen = workspaceMenuMode && workspaceMenuOpen;
|
|
11711
|
+
const withWorkspaceMenu = (button, wrapperClassName) => workspaceMenuMode ? /* @__PURE__ */ jsx91(
|
|
11712
|
+
DropdownMenu,
|
|
11713
|
+
{
|
|
11714
|
+
trigger: button,
|
|
11715
|
+
items: workspaceMenuItems ?? [],
|
|
11716
|
+
header: workspaceMenuHeader,
|
|
11717
|
+
align: "start",
|
|
11718
|
+
side: workspaceAtBottom ? "top" : "bottom",
|
|
11719
|
+
open: workspaceMenuOpen,
|
|
11720
|
+
onOpenChange: setWorkspaceMenuOpen,
|
|
11721
|
+
"aria-label": "Workspace",
|
|
11722
|
+
className: wrapperClassName
|
|
11723
|
+
}
|
|
11724
|
+
) : button;
|
|
11705
11725
|
const workspaceRow = showWorkspaceRow ? /* @__PURE__ */ jsxs83(
|
|
11706
11726
|
"div",
|
|
11707
11727
|
{
|
|
@@ -11711,16 +11731,32 @@ var SidebarDesktop = React91.forwardRef(
|
|
|
11711
11731
|
workspaceAtBottom ? "border-t border-hairline py-sm" : "pb-sm"
|
|
11712
11732
|
),
|
|
11713
11733
|
children: [
|
|
11714
|
-
workspaceName ? collapsed ?
|
|
11715
|
-
Button,
|
|
11716
|
-
|
|
11717
|
-
|
|
11718
|
-
|
|
11719
|
-
|
|
11720
|
-
|
|
11721
|
-
|
|
11722
|
-
|
|
11723
|
-
|
|
11734
|
+
workspaceName ? collapsed ? withWorkspaceMenu(
|
|
11735
|
+
/* @__PURE__ */ jsx91(Button, { variant: "ghost", iconOnly: true, "aria-label": workspaceName, onClick: workspaceOnClick, children: /* @__PURE__ */ jsx91(Avatar, { name: workspaceName, src: workspaceAvatarSrc, size: "sm" }) }),
|
|
11736
|
+
"shrink-0"
|
|
11737
|
+
) : withWorkspaceMenu(
|
|
11738
|
+
/* @__PURE__ */ jsx91(
|
|
11739
|
+
Button,
|
|
11740
|
+
{
|
|
11741
|
+
variant: "ghost",
|
|
11742
|
+
onClick: workspaceOnClick,
|
|
11743
|
+
className: "min-w-0 flex-1 justify-start px-sm",
|
|
11744
|
+
leadingIcon: /* @__PURE__ */ jsx91(Avatar, { name: workspaceName, src: workspaceAvatarSrc, size: "sm" }),
|
|
11745
|
+
trailingIcon: /* @__PURE__ */ jsx91(
|
|
11746
|
+
Icon,
|
|
11747
|
+
{
|
|
11748
|
+
name: "chevron-down",
|
|
11749
|
+
size: 14,
|
|
11750
|
+
className: cn70(
|
|
11751
|
+
"text-muted transition-transform duration-200 ease-out",
|
|
11752
|
+
workspaceChevronOpen && "rotate-180"
|
|
11753
|
+
)
|
|
11754
|
+
}
|
|
11755
|
+
),
|
|
11756
|
+
children: /* @__PURE__ */ jsx91("span", { className: "min-w-0 truncate text-ink", children: workspaceName })
|
|
11757
|
+
}
|
|
11758
|
+
),
|
|
11759
|
+
"min-w-0 flex-1"
|
|
11724
11760
|
) : /* @__PURE__ */ jsx91("span", { className: "min-w-0 flex-1" }),
|
|
11725
11761
|
!collapsed && headerActions != null && /* @__PURE__ */ jsx91("div", { className: "flex shrink-0 items-center gap-xxs", children: headerActions })
|
|
11726
11762
|
]
|
|
@@ -11835,6 +11871,8 @@ var SidebarMobile = React92.forwardRef(
|
|
|
11835
11871
|
workspaceName,
|
|
11836
11872
|
workspaceAvatarSrc,
|
|
11837
11873
|
onWorkspaceClick,
|
|
11874
|
+
workspaceMenuItems,
|
|
11875
|
+
workspaceMenuHeader,
|
|
11838
11876
|
workspacePlacement = "top",
|
|
11839
11877
|
mobileActions,
|
|
11840
11878
|
sections,
|
|
@@ -11873,6 +11911,7 @@ var SidebarMobile = React92.forwardRef(
|
|
|
11873
11911
|
else next.add(id);
|
|
11874
11912
|
return next;
|
|
11875
11913
|
});
|
|
11914
|
+
const [workspaceMenuOpen, setWorkspaceMenuOpen] = React92.useState(false);
|
|
11876
11915
|
const showHelpAction = onHelpClick !== void 0;
|
|
11877
11916
|
const showSettingsAction = onSettingsClick !== void 0;
|
|
11878
11917
|
const showFooterActions = showHelpAction || showSettingsAction;
|
|
@@ -11941,17 +11980,43 @@ var SidebarMobile = React92.forwardRef(
|
|
|
11941
11980
|
)
|
|
11942
11981
|
] }, link.id);
|
|
11943
11982
|
};
|
|
11944
|
-
const
|
|
11983
|
+
const workspaceMenuMode = workspaceMenuItems !== void 0;
|
|
11984
|
+
const workspaceButtonNode = workspaceName ? /* @__PURE__ */ jsx92(
|
|
11945
11985
|
Button,
|
|
11946
11986
|
{
|
|
11947
11987
|
variant: "ghost",
|
|
11948
|
-
onClick: onWorkspaceClick,
|
|
11988
|
+
onClick: workspaceMenuMode ? void 0 : onWorkspaceClick,
|
|
11949
11989
|
className: "px-sm",
|
|
11990
|
+
fullWidth: workspaceMenuMode,
|
|
11950
11991
|
leadingIcon: /* @__PURE__ */ jsx92(Avatar, { name: workspaceName, src: workspaceAvatarSrc, size: "sm" }),
|
|
11951
|
-
trailingIcon: /* @__PURE__ */ jsx92(
|
|
11992
|
+
trailingIcon: /* @__PURE__ */ jsx92(
|
|
11993
|
+
Icon,
|
|
11994
|
+
{
|
|
11995
|
+
name: "chevron-down",
|
|
11996
|
+
size: 14,
|
|
11997
|
+
className: cn71(
|
|
11998
|
+
"text-muted transition-transform duration-200 ease-out",
|
|
11999
|
+
workspaceMenuMode && workspaceMenuOpen && "rotate-180"
|
|
12000
|
+
)
|
|
12001
|
+
}
|
|
12002
|
+
),
|
|
11952
12003
|
children: /* @__PURE__ */ jsx92("span", { className: "text-ink", children: workspaceName })
|
|
11953
12004
|
}
|
|
11954
12005
|
) : null;
|
|
12006
|
+
const workspaceButton = workspaceButtonNode && workspaceMenuMode ? /* @__PURE__ */ jsx92(
|
|
12007
|
+
DropdownMenu,
|
|
12008
|
+
{
|
|
12009
|
+
trigger: workspaceButtonNode,
|
|
12010
|
+
items: workspaceMenuItems ?? [],
|
|
12011
|
+
header: workspaceMenuHeader,
|
|
12012
|
+
align: "start",
|
|
12013
|
+
side: workspaceAtBottom ? "top" : "bottom",
|
|
12014
|
+
open: workspaceMenuOpen,
|
|
12015
|
+
onOpenChange: setWorkspaceMenuOpen,
|
|
12016
|
+
"aria-label": "Workspace",
|
|
12017
|
+
className: "w-full"
|
|
12018
|
+
}
|
|
12019
|
+
) : workspaceButtonNode;
|
|
11955
12020
|
const userRow = showFooterRow ? /* @__PURE__ */ jsxs84("div", { className: "flex w-full items-center justify-between", children: [
|
|
11956
12021
|
userName ? /* @__PURE__ */ jsx92(Avatar, { name: userName, src: userAvatarSrc, size: "sm" }) : /* @__PURE__ */ jsx92("span", {}),
|
|
11957
12022
|
showFooterActions && /* @__PURE__ */ jsxs84("div", { className: "flex items-center gap-xxs", children: [
|
package/package.json
CHANGED
|
@@ -2,6 +2,7 @@ import * as React from "react";
|
|
|
2
2
|
import { SidebarDesktop } from "../SidebarDesktop";
|
|
3
3
|
import { SidebarMobile } from "../SidebarMobile";
|
|
4
4
|
import type { IconName } from "../../atoms/Icon";
|
|
5
|
+
import type { DropdownMenuEntry } from "../../molecules/DropdownMenu";
|
|
5
6
|
|
|
6
7
|
export interface SidebarLink {
|
|
7
8
|
id: string;
|
|
@@ -25,6 +26,15 @@ export interface SidebarProps {
|
|
|
25
26
|
workspaceName?: string;
|
|
26
27
|
workspaceAvatarSrc?: string;
|
|
27
28
|
onWorkspaceClick?: () => void;
|
|
29
|
+
/**
|
|
30
|
+
* Entries for the workspace switcher menu. When provided, the workspace button
|
|
31
|
+
* (avatar + name + chevron in both placements, and the avatar-only button in the
|
|
32
|
+
* folded rail) becomes the trigger of a `DropdownMenu` with these entries, instead
|
|
33
|
+
* of calling `onWorkspaceClick`. Omit it to keep the plain click behaviour.
|
|
34
|
+
*/
|
|
35
|
+
workspaceMenuItems?: DropdownMenuEntry[];
|
|
36
|
+
/** Optional block pinned above the workspace menu's actions, like `DropdownMenu`'s `header`. */
|
|
37
|
+
workspaceMenuHeader?: React.ReactNode;
|
|
28
38
|
/**
|
|
29
39
|
* Where the workspace row (avatar, name, chevron plus `headerActions`) renders.
|
|
30
40
|
* Defaults to `"top"` — directly under the logo. `"bottom"` pins it to the end of
|
|
@@ -4,6 +4,7 @@ import { SidebarMobile } from "../SidebarMobile";
|
|
|
4
4
|
import { IconButton } from "../../atoms/IconButton";
|
|
5
5
|
import { Avatar } from "../../atoms/Avatar";
|
|
6
6
|
import type { SidebarSection } from "./Sidebar";
|
|
7
|
+
import type { DropdownMenuEntry } from "../../molecules/DropdownMenu";
|
|
7
8
|
|
|
8
9
|
const SECTIONS: SidebarSection[] = [
|
|
9
10
|
{
|
|
@@ -29,11 +30,6 @@ const SECTIONS: SidebarSection[] = [
|
|
|
29
30
|
},
|
|
30
31
|
],
|
|
31
32
|
},
|
|
32
|
-
{
|
|
33
|
-
id: "try",
|
|
34
|
-
label: "Try",
|
|
35
|
-
items: [{ id: "import", label: "Import issues", icon: "copy" }],
|
|
36
|
-
},
|
|
37
33
|
];
|
|
38
34
|
|
|
39
35
|
const HEADER_ACTIONS = (
|
|
@@ -53,10 +49,28 @@ const MOBILE_ACTIONS = (
|
|
|
53
49
|
|
|
54
50
|
const ANNOUNCEMENT = { eyebrow: "What's new", title: "Cycles 2.0 is live", href: "#" };
|
|
55
51
|
|
|
52
|
+
const WORKSPACE_MENU_HEADER = (
|
|
53
|
+
<span className="flex min-w-0 items-center gap-sm">
|
|
54
|
+
<Avatar name="Northwind Studio" size="sm" />
|
|
55
|
+
<span className="flex min-w-0 flex-col">
|
|
56
|
+
<span className="truncate text-body-sm text-ink">Northwind Studio</span>
|
|
57
|
+
<span className="truncate text-caption text-muted">ada@northwind.studio</span>
|
|
58
|
+
</span>
|
|
59
|
+
</span>
|
|
60
|
+
);
|
|
61
|
+
|
|
62
|
+
const WORKSPACE_MENU_ITEMS: DropdownMenuEntry[] = [
|
|
63
|
+
{ type: "label", id: "lbl-workspaces", label: "Workspaces" },
|
|
64
|
+
{ id: "northwind", label: "Northwind Studio", icon: "box", selected: true },
|
|
65
|
+
{ id: "lakeside", label: "Lakeside Labs", icon: "box" },
|
|
66
|
+
{ type: "separator", id: "sep-1" },
|
|
67
|
+
{ id: "invite", label: "Invite people", icon: "plus" },
|
|
68
|
+
];
|
|
69
|
+
|
|
56
70
|
export default function SidebarPreview() {
|
|
57
71
|
const [collapsed, setCollapsed] = React.useState(false);
|
|
58
72
|
const [mobileOpen, setMobileOpen] = React.useState(false);
|
|
59
|
-
const [active, setActive] = React.useState("issues");
|
|
73
|
+
const [active, setActive] = React.useState("my-issues");
|
|
60
74
|
|
|
61
75
|
const navigate = (link: { id: string }, e: React.MouseEvent<HTMLAnchorElement>) => {
|
|
62
76
|
e.preventDefault();
|
|
@@ -65,45 +79,59 @@ export default function SidebarPreview() {
|
|
|
65
79
|
|
|
66
80
|
const shared = {
|
|
67
81
|
sections: SECTIONS,
|
|
68
|
-
defaultExpanded: ["teams", "
|
|
82
|
+
defaultExpanded: ["teams", "engineering"],
|
|
69
83
|
activeId: active,
|
|
70
84
|
onNavigate: navigate,
|
|
71
85
|
workspaceName: "Northwind Studio",
|
|
72
86
|
userName: "Ada Fenwick",
|
|
73
87
|
};
|
|
74
88
|
|
|
89
|
+
const menu = {
|
|
90
|
+
workspaceMenuItems: WORKSPACE_MENU_ITEMS,
|
|
91
|
+
workspaceMenuHeader: WORKSPACE_MENU_HEADER,
|
|
92
|
+
};
|
|
93
|
+
|
|
75
94
|
return (
|
|
76
|
-
<div className="mx-auto w-full max-w-
|
|
95
|
+
<div className="mx-auto w-full max-w-4xl space-y-md p-md">
|
|
96
|
+
<p className="text-caption text-muted">
|
|
97
|
+
The workspace switcher opens a menu when `workspaceMenuItems` is supplied — click a switcher to try it.
|
|
98
|
+
</p>
|
|
99
|
+
|
|
77
100
|
<div className="grid w-full gap-md md:grid-cols-2">
|
|
78
101
|
<div className="w-full">
|
|
79
|
-
<p className="mb-xs text-caption text-muted">Top
|
|
80
|
-
<div className="w-full overflow-hidden rounded-lg border border-hairline" style={{ height: "
|
|
102
|
+
<p className="mb-xs text-caption text-muted">Top placement — menu opens downward</p>
|
|
103
|
+
<div className="w-full overflow-hidden rounded-lg border border-hairline" style={{ height: "15rem" }}>
|
|
81
104
|
<Sidebar
|
|
82
105
|
{...shared}
|
|
106
|
+
{...menu}
|
|
83
107
|
headerActions={HEADER_ACTIONS}
|
|
84
|
-
onHelpClick={() => {}}
|
|
85
108
|
onSettingsClick={() => {}}
|
|
86
109
|
collapsed={collapsed}
|
|
87
110
|
onCollapsedChange={setCollapsed}
|
|
88
111
|
>
|
|
89
112
|
<div className="p-md">
|
|
90
113
|
<h3 className="text-heading-sm text-ink">Issues</h3>
|
|
91
|
-
<p className="mt-xs text-body-sm text-muted">
|
|
92
|
-
Fold the rail with the panel button to see the workspace avatar-only row.
|
|
93
|
-
</p>
|
|
114
|
+
<p className="mt-xs text-body-sm text-muted">Fold the rail with the panel button to try the avatar trigger.</p>
|
|
94
115
|
</div>
|
|
95
116
|
</Sidebar>
|
|
96
117
|
</div>
|
|
97
118
|
</div>
|
|
98
119
|
|
|
99
120
|
<div className="w-full">
|
|
100
|
-
<p className="mb-xs text-caption text-muted">Bottom —
|
|
101
|
-
<div className="w-full overflow-hidden rounded-lg border border-hairline" style={{ height: "
|
|
102
|
-
<Sidebar
|
|
121
|
+
<p className="mb-xs text-caption text-muted">Bottom placement — menu opens upward</p>
|
|
122
|
+
<div className="w-full overflow-hidden rounded-lg border border-hairline" style={{ height: "15rem" }}>
|
|
123
|
+
<Sidebar
|
|
124
|
+
{...shared}
|
|
125
|
+
{...menu}
|
|
126
|
+
headerActions={HEADER_ACTIONS}
|
|
127
|
+
announcement={ANNOUNCEMENT}
|
|
128
|
+
onSettingsClick={() => {}}
|
|
129
|
+
workspacePlacement="bottom"
|
|
130
|
+
>
|
|
103
131
|
<div className="p-md">
|
|
104
132
|
<h3 className="text-heading-sm text-ink">Issues</h3>
|
|
105
133
|
<p className="mt-xs text-body-sm text-muted">
|
|
106
|
-
The
|
|
134
|
+
The workspace row stays above the user footer and opens its menu upward.
|
|
107
135
|
</p>
|
|
108
136
|
</div>
|
|
109
137
|
</Sidebar>
|
|
@@ -113,9 +141,9 @@ export default function SidebarPreview() {
|
|
|
113
141
|
|
|
114
142
|
<div className="grid w-full gap-md md:grid-cols-2">
|
|
115
143
|
<div className="w-full">
|
|
116
|
-
<p className="mb-xs text-caption text-muted">
|
|
117
|
-
<div className="w-full overflow-hidden rounded-lg border border-hairline" style={{ height: "
|
|
118
|
-
<Sidebar {...shared} onSettingsClick={() => {}} workspacePlacement="bottom" defaultCollapsed>
|
|
144
|
+
<p className="mb-xs text-caption text-muted">Folded rail — avatar trigger opens the same menu</p>
|
|
145
|
+
<div className="w-full overflow-hidden rounded-lg border border-hairline" style={{ height: "12rem" }}>
|
|
146
|
+
<Sidebar {...shared} {...menu} onSettingsClick={() => {}} workspacePlacement="bottom" defaultCollapsed>
|
|
119
147
|
<div className="p-md">
|
|
120
148
|
<h3 className="text-heading-sm text-ink">Issues</h3>
|
|
121
149
|
</div>
|
|
@@ -124,7 +152,7 @@ export default function SidebarPreview() {
|
|
|
124
152
|
</div>
|
|
125
153
|
|
|
126
154
|
<div className="w-full">
|
|
127
|
-
<p className="mb-xs text-caption text-muted">Mobile drawer —
|
|
155
|
+
<p className="mb-xs text-caption text-muted">Mobile drawer — same menu from the drawer switcher</p>
|
|
128
156
|
<div
|
|
129
157
|
className="w-full overflow-hidden rounded-lg border border-hairline"
|
|
130
158
|
style={{ maxWidth: "var(--container-sm, 24rem)" }}
|
|
@@ -137,9 +165,9 @@ export default function SidebarPreview() {
|
|
|
137
165
|
workspaceName="Northwind Studio"
|
|
138
166
|
userName="Ada Fenwick"
|
|
139
167
|
mobileActions={MOBILE_ACTIONS}
|
|
140
|
-
announcement={ANNOUNCEMENT}
|
|
141
168
|
workspacePlacement="bottom"
|
|
142
169
|
onSettingsClick={() => {}}
|
|
170
|
+
{...menu}
|
|
143
171
|
open={mobileOpen}
|
|
144
172
|
onOpenChange={setMobileOpen}
|
|
145
173
|
>
|
|
@@ -6,6 +6,8 @@ import { IconButton } from "../../atoms/IconButton";
|
|
|
6
6
|
import { Button } from "../../atoms/Button";
|
|
7
7
|
import { Avatar } from "../../atoms/Avatar";
|
|
8
8
|
import { Tooltip } from "../../atoms/Tooltip";
|
|
9
|
+
import { DropdownMenu } from "../../molecules/DropdownMenu";
|
|
10
|
+
import type { DropdownMenuEntry } from "../../molecules/DropdownMenu";
|
|
9
11
|
|
|
10
12
|
export interface SidebarDesktopLink {
|
|
11
13
|
id: string;
|
|
@@ -31,6 +33,15 @@ export interface SidebarDesktopProps extends React.HTMLAttributes<HTMLDivElement
|
|
|
31
33
|
workspaceName?: string;
|
|
32
34
|
workspaceAvatarSrc?: string;
|
|
33
35
|
onWorkspaceClick?: () => void;
|
|
36
|
+
/**
|
|
37
|
+
* Entries for the workspace switcher menu. When provided, the workspace button
|
|
38
|
+
* (avatar + name + chevron, or the avatar-only rail button) becomes the trigger
|
|
39
|
+
* of a `DropdownMenu` with these entries — and `onWorkspaceClick` is no longer
|
|
40
|
+
* called. Omit it to keep the plain click behaviour.
|
|
41
|
+
*/
|
|
42
|
+
workspaceMenuItems?: DropdownMenuEntry[];
|
|
43
|
+
/** Optional block pinned above the workspace menu's actions, like `DropdownMenu`'s `header`. */
|
|
44
|
+
workspaceMenuHeader?: React.ReactNode;
|
|
34
45
|
/**
|
|
35
46
|
* Where the workspace row (avatar, name, chevron plus `headerActions`) renders.
|
|
36
47
|
* `"top"` is the default: directly under the logo. `"bottom"` pins it to the end
|
|
@@ -89,6 +100,8 @@ export const SidebarDesktop = React.forwardRef<HTMLDivElement, SidebarDesktopPro
|
|
|
89
100
|
workspaceName,
|
|
90
101
|
workspaceAvatarSrc,
|
|
91
102
|
onWorkspaceClick,
|
|
103
|
+
workspaceMenuItems,
|
|
104
|
+
workspaceMenuHeader,
|
|
92
105
|
workspacePlacement = "top",
|
|
93
106
|
headerActions,
|
|
94
107
|
sections,
|
|
@@ -119,6 +132,9 @@ export const SidebarDesktop = React.forwardRef<HTMLDivElement, SidebarDesktopPro
|
|
|
119
132
|
onCollapsedChange?.(next);
|
|
120
133
|
};
|
|
121
134
|
|
|
135
|
+
/** Open state of the workspace switcher menu, so the chevron can follow it. */
|
|
136
|
+
const [workspaceMenuOpen, setWorkspaceMenuOpen] = React.useState(false);
|
|
137
|
+
|
|
122
138
|
const [expanded, setExpanded] = React.useState<Set<string>>(
|
|
123
139
|
() =>
|
|
124
140
|
new Set(
|
|
@@ -258,6 +274,28 @@ export const SidebarDesktop = React.forwardRef<HTMLDivElement, SidebarDesktopPro
|
|
|
258
274
|
const showWorkspaceRow = Boolean(workspaceName) || (!collapsed && headerActions != null);
|
|
259
275
|
const workspaceAtBottom = workspacePlacement === "bottom";
|
|
260
276
|
|
|
277
|
+
/** Menu mode: the workspace button becomes the dropdown trigger instead of a click. */
|
|
278
|
+
const workspaceMenuMode = workspaceMenuItems !== undefined;
|
|
279
|
+
const workspaceOnClick = workspaceMenuMode ? undefined : onWorkspaceClick;
|
|
280
|
+
const workspaceChevronOpen = workspaceMenuMode && workspaceMenuOpen;
|
|
281
|
+
|
|
282
|
+
const withWorkspaceMenu = (button: React.ReactElement, wrapperClassName: string) =>
|
|
283
|
+
workspaceMenuMode ? (
|
|
284
|
+
<DropdownMenu
|
|
285
|
+
trigger={button}
|
|
286
|
+
items={workspaceMenuItems ?? []}
|
|
287
|
+
header={workspaceMenuHeader}
|
|
288
|
+
align="start"
|
|
289
|
+
side={workspaceAtBottom ? "top" : "bottom"}
|
|
290
|
+
open={workspaceMenuOpen}
|
|
291
|
+
onOpenChange={setWorkspaceMenuOpen}
|
|
292
|
+
aria-label="Workspace"
|
|
293
|
+
className={wrapperClassName}
|
|
294
|
+
/>
|
|
295
|
+
) : (
|
|
296
|
+
button
|
|
297
|
+
);
|
|
298
|
+
|
|
261
299
|
const workspaceRow = showWorkspaceRow ? (
|
|
262
300
|
<div
|
|
263
301
|
className={cn(
|
|
@@ -268,21 +306,34 @@ export const SidebarDesktop = React.forwardRef<HTMLDivElement, SidebarDesktopPro
|
|
|
268
306
|
>
|
|
269
307
|
{workspaceName ? (
|
|
270
308
|
collapsed ? (
|
|
271
|
-
|
|
272
|
-
<Button variant="ghost" iconOnly aria-label={workspaceName} onClick={
|
|
309
|
+
withWorkspaceMenu(
|
|
310
|
+
<Button variant="ghost" iconOnly aria-label={workspaceName} onClick={workspaceOnClick}>
|
|
273
311
|
<Avatar name={workspaceName} src={workspaceAvatarSrc} size="sm" />
|
|
274
|
-
</Button
|
|
275
|
-
|
|
312
|
+
</Button>,
|
|
313
|
+
"shrink-0",
|
|
314
|
+
)
|
|
276
315
|
) : (
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
316
|
+
withWorkspaceMenu(
|
|
317
|
+
<Button
|
|
318
|
+
variant="ghost"
|
|
319
|
+
onClick={workspaceOnClick}
|
|
320
|
+
className="min-w-0 flex-1 justify-start px-sm"
|
|
321
|
+
leadingIcon={<Avatar name={workspaceName} src={workspaceAvatarSrc} size="sm" />}
|
|
322
|
+
trailingIcon={
|
|
323
|
+
<Icon
|
|
324
|
+
name="chevron-down"
|
|
325
|
+
size={14}
|
|
326
|
+
className={cn(
|
|
327
|
+
"text-muted transition-transform duration-200 ease-out",
|
|
328
|
+
workspaceChevronOpen && "rotate-180",
|
|
329
|
+
)}
|
|
330
|
+
/>
|
|
331
|
+
}
|
|
332
|
+
>
|
|
333
|
+
<span className="min-w-0 truncate text-ink">{workspaceName}</span>
|
|
334
|
+
</Button>,
|
|
335
|
+
"min-w-0 flex-1",
|
|
336
|
+
)
|
|
286
337
|
)
|
|
287
338
|
) : (
|
|
288
339
|
<span className="min-w-0 flex-1" />
|
|
@@ -6,6 +6,8 @@ import { IconButton } from "../../atoms/IconButton";
|
|
|
6
6
|
import { Button } from "../../atoms/Button";
|
|
7
7
|
import { Avatar } from "../../atoms/Avatar";
|
|
8
8
|
import { Drawer } from "../Drawer";
|
|
9
|
+
import { DropdownMenu } from "../../molecules/DropdownMenu";
|
|
10
|
+
import type { DropdownMenuEntry } from "../../molecules/DropdownMenu";
|
|
9
11
|
|
|
10
12
|
export interface SidebarMobileLink {
|
|
11
13
|
id: string;
|
|
@@ -31,6 +33,14 @@ export interface SidebarMobileProps extends React.HTMLAttributes<HTMLDivElement>
|
|
|
31
33
|
workspaceName?: string;
|
|
32
34
|
workspaceAvatarSrc?: string;
|
|
33
35
|
onWorkspaceClick?: () => void;
|
|
36
|
+
/**
|
|
37
|
+
* Entries for the workspace switcher menu. When provided, the workspace button
|
|
38
|
+
* in the drawer becomes the trigger of a `DropdownMenu` with these entries —
|
|
39
|
+
* and `onWorkspaceClick` is no longer called. Omit it to keep the plain click.
|
|
40
|
+
*/
|
|
41
|
+
workspaceMenuItems?: DropdownMenuEntry[];
|
|
42
|
+
/** Optional block pinned above the workspace menu's actions, like `DropdownMenu`'s `header`. */
|
|
43
|
+
workspaceMenuHeader?: React.ReactNode;
|
|
34
44
|
/**
|
|
35
45
|
* Where the workspace row renders inside the drawer. `"top"` is the default:
|
|
36
46
|
* above the nav. `"bottom"` pins it to the end of the drawer panel — after the
|
|
@@ -91,6 +101,8 @@ export const SidebarMobile = React.forwardRef<HTMLDivElement, SidebarMobileProps
|
|
|
91
101
|
workspaceName,
|
|
92
102
|
workspaceAvatarSrc,
|
|
93
103
|
onWorkspaceClick,
|
|
104
|
+
workspaceMenuItems,
|
|
105
|
+
workspaceMenuHeader,
|
|
94
106
|
workspacePlacement = "top",
|
|
95
107
|
mobileActions,
|
|
96
108
|
sections,
|
|
@@ -134,6 +146,9 @@ export const SidebarMobile = React.forwardRef<HTMLDivElement, SidebarMobileProps
|
|
|
134
146
|
return next;
|
|
135
147
|
});
|
|
136
148
|
|
|
149
|
+
/** Open state of the workspace switcher menu, so the chevron can follow it. */
|
|
150
|
+
const [workspaceMenuOpen, setWorkspaceMenuOpen] = React.useState(false);
|
|
151
|
+
|
|
137
152
|
/** Each drawer-footer action only exists when the consumer supplied its handler. */
|
|
138
153
|
const showHelpAction = onHelpClick !== undefined;
|
|
139
154
|
const showSettingsAction = onSettingsClick !== undefined;
|
|
@@ -209,18 +224,48 @@ export const SidebarMobile = React.forwardRef<HTMLDivElement, SidebarMobileProps
|
|
|
209
224
|
);
|
|
210
225
|
};
|
|
211
226
|
|
|
212
|
-
|
|
227
|
+
/** Menu mode: the workspace button becomes a dropdown trigger instead of a click. */
|
|
228
|
+
const workspaceMenuMode = workspaceMenuItems !== undefined;
|
|
229
|
+
|
|
230
|
+
const workspaceButtonNode = workspaceName ? (
|
|
213
231
|
<Button
|
|
214
232
|
variant="ghost"
|
|
215
|
-
onClick={onWorkspaceClick}
|
|
233
|
+
onClick={workspaceMenuMode ? undefined : onWorkspaceClick}
|
|
216
234
|
className="px-sm"
|
|
235
|
+
fullWidth={workspaceMenuMode}
|
|
217
236
|
leadingIcon={<Avatar name={workspaceName} src={workspaceAvatarSrc} size="sm" />}
|
|
218
|
-
trailingIcon={
|
|
237
|
+
trailingIcon={
|
|
238
|
+
<Icon
|
|
239
|
+
name="chevron-down"
|
|
240
|
+
size={14}
|
|
241
|
+
className={cn(
|
|
242
|
+
"text-muted transition-transform duration-200 ease-out",
|
|
243
|
+
workspaceMenuMode && workspaceMenuOpen && "rotate-180",
|
|
244
|
+
)}
|
|
245
|
+
/>
|
|
246
|
+
}
|
|
219
247
|
>
|
|
220
248
|
<span className="text-ink">{workspaceName}</span>
|
|
221
249
|
</Button>
|
|
222
250
|
) : null;
|
|
223
251
|
|
|
252
|
+
const workspaceButton =
|
|
253
|
+
workspaceButtonNode && workspaceMenuMode ? (
|
|
254
|
+
<DropdownMenu
|
|
255
|
+
trigger={workspaceButtonNode}
|
|
256
|
+
items={workspaceMenuItems ?? []}
|
|
257
|
+
header={workspaceMenuHeader}
|
|
258
|
+
align="start"
|
|
259
|
+
side={workspaceAtBottom ? "top" : "bottom"}
|
|
260
|
+
open={workspaceMenuOpen}
|
|
261
|
+
onOpenChange={setWorkspaceMenuOpen}
|
|
262
|
+
aria-label="Workspace"
|
|
263
|
+
className="w-full"
|
|
264
|
+
/>
|
|
265
|
+
) : (
|
|
266
|
+
workspaceButtonNode
|
|
267
|
+
);
|
|
268
|
+
|
|
224
269
|
const userRow = showFooterRow ? (
|
|
225
270
|
<div className="flex w-full items-center justify-between">
|
|
226
271
|
{userName ? <Avatar name={userName} src={userAvatarSrc} size="sm" /> : <span />}
|