@vrobots/storybook 0.1.39 → 0.1.41
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/package.json +1 -1
- package/dist/src/components/Frame.js +4 -4
- package/dist/src/components/Header.d.ts +1 -0
- package/dist/src/components/Header.js +2 -1
- package/dist/src/components/Sidebar.d.ts +10 -5
- package/dist/src/components/Sidebar.js +2 -2
- package/dist/src/components/ui/color-mode.js +3 -0
- package/package.json +1 -1
package/dist/package.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { Box, HStack } from "@chakra-ui/react";
|
|
3
3
|
import React, { forwardRef } from "react";
|
|
4
|
-
import { Header } from "./Header";
|
|
5
|
-
import { Sidebar } from "./Sidebar";
|
|
4
|
+
import { Header, useHeader } from "./Header";
|
|
5
|
+
import { Sidebar, useSidebar } from "./Sidebar";
|
|
6
6
|
import { Display } from "./Display";
|
|
7
7
|
export const Frame = forwardRef((props, ref) => {
|
|
8
|
-
const headerRef =
|
|
9
|
-
const sidebarRef =
|
|
8
|
+
const { ref: headerRef } = useHeader();
|
|
9
|
+
const { ref: sidebarRef } = useSidebar();
|
|
10
10
|
const displayRef = React.useRef(null);
|
|
11
11
|
return (_jsxs(Box, { ref: ref, height: '100vh', display: 'flex', flexDirection: 'column', alignItems: 'stretch', overflow: 'hidden', children: [_jsx(Header, { ref: headerRef }), _jsxs(HStack, { gap: 0, flex: 12, alignItems: 'stretch', children: [_jsx(Sidebar, { ref: sidebarRef }), _jsx(Display, { ref: displayRef, children: props.children })] })] }));
|
|
12
12
|
});
|
|
@@ -22,6 +22,7 @@ export interface IHeaderContextProps {
|
|
|
22
22
|
setMenu: React.Dispatch<React.SetStateAction<React.ReactNode | null>>;
|
|
23
23
|
version?: string | null;
|
|
24
24
|
setVersion?: React.Dispatch<React.SetStateAction<string>>;
|
|
25
|
+
ref: React.RefObject<HTMLDivElement | null>;
|
|
25
26
|
}
|
|
26
27
|
export declare const HeaderContext: React.Context<IHeaderContextProps>;
|
|
27
28
|
export declare const useHeader: () => IHeaderContextProps;
|
|
@@ -12,6 +12,7 @@ export const HeaderProvider = (props) => {
|
|
|
12
12
|
const [logo, setLogo] = React.useState(props.logo);
|
|
13
13
|
const [version, setVersion] = React.useState(props.version || '');
|
|
14
14
|
const [defaultPath, setDefaultPath] = React.useState(props.defaultPath || '');
|
|
15
|
+
const ref = React.useRef(null);
|
|
15
16
|
React.useEffect(() => {
|
|
16
17
|
setAppName(props.appName || '');
|
|
17
18
|
}, [props.appName]);
|
|
@@ -24,7 +25,7 @@ export const HeaderProvider = (props) => {
|
|
|
24
25
|
React.useEffect(() => {
|
|
25
26
|
setVersion(props.version || '');
|
|
26
27
|
}, [props.version]);
|
|
27
|
-
return (_jsx(HeaderContext.Provider, { value: { appName, setVersion, setAppName, setLogo, setMenu, logo, menu, version, defaultPath, setDefaultPath }, children: props.children }));
|
|
28
|
+
return (_jsx(HeaderContext.Provider, { value: { appName, setVersion, setAppName, setLogo, setMenu, logo, menu, version, defaultPath, setDefaultPath, ref }, children: props.children }));
|
|
28
29
|
};
|
|
29
30
|
export const Header = forwardRef(({}, ref) => {
|
|
30
31
|
const { appName, logo, menu, version, defaultPath } = useHeader();
|
|
@@ -1,15 +1,20 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import { IconButtonProps } from "@chakra-ui/react";
|
|
3
|
-
export interface
|
|
3
|
+
export interface ISidebarProviderProps {
|
|
4
|
+
isOpen?: boolean;
|
|
5
|
+
menu?: React.ReactNode | null;
|
|
6
|
+
children?: React.ReactNode;
|
|
7
|
+
}
|
|
8
|
+
export interface ISidebarContextProps {
|
|
4
9
|
isOpen?: boolean;
|
|
5
10
|
menu?: React.ReactNode | null;
|
|
6
11
|
setIsOpen?: React.Dispatch<React.SetStateAction<boolean>>;
|
|
7
12
|
setMenu?: React.Dispatch<React.SetStateAction<React.ReactNode | null>>;
|
|
8
13
|
toggleSidebar?: () => void;
|
|
9
|
-
|
|
14
|
+
ref: React.RefObject<HTMLDivElement | null>;
|
|
10
15
|
}
|
|
11
|
-
export declare const SidebarContext: React.Context<
|
|
12
|
-
export declare const SidebarProvider: React.FC<
|
|
13
|
-
export declare const useSidebar: () =>
|
|
16
|
+
export declare const SidebarContext: React.Context<ISidebarContextProps>;
|
|
17
|
+
export declare const SidebarProvider: React.FC<ISidebarProviderProps>;
|
|
18
|
+
export declare const useSidebar: () => ISidebarContextProps;
|
|
14
19
|
export declare const SidebarToggleButton: React.FC<IconButtonProps>;
|
|
15
20
|
export declare const Sidebar: React.ForwardRefExoticComponent<React.RefAttributes<HTMLDivElement>>;
|
|
@@ -11,13 +11,14 @@ export const SidebarProvider = (props) => {
|
|
|
11
11
|
const [isOpen, setIsOpen] = React.useState(props?.isOpen || false);
|
|
12
12
|
const [menu, setMenu] = React.useState(props?.menu || null);
|
|
13
13
|
const toggleSidebar = () => setIsOpen(!isOpen);
|
|
14
|
+
const ref = React.useRef(null);
|
|
14
15
|
React.useEffect(() => {
|
|
15
16
|
setIsOpen(props.isOpen || false);
|
|
16
17
|
}, [props.isOpen]);
|
|
17
18
|
React.useEffect(() => {
|
|
18
19
|
setMenu(props.menu || null);
|
|
19
20
|
}, [props.menu]);
|
|
20
|
-
return (_jsx(SidebarContext.Provider, { value: { ...props, isOpen, menu, setIsOpen, setMenu, toggleSidebar }, children: props.children }));
|
|
21
|
+
return (_jsx(SidebarContext.Provider, { value: { ...props, isOpen, menu, ref, setIsOpen, setMenu, toggleSidebar }, children: props.children }));
|
|
21
22
|
};
|
|
22
23
|
export const useSidebar = () => React.useContext(SidebarContext);
|
|
23
24
|
export const SidebarToggleButton = (props) => {
|
|
@@ -25,7 +26,6 @@ export const SidebarToggleButton = (props) => {
|
|
|
25
26
|
return (_jsx(IconButton, { onClick: toggleSidebar, position: 'absolute', bottom: 2, right: 2, zIndex: 3, variant: 'ghost', ...props, children: _jsx(LuMenu, {}) }));
|
|
26
27
|
};
|
|
27
28
|
export const Sidebar = forwardRef((props, ref) => {
|
|
28
|
-
const [isFirstTimeOpen, setIsFirstTimeOpen] = React.useState(true);
|
|
29
29
|
const sidebar = useSidebar();
|
|
30
30
|
const { colorMode } = useColorMode();
|
|
31
31
|
const breakpoint = useBreakpoint();
|