@vrobots/storybook 0.1.13 → 0.1.15

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@vrobots/storybook",
3
3
  "private": false,
4
- "version": "0.1.12",
4
+ "version": "0.1.15",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
7
7
  "types": "dist/index.d.ts",
@@ -1,7 +1,10 @@
1
1
  import { jsx as _jsx } from "react/jsx-runtime";
2
2
  import { Box } from "@chakra-ui/react";
3
3
  import { forwardRef } from "react";
4
+ import { useColorMode } from "./ui/color-mode";
4
5
  export const Display = forwardRef((props, ref) => {
5
- return (_jsx(Box, { ref: ref, height: 'inherit', width: '100%', children: props.children }));
6
+ const { colorMode } = useColorMode();
7
+ const bgColor = colorMode === 'light' ? 'gray.50' : 'gray.800';
8
+ return (_jsx(Box, { ref: ref, height: 'inherit', width: '100%', bg: bgColor, children: props.children }));
6
9
  });
7
10
  Display.displayName = 'Display';
@@ -1,7 +1,5 @@
1
1
  import React from "react";
2
- import { IHeaderProps } from "./Header";
3
2
  export interface IFrameProps {
4
3
  children?: React.ReactNode;
5
- headerProps: IHeaderProps;
6
4
  }
7
5
  export declare const Frame: React.ForwardRefExoticComponent<IFrameProps & React.RefAttributes<HTMLDivElement>>;
@@ -5,10 +5,9 @@ import { Header } from "./Header";
5
5
  import { Sidebar } from "./Sidebar";
6
6
  import { Display } from "./Display";
7
7
  export const Frame = forwardRef((props, ref) => {
8
- const { headerProps, } = props;
9
8
  const headerRef = React.useRef(null);
10
9
  const sidebarRef = React.useRef(null);
11
10
  const displayRef = React.useRef(null);
12
- return (_jsxs(Box, { ref: ref, height: '100vh', display: 'flex', flexDirection: 'column', alignItems: 'stretch', overflow: 'hidden', children: [_jsx(Header, { ...headerProps, ref: headerRef }), _jsxs(HStack, { gap: 0, flex: 12, alignItems: 'stretch', children: [_jsx(Sidebar, { ref: sidebarRef }), _jsx(Display, { ref: displayRef, children: props.children })] })] }));
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 })] })] }));
13
12
  });
14
13
  Frame.displayName = 'Frame';
@@ -1,11 +1,26 @@
1
1
  import React from 'react';
2
+ export interface IHeaderLogo {
3
+ light: string;
4
+ dark: string;
5
+ }
2
6
  export interface IHeaderProps {
3
7
  appName?: string;
4
- logo: {
5
- light: string;
6
- dark: string;
7
- };
8
+ logo: IHeaderLogo;
9
+ menu?: React.ReactNode | null;
10
+ version?: string | null;
11
+ children?: React.ReactNode | null;
12
+ }
13
+ export interface IHeaderContextProps {
14
+ appName: string;
15
+ setAppName: React.Dispatch<React.SetStateAction<string>>;
16
+ logo: IHeaderLogo;
17
+ setLogo: React.Dispatch<React.SetStateAction<IHeaderLogo>>;
8
18
  menu: React.ReactNode | null;
19
+ setMenu: React.Dispatch<React.SetStateAction<React.ReactNode | null>>;
9
20
  version?: string | null;
21
+ setVersion?: React.Dispatch<React.SetStateAction<string>>;
10
22
  }
11
- export declare const Header: React.ForwardRefExoticComponent<IHeaderProps & React.RefAttributes<HTMLDivElement>>;
23
+ export declare const HeaderContext: React.Context<IHeaderContextProps>;
24
+ export declare const useHeader: () => IHeaderContextProps;
25
+ export declare const HeaderProvider: React.FC<IHeaderProps>;
26
+ export declare const Header: React.ForwardRefExoticComponent<React.RefAttributes<HTMLDivElement>>;
@@ -1,9 +1,32 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import React from 'react';
2
3
  import { defaultSystem, Grid, GridItem, Text } from '@chakra-ui/react';
3
4
  import { forwardRef } from 'react';
4
5
  import { Logo } from './Logo';
5
6
  import { useColorMode } from './ui/color-mode';
