@hyphen/hyphen-components 5.3.0 → 5.4.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/Sidebar/Sidebar.d.ts +2 -1
- package/dist/css/utilities.css +1 -1
- package/dist/css/variables.css +2 -2
- package/dist/hyphen-components.cjs.development.js +4 -5
- package/dist/hyphen-components.cjs.development.js.map +1 -1
- package/dist/hyphen-components.cjs.production.min.js +1 -1
- package/dist/hyphen-components.cjs.production.min.js.map +1 -1
- package/dist/hyphen-components.esm.js +4 -5
- package/dist/hyphen-components.esm.js.map +1 -1
- package/dist/lib/tokens.d.ts +1 -1
- package/package.json +2 -2
- package/src/components/Sidebar/Sidebar.stories.tsx +17 -17
- package/src/components/Sidebar/Sidebar.tsx +3 -4
package/dist/lib/tokens.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { BorderRadiusSize, Breakpoint, BreakpointSizeWithBase } from '../types';
|
|
2
|
-
export declare const ICON_NAMES: ("add" | "alarm-disable" | "alarm" | "analytics" | "app-window" | "arrow-down" | "arrow-left" | "arrow-right" | "arrow-up" | "arrows-maximize" | "at" | "ban" | "block" | "blocks" | "book-open" | "c-add" | "c-check" | "c-delete" | "c-in-progress" | "c-info" | "c-question" | "c-remove" | "c-warning" | "calendar-create" | "calendar" | "camera" | "caret-down" | "caret-left" | "caret-right" | "caret-sm-down" | "caret-sm-left" | "caret-sm-right" | "caret-sm-up" | "caret-up-down" | "caret-up" | "chart-bar" | "chart-line" | "chat" | "check" | "checkbox-btn-checked" | "checkbox-btn-indeterminate" | "checkbox-btn" | "circle-filled" | "circle" | "clipboard" | "cloud" | "code" | "command-line" | "contact" | "copy-document" | "dashboard" | "database" | "dock-left" | "document" | "dots" | "download" | "electricity-bolt" | "exclamation-mark" | "eye-slash" | "eye" | "filter" | "flag" | "folder" | "gear" | "grab" | "hash-mark" | "heart-o" | "heart" | "home" | "info" | "integrations" | "key" | "launch-app" | "lightbulb" | "link" | "list" | "lock" | "logo-deploy" | "logo-env" | "logo-link" | "logo-netinfo" | "logo-toggle" | "logout" | "mail" | "menu" | "minus" | "moon" | "paperclip" | "path-intersect" | "pause" | "pc" | "pencil" | "phone" | "photo" | "play" | "qr-code" | "radio-btn-checked" | "radio-btn-unchecked" | "refresh" | "remove" | "rewind" | "search" | "send" | "settings" | "skip" | "stack" | "star-o" | "star" | "stopwatch" | "subtract" | "sun" | "t-warning" | "tag" | "terminal" | "time-alarm" | "time-clock" | "trash" | "unlocked" | "upload" | "user-create" | "user" | "users" | "wifi-off" | "wifi" | "zoom-in" | "zoom-out")[];
|
|
2
|
+
export declare const ICON_NAMES: ("add" | "alarm-disable" | "alarm" | "analytics" | "app-window" | "arrow-down" | "arrow-left" | "arrow-right" | "arrow-up" | "arrows-maximize" | "at" | "ban" | "block" | "blocks" | "book-open" | "c-add" | "c-check" | "c-delete" | "c-in-progress" | "c-info" | "c-question" | "c-remove" | "c-user" | "c-warning" | "calendar-create" | "calendar" | "camera" | "caret-down" | "caret-left" | "caret-right" | "caret-sm-down" | "caret-sm-left" | "caret-sm-right" | "caret-sm-up" | "caret-up-down" | "caret-up" | "chart-bar" | "chart-line" | "chat" | "check" | "checkbox-btn-checked" | "checkbox-btn-indeterminate" | "checkbox-btn" | "circle-filled" | "circle" | "clipboard" | "cloud" | "code" | "command-line" | "contact" | "copy-document" | "dashboard" | "database" | "dock-left" | "document" | "dots" | "download" | "electricity-bolt" | "exclamation-mark" | "eye-slash" | "eye" | "filter" | "flag" | "folder" | "gear" | "grab" | "hash-mark" | "heart-o" | "heart" | "home" | "info" | "integrations" | "key" | "launch-app" | "lightbulb" | "link" | "list" | "lock" | "logo-deploy" | "logo-env" | "logo-link" | "logo-netinfo" | "logo-toggle" | "logout" | "mail" | "menu" | "minus" | "moon" | "paperclip" | "path-intersect" | "pause" | "pc" | "pencil" | "phone" | "photo" | "play" | "qr-code" | "radio-btn-checked" | "radio-btn-unchecked" | "refresh" | "remove" | "rewind" | "search" | "send" | "settings" | "skip" | "stack" | "star-o" | "star" | "stopwatch" | "subtract" | "sun" | "t-warning" | "tag" | "terminal" | "time-alarm" | "time-clock" | "trash" | "unlocked" | "upload" | "user-create" | "user" | "users" | "wifi-off" | "wifi" | "zoom-in" | "zoom-out")[];
|
|
3
3
|
export declare const BORDER_RADIUS_OPTIONS: BorderRadiusSize[];
|
|
4
4
|
export declare const BORDER_SIZE_OPTIONS: ("0" | "sm" | "md" | "lg")[];
|
|
5
5
|
export declare const BREAKPOINT_OPTIONS: BreakpointSizeWithBase[];
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hyphen/hyphen-components",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.4.1",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "@hyphen"
|
|
@@ -62,7 +62,7 @@
|
|
|
62
62
|
],
|
|
63
63
|
"dependencies": {
|
|
64
64
|
"@emotion/react": "^11.14.0",
|
|
65
|
-
"@hyphen/hyphen-design-tokens": "^4.
|
|
65
|
+
"@hyphen/hyphen-design-tokens": "^4.35.0",
|
|
66
66
|
"@popperjs/core": "^2.11.8",
|
|
67
67
|
"@radix-ui/react-collapsible": "^1.1.11",
|
|
68
68
|
"@radix-ui/react-dropdown-menu": "^2.1.15",
|
|
@@ -158,24 +158,20 @@ const data = {
|
|
|
158
158
|
|
|
159
159
|
// type Story = StoryObj<typeof Sidebar>;
|
|
160
160
|
|
|
161
|
-
function getCookieValue(name: string): string | null {
|
|
162
|
-
const match = document.cookie.match(
|
|
163
|
-
new RegExp(
|
|
164
|
-
`(?:^|; )${name.replace(/([.$?*|{}()[\]\\/+^])/g, '\\$1')}=([^;]*)`
|
|
165
|
-
)
|
|
166
|
-
);
|
|
167
|
-
return match ? decodeURIComponent(match[1]) : null;
|
|
168
|
-
}
|
|
169
|
-
|
|
170
161
|
export const SidebarExample = () => {
|
|
171
162
|
const [activeTeam, setActiveTeam] = React.useState(data.teams[0]);
|
|
172
163
|
const isMobile = useIsMobile();
|
|
173
164
|
|
|
174
|
-
const
|
|
165
|
+
const STORAGE_KEY = 'sidebar_expanded_storybook';
|
|
166
|
+
|
|
167
|
+
const startOpen = localStorage.getItem(STORAGE_KEY) || 'true';
|
|
175
168
|
|
|
176
169
|
return (
|
|
177
170
|
<ResponsiveProvider>
|
|
178
|
-
<SidebarProvider
|
|
171
|
+
<SidebarProvider
|
|
172
|
+
storageKey={STORAGE_KEY}
|
|
173
|
+
defaultOpen={startOpen === 'true'}
|
|
174
|
+
>
|
|
179
175
|
<Sidebar side="left" collapsible="icon">
|
|
180
176
|
<NavHeader activeTeam={activeTeam} setActiveTeam={setActiveTeam} />
|
|
181
177
|
<SidebarContent>
|
|
@@ -197,14 +193,18 @@ export const SidebarExample = () => {
|
|
|
197
193
|
};
|
|
198
194
|
|
|
199
195
|
export const SidebarCollapsed = () => {
|
|
196
|
+
const STORAGE_KEY = 'sidebar_collapsed';
|
|
197
|
+
|
|
200
198
|
const [activeTeam, setActiveTeam] = React.useState(data.teams[0]);
|
|
201
199
|
const isMobile = useIsMobile();
|
|
202
|
-
|
|
203
|
-
const startOpen = getCookieValue('false');
|
|
200
|
+
const startOpen = localStorage.getItem(STORAGE_KEY) || 'false';
|
|
204
201
|
|
|
205
202
|
return (
|
|
206
203
|
<ResponsiveProvider>
|
|
207
|
-
<SidebarProvider
|
|
204
|
+
<SidebarProvider
|
|
205
|
+
storageKey={STORAGE_KEY}
|
|
206
|
+
defaultOpen={startOpen === 'true'}
|
|
207
|
+
>
|
|
208
208
|
<Sidebar side="left" collapsible="icon">
|
|
209
209
|
<NavHeader activeTeam={activeTeam} setActiveTeam={setActiveTeam} />
|
|
210
210
|
<SidebarContent>
|
|
@@ -326,10 +326,10 @@ const NavMain = ({ items }: { items: NavItem[] }) => {
|
|
|
326
326
|
<SidebarGroup>
|
|
327
327
|
<SidebarGroupLabel>Platform</SidebarGroupLabel>
|
|
328
328
|
<SidebarMenu>
|
|
329
|
-
{items.map((item
|
|
329
|
+
{items.map((item) =>
|
|
330
330
|
item.items && state === 'expanded' ? (
|
|
331
331
|
<Collapsible
|
|
332
|
-
key={`${item.title}
|
|
332
|
+
key={`${item.title}`}
|
|
333
333
|
className="group/collapsible"
|
|
334
334
|
asChild
|
|
335
335
|
>
|
|
@@ -364,7 +364,7 @@ const NavMain = ({ items }: { items: NavItem[] }) => {
|
|
|
364
364
|
</SidebarMenuItem>
|
|
365
365
|
</Collapsible>
|
|
366
366
|
) : item.items && state === 'collapsed' ? (
|
|
367
|
-
<DropdownMenu>
|
|
367
|
+
<DropdownMenu key={`${item.title}`}>
|
|
368
368
|
<DropdownMenuTrigger asChild>
|
|
369
369
|
<SidebarMenuButton tooltip={item.title}>
|
|
370
370
|
<Icon
|
|
@@ -21,8 +21,6 @@ import {
|
|
|
21
21
|
TooltipTrigger,
|
|
22
22
|
} from '../Tooltip/Tooltip';
|
|
23
23
|
|
|
24
|
-
const SIDEBAR_COOKIE_NAME = 'sidebar_expanded';
|
|
25
|
-
const SIDEBAR_COOKIE_MAX_AGE = 60 * 60 * 24 * 7;
|
|
26
24
|
const SIDEBAR_WIDTH = '16rem';
|
|
27
25
|
const SIDEBAR_WIDTH_ICON = '44px';
|
|
28
26
|
const SIDEBAR_KEYBOARD_SHORTCUT = '[';
|
|
@@ -52,6 +50,7 @@ const SidebarProvider = forwardRef<
|
|
|
52
50
|
React.ComponentProps<'div'> & {
|
|
53
51
|
defaultOpen?: boolean;
|
|
54
52
|
open?: boolean;
|
|
53
|
+
storageKey?: string;
|
|
55
54
|
onOpenChange?: (open: boolean) => void;
|
|
56
55
|
}
|
|
57
56
|
>(
|
|
@@ -59,6 +58,7 @@ const SidebarProvider = forwardRef<
|
|
|
59
58
|
{
|
|
60
59
|
defaultOpen = true,
|
|
61
60
|
open: openProp,
|
|
61
|
+
storageKey = 'sidebar_expanded',
|
|
62
62
|
onOpenChange: setOpenProp,
|
|
63
63
|
className,
|
|
64
64
|
style,
|
|
@@ -96,8 +96,7 @@ const SidebarProvider = forwardRef<
|
|
|
96
96
|
_setOpen(newOpenState);
|
|
97
97
|
}
|
|
98
98
|
|
|
99
|
-
|
|
100
|
-
document.cookie = `${SIDEBAR_COOKIE_NAME}=${newOpenState}; path=/; max-age=${SIDEBAR_COOKIE_MAX_AGE}`;
|
|
99
|
+
localStorage.setItem(storageKey, `${newOpenState}`);
|
|
101
100
|
}
|
|
102
101
|
},
|
|
103
102
|
[setOpenProp, open]
|