6
- export const Header = forwardRef(({ appName, logo, menu = null, version = null, }, ref) => {
7
+ export const HeaderContext = React.createContext({});
8
+ export const useHeader = () => React.useContext(HeaderContext);
9
+ export const HeaderProvider = (props) => {
10
+ const [appName, setAppName] = React.useState(props.appName || '');
11
+ const [menu, setMenu] = React.useState(props?.menu || null);
12
+ const [logo, setLogo] = React.useState(props.logo);
13
+ const [version, setVersion] = React.useState(props.version || '');
14
+ React.useEffect(() => {
15
+ setAppName(props.appName || '');
16
+ }, [props.appName]);
17
+ React.useEffect(() => {
18
+ setMenu(props.menu || null);
19
+ }, [props.menu]);
20
+ React.useEffect(() => {
21
+ setLogo(props.logo);
22
+ }, [props.logo]);
23
+ React.useEffect(() => {
24
+ setVersion(props.version || '');
25
+ }, [props.version]);
26
+ return (_jsx(HeaderContext.Provider, { value: { appName, setVersion, setAppName, setLogo, setMenu, logo, menu, version }, children: props.children }));
27
+ };
28
+ export const Header = forwardRef(({}, ref) => {
29
+ const { appName, logo, menu, version } = useHeader();
7
30
  const { colorMode } = useColorMode();
8
31
  const selectedLogo = logo[colorMode];
9
32
  const borderColors = { ...defaultSystem }._config.theme?.semanticTokens?.colors.border.DEFAULT.value;
@@ -5,8 +5,7 @@ import React, { forwardRef } from "react";
5
5
  import { LuMenu } from "react-icons/lu";
6
6
  import { motion } from "motion/react";
7
7
  import { useBreakpoint, useIsMobile } from "../hooks";
8
- const COLOR_GRAY_200 = '#e4e4e7';
9
- const COLOR_GRAY_800 = '#27272a';
8
+ import { COLOR_GRAY_200, COLOR_GRAY_800 } from "../constants";
10
9
  export const SidebarContext = React.createContext({});
11
10
  export const SidebarProvider = (props) => {
12
11
  const [isOpen, setIsOpen] = React.useState(props?.isOpen || false);
@@ -0,0 +1,2 @@
1
+ export declare const COLOR_GRAY_200 = "#e4e4e7";
2
+ export declare const COLOR_GRAY_800 = "#27272a";
@@ -0,0 +1,2 @@
1
+ export const COLOR_GRAY_200 = '#e4e4e7';
2
+ export const COLOR_GRAY_800 = '#27272a';
@@ -7,15 +7,6 @@ declare const meta: {
7
7
  layout: string;
8
8
  };
9
9
  args: {
10
- headerProps: {
11
- appName: string;
12
- logo: {
13
- light: string;
14
- dark: string;
15
- };
16
- menu: import("react/jsx-runtime").JSX.Element;
17
- version: string;
18
- };
19
10
  children: import("react/jsx-runtime").JSX.Element;
20
11
  };
21
12
  };
@@ -9,6 +9,7 @@ import { Page } from '../components/Page';
9
9
  import { EXAMPLE_BREADCRUMBS } from './Breadcrumbs.stories';
10
10
  import { useIsMobile } from '../hooks/useIsMobile';
11
11
  import { AvatarIconMenu } from '../components/AvatarIconMenu';
12
+ import { HeaderProvider } from '../components';
12
13
  const logo = {
13
14
  light: '/logo_hyperion_official.svg',
14
15
  dark: '/logo_hyperion_official_white.svg',
@@ -26,31 +27,19 @@ const meta = {
26
27
  layout: 'fullscreen',
27
28
  },
28
29
  args: {
29
- headerProps: {
30
- appName: 'My Application',
31
- logo,
32
- menu,
33
- version: packageJson.version,
34
- },
35
30
  children: (_jsx(Page, { breadcrumbs: EXAMPLE_BREADCRUMBS, children: _jsx(Heading, { children: "Gaming Laptops" }) })),
36
31
  },
37
32
  };
38
33
  export default meta;
39
34
  export const Component = {
40
35
  args: {
41
- headerProps: {
42
- appName: 'My Application',
43
- logo,
44
- menu,
45
- version: packageJson.version,
46
- },
47
36
  children: (_jsx(Page, { breadcrumbs: EXAMPLE_BREADCRUMBS, children: _jsx(Heading, { children: "Gaming Laptops" }) })),
48
37
  },
49
38
  decorators: [
50
39
  (Story) => {
51
40
  const isMobile = useIsMobile();
52
41
  const isSidebarOpen = !isMobile;
53
- return (_jsxs(SidebarProvider, { isOpen: isSidebarOpen, menu: _jsx(Menu, { label: 'Sidebar Menu', menuItems: SIDEBAR_MENU }), children: [_jsx(Story, {}), isMobile && _jsx(SidebarToggleButton, { name: 'sidebar-toggle', "aria-label": 'Toggle sidebar' })] }));
42
+ return (_jsx(HeaderProvider, { appName: 'My Application', logo: logo, menu: menu, version: packageJson.version, children: _jsxs(SidebarProvider, { isOpen: isSidebarOpen, menu: _jsx(Menu, { label: 'Sidebar Menu', menuItems: SIDEBAR_MENU }), children: [_jsx(Story, {}), isMobile && _jsx(SidebarToggleButton, { name: 'sidebar-toggle', "aria-label": 'Toggle sidebar' })] }) }));
54
43
  },
55
44
  ],
56
45
  };
@@ -1,20 +1,11 @@
1
1
  import type { StoryObj } from '@storybook/react-vite';
2
2
  declare const meta: {
3
3
  title: string;
4
- component: import("react").ForwardRefExoticComponent<import("../components").IHeaderProps & import("react").RefAttributes<HTMLDivElement>>;
4
+ component: import("react").ForwardRefExoticComponent<import("react").RefAttributes<HTMLDivElement>>;
5
5
  tags: string[];
6
6
  parameters: {
7
7
  layout: string;
8
8
  };
9
- args: {
10
- appName: string;
11
- logo: {
12
- light: string;
13
- dark: string;
14
- };
15
- menu: null;
16
- version: string;
17
- };
18
9
  };
19
10
  export default meta;
20
11
  type Story = StoryObj<typeof meta>;
@@ -1,11 +1,16 @@
1
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
2
  import packageJson from '../../package.json';
3
- import { Header } from '../components/Header';
4
- import { Avatar } from '@chakra-ui/react';
3
+ import { Header, HeaderProvider } from '../components/Header';
4
+ import { AvatarIconMenu } from '../components/AvatarIconMenu';
5
5
  const logo = {
6
6
  light: '/logo_hyperion_official.svg',
7
7
  dark: '/logo_hyperion_official_white.svg',
8
8
  };
9
+ const menu = (_jsx(AvatarIconMenu, { name: "Segun Adebayo", src: "https://bit.ly/sage-adebayo", menu: [
10
+ { label: 'Account', value: 'account' },
11
+ { label: 'Settings', value: 'settings' },
12
+ { label: 'Logout', value: 'logout' },
13
+ ] }));
9
14
  const meta = {
10
15
  title: 'Frame/Header',
11
16
  component: Header,
@@ -13,27 +18,19 @@ const meta = {
13
18
  parameters: {
14
19
  layout: 'fullscreen',
15
20
  },
16
- args: {
17
- appName: 'My Application',
18
- logo,
19
- menu: null,
20
- version: packageJson.version,
21
- },
22
21
  };
23
22
  export default meta;
24
23
  export const LoggedIn = {
25
- args: {
26
- appName: 'My Application',
27
- logo,
28
- menu: (_jsxs(Avatar.Root, { children: [_jsx(Avatar.Fallback, { name: "Segun Adebayo" }), _jsx(Avatar.Image, { src: "https://bit.ly/sage-adebayo" })] })),
29
- version: packageJson.version,
30
- }
24
+ decorators: [
25
+ (Story) => {
26
+ return (_jsx(HeaderProvider, { appName: 'My Application', logo: logo, menu: menu, version: packageJson.version, children: _jsx(Story, {}) }));
27
+ },
28
+ ],
31
29
  };
32
30
  export const LoggedOut = {
33
- args: {
34
- appName: 'My Application',
35
- logo,
36
- menu: null,
37
- version: packageJson.version,
38
- }
31
+ decorators: [
32
+ (Story) => {
33
+ return (_jsx(HeaderProvider, { appName: 'My Application', logo: logo, version: packageJson.version, children: _jsx(Story, {}) }));
34
+ },
35
+ ],
39
36
  };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@vrobots/storybook",
3
3
  "private": false,
4
- "version": "0.1.13",
4
+ "version": "0.1.15",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
7
7
  "types": "dist/index.d.ts",