@vrobots/storybook 0.1.0

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.
Files changed (59) hide show
  1. package/README.md +73 -0
  2. package/dist/index.d.ts +3 -0
  3. package/dist/index.js +3 -0
  4. package/dist/package.json +63 -0
  5. package/dist/src/components/AvatarIconMenu.d.ts +8 -0
  6. package/dist/src/components/AvatarIconMenu.js +8 -0
  7. package/dist/src/components/Breadcrumbs.d.ts +11 -0
  8. package/dist/src/components/Breadcrumbs.js +18 -0
  9. package/dist/src/components/Display.d.ts +4 -0
  10. package/dist/src/components/Display.js +7 -0
  11. package/dist/src/components/Frame.d.ts +7 -0
  12. package/dist/src/components/Frame.js +14 -0
  13. package/dist/src/components/Header.d.ts +11 -0
  14. package/dist/src/components/Header.js +15 -0
  15. package/dist/src/components/Logo.d.ts +5 -0
  16. package/dist/src/components/Logo.js +7 -0
  17. package/dist/src/components/Menu.d.ts +12 -0
  18. package/dist/src/components/Menu.js +17 -0
  19. package/dist/src/components/Page.d.ts +6 -0
  20. package/dist/src/components/Page.js +6 -0
  21. package/dist/src/components/Sidebar.d.ts +15 -0
  22. package/dist/src/components/Sidebar.js +66 -0
  23. package/dist/src/components/index.d.ts +8 -0
  24. package/dist/src/components/index.js +8 -0
  25. package/dist/src/components/ui/color-mode.d.ts +21 -0
  26. package/dist/src/components/ui/color-mode.js +44 -0
  27. package/dist/src/hooks/index.d.ts +3 -0
  28. package/dist/src/hooks/index.js +3 -0
  29. package/dist/src/hooks/useBreakpoint.d.ts +1 -0
  30. package/dist/src/hooks/useBreakpoint.js +12 -0
  31. package/dist/src/hooks/useIsMobile.d.ts +1 -0
  32. package/dist/src/hooks/useIsMobile.js +6 -0
  33. package/dist/src/hooks/useSelectedColorSchema.d.ts +5 -0
  34. package/dist/src/hooks/useSelectedColorSchema.js +8 -0
  35. package/dist/src/stories/AvatarIconMenu.stories.d.ts +18 -0
  36. package/dist/src/stories/AvatarIconMenu.stories.js +27 -0
  37. package/dist/src/stories/Breadcrumbs.stories.d.ts +14 -0
  38. package/dist/src/stories/Breadcrumbs.stories.js +22 -0
  39. package/dist/src/stories/Frame.stories.d.ts +24 -0
  40. package/dist/src/stories/Frame.stories.js +56 -0
  41. package/dist/src/stories/Header.stories.d.ts +22 -0
  42. package/dist/src/stories/Header.stories.js +39 -0
  43. package/dist/src/stories/Menu.stories.d.ts +12 -0
  44. package/dist/src/stories/Menu.stories.js +17 -0
  45. package/dist/src/stories/Sidebar.stories.d.ts +16 -0
  46. package/dist/src/stories/Sidebar.stories.js +25 -0
  47. package/dist/src/utils/calculate.d.ts +5 -0
  48. package/dist/src/utils/calculate.js +15 -0
  49. package/dist/src/utils/cookies.d.ts +5 -0
  50. package/dist/src/utils/cookies.js +26 -0
  51. package/dist/src/utils/data.d.ts +6 -0
  52. package/dist/src/utils/data.js +20 -0
  53. package/dist/src/utils/format.d.ts +23 -0
  54. package/dist/src/utils/format.js +76 -0
  55. package/dist/src/utils/index.d.ts +14 -0
  56. package/dist/src/utils/index.js +13 -0
  57. package/dist/src/utils/validation.d.ts +13 -0
  58. package/dist/src/utils/validation.js +66 -0
  59. package/package.json +63 -0
package/README.md ADDED
@@ -0,0 +1,73 @@
1
+ # React + TypeScript + Vite
2
+
3
+ This template provides a minimal setup to get React working in Vite with HMR and some ESLint rules.
4
+
5
+ Currently, two official plugins are available:
6
+
7
+ - [@vitejs/plugin-react](https://github.com/vitejs/vite-plugin-react/blob/main/packages/plugin-react) uses [Babel](https://babeljs.io/) (or [oxc](https://oxc.rs) when used in [rolldown-vite](https://vite.dev/guide/rolldown)) for Fast Refresh
8
+ - [@vitejs/plugin-react-swc](https://github.com/vitejs/vite-plugin-react/blob/main/packages/plugin-react-swc) uses [SWC](https://swc.rs/) for Fast Refresh
9
+
10
+ ## React Compiler
11
+
12
+ The React Compiler is not enabled on this template because of its impact on dev & build performances. To add it, see [this documentation](https://react.dev/learn/react-compiler/installation).
13
+
14
+ ## Expanding the ESLint configuration
15
+
16
+ If you are developing a production application, we recommend updating the configuration to enable type-aware lint rules:
17
+
18
+ ```js
19
+ export default defineConfig([
20
+ globalIgnores(['dist']),
21
+ {
22
+ files: ['**/*.{ts,tsx}'],
23
+ extends: [
24
+ // Other configs...
25
+
26
+ // Remove tseslint.configs.recommended and replace with this
27
+ tseslint.configs.recommendedTypeChecked,
28
+ // Alternatively, use this for stricter rules
29
+ tseslint.configs.strictTypeChecked,
30
+ // Optionally, add this for stylistic rules
31
+ tseslint.configs.stylisticTypeChecked,
32
+
33
+ // Other configs...
34
+ ],
35
+ languageOptions: {
36
+ parserOptions: {
37
+ project: ['./tsconfig.node.json', './tsconfig.app.json'],
38
+ tsconfigRootDir: import.meta.dirname,
39
+ },
40
+ // other options...
41
+ },
42
+ },
43
+ ])
44
+ ```
45
+
46
+ You can also install [eslint-plugin-react-x](https://github.com/Rel1cx/eslint-react/tree/main/packages/plugins/eslint-plugin-react-x) and [eslint-plugin-react-dom](https://github.com/Rel1cx/eslint-react/tree/main/packages/plugins/eslint-plugin-react-dom) for React-specific lint rules:
47
+
48
+ ```js
49
+ // eslint.config.js
50
+ import reactX from 'eslint-plugin-react-x'
51
+ import reactDom from 'eslint-plugin-react-dom'
52
+
53
+ export default defineConfig([
54
+ globalIgnores(['dist']),
55
+ {
56
+ files: ['**/*.{ts,tsx}'],
57
+ extends: [
58
+ // Other configs...
59
+ // Enable lint rules for React
60
+ reactX.configs['recommended-typescript'],
61
+ // Enable lint rules for React DOM
62
+ reactDom.configs.recommended,
63
+ ],
64
+ languageOptions: {
65
+ parserOptions: {
66
+ project: ['./tsconfig.node.json', './tsconfig.app.json'],
67
+ tsconfigRootDir: import.meta.dirname,
68
+ },
69
+ // other options...
70
+ },
71
+ },
72
+ ])
73
+ ```
@@ -0,0 +1,3 @@
1
+ export * from './src/components';
2
+ export * as utils from './src/utils';
3
+ export * from './src/hooks';
package/dist/index.js ADDED
@@ -0,0 +1,3 @@
1
+ export * from './src/components';
2
+ export * as utils from './src/utils';
3
+ export * from './src/hooks';
@@ -0,0 +1,63 @@
1
+ {
2
+ "name": "@vrobots/storybook",
3
+ "private": false,
4
+ "version": "0.1.0",
5
+ "type": "module",
6
+ "main": "dist/index.js",
7
+ "types": "dist/index.d.ts",
8
+ "publishConfig": {
9
+ "access": "public"
10
+ },
11
+ "files": [
12
+ "dist"
13
+ ],
14
+ "scripts": {
15
+ "build": "tsc -declaration",
16
+ "lint": "eslint .",
17
+ "storybook": "storybook dev -p 6006",
18
+ "pre-publish": "rimraf dist; npm run build"
19
+ },
20
+ "dependencies": {
21
+ "@chakra-ui/react": "^3.32.0",
22
+ "@emotion/react": "^11.14.0",
23
+ "@storybook/addon-themes": "^10.2.6",
24
+ "axios": "^1.13.4",
25
+ "motion": "^12.34.0",
26
+ "next-themes": "^0.4.6",
27
+ "owasp-password-strength-test": "^1.3.0",
28
+ "react": "^19.2.0",
29
+ "react-dnd": "^16.0.1",
30
+ "react-dnd-html5-backend": "^16.0.1",
31
+ "react-dnd-touch-backend": "^16.0.1",
32
+ "react-dom": "^19.2.0",
33
+ "react-icons": "^5.5.0"
34
+ },
35
+ "devDependencies": {
36
+ "@chromatic-com/storybook": "^5.0.0",
37
+ "@eslint/js": "^9.39.1",
38
+ "@storybook/addon-a11y": "^10.2.6",
39
+ "@storybook/addon-docs": "^10.2.6",
40
+ "@storybook/addon-vitest": "^10.2.6",
41
+ "@storybook/react-vite": "^10.2.6",
42
+ "@types/node": "^24.10.1",
43
+ "@types/react": "^19.2.5",
44
+ "@types/react-dom": "^19.2.3",
45
+ "@vitejs/plugin-react": "^5.1.1",
46
+ "@vitest/browser-playwright": "^4.0.18",
47
+ "@vitest/coverage-v8": "^4.0.18",
48
+ "@vrobots/types": "^0.4.17",
49
+ "eslint": "^9.39.1",
50
+ "eslint-plugin-react-hooks": "^7.0.1",
51
+ "eslint-plugin-react-refresh": "^0.4.24",
52
+ "eslint-plugin-storybook": "^10.2.6",
53
+ "globals": "^16.5.0",
54
+ "playwright": "^1.58.1",
55
+ "rimraf": "^6.1.2",
56
+ "storybook": "^10.2.6",
57
+ "ts-node": "^10.9.2",
58
+ "typescript": "~5.9.3",
59
+ "typescript-eslint": "^8.46.4",
60
+ "vite": "^7.2.4",
61
+ "vitest": "^4.0.18"
62
+ }
63
+ }
@@ -0,0 +1,8 @@
1
+ import { IMenuItemsProps } from "./Menu";
2
+ export interface IAvatarIconMenuProps {
3
+ src: string;
4
+ name: string;
5
+ menu: IMenuItemsProps[];
6
+ }
7
+ export declare const createMenuItem: (item: IMenuItemsProps) => import("react/jsx-runtime").JSX.Element;
8
+ export declare const AvatarIconMenu: ({ src, name, menu, }: IAvatarIconMenuProps) => import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,8 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { Avatar, Menu, Portal } from "@chakra-ui/react";
3
+ export const createMenuItem = (item) => {
4
+ return (_jsx(Menu.Item, { value: item.value, children: item.label }));
5
+ };
6
+ export const AvatarIconMenu = ({ src, name, menu, }) => {
7
+ return (_jsxs(Menu.Root, { positioning: { placement: "right-end" }, children: [_jsx(Menu.Trigger, { rounded: "full", focusRing: "outside", children: _jsxs(Avatar.Root, { size: { base: 'xs', md: 'sm' }, children: [_jsx(Avatar.Fallback, { name: name }), _jsx(Avatar.Image, { src: src })] }) }), _jsx(Portal, { children: _jsx(Menu.Positioner, { children: _jsx(Menu.Content, { children: menu.map((item) => createMenuItem(item)) }) }) })] }));
8
+ };
@@ -0,0 +1,11 @@
1
+ import React from "react";
2
+ import { TColor } from "../types";
3
+ export interface IBreadcrumb {
4
+ title: string;
5
+ nav?: string;
6
+ color?: TColor;
7
+ }
8
+ export interface BreadcrumbProps {
9
+ breadcrumbs?: IBreadcrumb[];
10
+ }
11
+ export declare const Breadcrumbs: React.ForwardRefExoticComponent<BreadcrumbProps & React.RefAttributes<HTMLDivElement>>;
@@ -0,0 +1,18 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import React from "react";
3
+ import { HStack, Link, Text } from "@chakra-ui/react";
4
+ import { useSelectedColorSchema } from "../hooks/useSelectedColorSchema";
5
+ export const Breadcrumbs = React.forwardRef(({ breadcrumbs }, ref) => {
6
+ const { color } = useSelectedColorSchema('blue');
7
+ if (!!breadcrumbs) {
8
+ const crumbs = breadcrumbs.map(({ title, nav, color: itemColor }, key) => {
9
+ if (!!nav) {
10
+ return (_jsxs(HStack, { children: [_jsx(Link, { href: nav, color: itemColor || color, whiteSpace: 'nowrap', wordBreak: 'break-word', fontSize: 'sm', truncate: true, children: title }), _jsx(Text, { ml: 2, mr: 2, fontSize: 'sm', children: ">" })] }, `${title}-${key}`));
11
+ }
12
+ return (_jsx(Text, { whiteSpace: 'nowrap', wordBreak: 'break-word', color: color || 'gray.500', fontSize: 'sm', truncate: true, children: title }, `${title}-${key}`));
13
+ });
14
+ return (_jsx(HStack, { width: '100%', flex: `0 1 auto`, ref: ref, children: crumbs }));
15
+ }
16
+ return null;
17
+ });
18
+ Breadcrumbs.displayName = 'Breadcrumbs';
@@ -0,0 +1,4 @@
1
+ export interface IDisplayProps {
2
+ children?: React.ReactNode;
3
+ }
4
+ export declare const Display: import("react").ForwardRefExoticComponent<IDisplayProps & import("react").RefAttributes<HTMLDivElement>>;
@@ -0,0 +1,7 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { Box } from "@chakra-ui/react";
3
+ import { forwardRef } from "react";
4
+ export const Display = forwardRef((props, ref) => {
5
+ return (_jsx(Box, { ref: ref, height: 'inherit', width: '100%', children: props.children }));
6
+ });
7
+ Display.displayName = 'Display';
@@ -0,0 +1,7 @@
1
+ import React from "react";
2
+ import { IHeaderProps } from "./Header";
3
+ export interface IFrameProps {
4
+ children?: React.ReactNode;
5
+ headerProps: IHeaderProps;
6
+ }
7
+ export declare const Frame: React.ForwardRefExoticComponent<IFrameProps & React.RefAttributes<HTMLDivElement>>;
@@ -0,0 +1,14 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { Box, HStack } from "@chakra-ui/react";
3
+ import React, { forwardRef } from "react";
4
+ import { Header } from "./Header";
5
+ import { Sidebar } from "./Sidebar";
6
+ import { Display } from "./Display";
7
+ export const Frame = forwardRef((props, ref) => {
8
+ const { headerProps, } = props;
9
+ const headerRef = React.useRef(null);
10
+ const sidebarRef = React.useRef(null);
11
+ 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 })] })] }));
13
+ });
14
+ Frame.displayName = 'Frame';
@@ -0,0 +1,11 @@
1
+ import React from 'react';
2
+ export interface IHeaderProps {
3
+ appName?: string;
4
+ logo: {
5
+ light: string;
6
+ dark: string;
7
+ };
8
+ menu: React.ReactNode | null;
9
+ version?: string | null;
10
+ }
11
+ export declare const Header: React.ForwardRefExoticComponent<IHeaderProps & React.RefAttributes<HTMLDivElement>>;
@@ -0,0 +1,15 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { defaultSystem, Grid, GridItem, Text } from '@chakra-ui/react';
3
+ import { forwardRef } from 'react';
4
+ import { Logo } from './Logo';
5
+ import { useColorMode } from './ui/color-mode';
6
+ export const Header = forwardRef(({ appName, logo, menu = null, version = null, }, ref) => {
7
+ const { colorMode } = useColorMode();
8
+ const selectedLogo = logo[colorMode];
9
+ const borderColors = { ...defaultSystem }._config.theme?.semanticTokens?.colors.border.DEFAULT.value;
10
+ const borderColor = colorMode === 'light' ? borderColors._light : borderColors._dark;
11
+ return (_jsxs(Grid, { id: 'header', width: '100%', position: 'relative', zIndex: 2, backgroundColor: colorMode === 'light' ? 'white' : 'black', borderBottom: `1px solid ${borderColor}`, templateColumns: {
12
+ base: 'repeat(12, 1fr)',
13
+ }, ref: ref, children: [_jsxs(GridItem, { colSpan: 6, pt: { base: '0', lg: '8px' }, pb: { base: '0', lg: '8px' }, children: [_jsx(Logo, { alt: appName, src: selectedLogo }), _jsx(Text, { position: 'absolute', fontSize: 'xx-small', bottom: 0, left: 0, ml: 1, color: 'gray.500', children: !!version && _jsxs("em", { children: ["v. ", version] }) })] }), _jsx(GridItem, { colSpan: 6, alignItems: 'center', justifyContent: 'flex-end', pr: 2, display: 'flex', children: menu })] }));
14
+ });
15
+ Header.displayName = 'Header';
@@ -0,0 +1,5 @@
1
+ import { ImageProps } from "@chakra-ui/react";
2
+ export interface ILogoProps extends ImageProps {
3
+ defaultPath?: string;
4
+ }
5
+ export declare const Logo: (props: ILogoProps) => import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,7 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { Image, Link } from "@chakra-ui/react";
3
+ export const Logo = (props) => {
4
+ const imageProps = { ...props, defaultPath: undefined };
5
+ const { defaultPath } = props;
6
+ return (_jsx(Link, { href: defaultPath, style: { textDecoration: 'none' }, children: _jsx(Image, { height: { base: '40px', md: '60px' }, p: 2, ...imageProps }) }));
7
+ };
@@ -0,0 +1,12 @@
1
+ import React from "react";
2
+ export interface IMenuItemsProps {
3
+ label: string;
4
+ value: string;
5
+ }
6
+ export interface IMenuProps {
7
+ menuItems?: IMenuItemsProps[];
8
+ label?: string;
9
+ defaultSelected?: string[];
10
+ onClick?: (value: string[]) => void;
11
+ }
12
+ export declare const Menu: React.ForwardRefExoticComponent<IMenuProps & React.RefAttributes<unknown>>;
@@ -0,0 +1,17 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { createListCollection, Listbox } from "@chakra-ui/react";
3
+ import React, { forwardRef } from "react";
4
+ import { useSelectedColorSchema } from "../hooks/useSelectedColorSchema";
5
+ export const Menu = forwardRef(({ label, menuItems, defaultSelected = [], onClick, }) => {
6
+ const [value, setValue] = React.useState(defaultSelected);
7
+ const frameworks = React.useMemo(() => createListCollection({
8
+ items: menuItems || [],
9
+ }), [menuItems]);
10
+ const selectedColorSchema = useSelectedColorSchema('blue');
11
+ const handleValueChange = (details) => {
12
+ setValue(details.value);
13
+ onClick?.(details.value);
14
+ };
15
+ return (_jsxs(Listbox.Root, { collection: frameworks, value: value, onValueChange: handleValueChange, pt: 4, children: [!!label && _jsx(Listbox.Label, { pl: 5, children: label }), _jsx(Listbox.Content, { border: 0, bgColor: 'transparent', children: frameworks.items.map((framework, i) => (_jsx(Listbox.Item, { item: framework, pl: 4, pr: 4, ...(value.includes(framework.value) ? selectedColorSchema : undefined), children: _jsx(Listbox.ItemText, { children: framework.label }) }, `${framework.label} ${i + 1}`))) })] }));
16
+ });
17
+ Menu.displayName = 'Menu';
@@ -0,0 +1,6 @@
1
+ import { IBreadcrumb } from "./Breadcrumbs";
2
+ export interface IPageProps {
3
+ breadcrumbs?: IBreadcrumb[];
4
+ children: React.ReactNode;
5
+ }
6
+ export declare const Page: ({ breadcrumbs, children }: IPageProps) => import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,6 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { Box } from "@chakra-ui/react";
3
+ import { Breadcrumbs } from "./Breadcrumbs";
4
+ export const Page = ({ breadcrumbs, children }) => {
5
+ return (_jsxs(Box, { flex: 1, display: 'flex', flexDirection: 'column', alignItems: 'stretch', overflow: 'hidden', minHeight: '100%', p: 4, children: [_jsx(Breadcrumbs, { breadcrumbs: breadcrumbs }), _jsx(Box, { flex: '1 1 auto', mt: !!breadcrumbs?.length ? 2 : 0, children: children })] }));
6
+ };
@@ -0,0 +1,15 @@
1
+ import { IconButtonProps } from "@chakra-ui/react";
2
+ import React from "react";
3
+ export interface ISidebarProps {
4
+ isOpen?: boolean;
5
+ menu?: React.ReactNode | null;
6
+ setIsOpen?: React.Dispatch<React.SetStateAction<boolean>>;
7
+ setMenu?: React.Dispatch<React.SetStateAction<React.ReactNode | null>>;
8
+ toggleSidebar?: () => void;
9
+ children?: React.ReactNode;
10
+ }
11
+ export declare const SidebarContext: React.Context<ISidebarProps>;
12
+ export declare const SidebarProvider: React.FC<ISidebarProps>;
13
+ export declare const useSidebar: () => ISidebarProps;
14
+ export declare const SidebarToggleButton: React.FC<IconButtonProps>;
15
+ export declare const Sidebar: React.ForwardRefExoticComponent<React.RefAttributes<HTMLDivElement>>;
@@ -0,0 +1,66 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { Box, defaultSystem, IconButton } from "@chakra-ui/react";
3
+ import { useColorMode } from "./ui/color-mode";
4
+ import React, { forwardRef } from "react";
5
+ import { LuMenu } from "react-icons/lu";
6
+ import { motion } from "motion/react";
7
+ import { useBreakpoint, useIsMobile } from "../hooks";
8
+ const COLOR_GRAY_200 = '#e4e4e7';
9
+ const COLOR_GRAY_800 = '#27272a';
10
+ export const SidebarContext = React.createContext({});
11
+ export const SidebarProvider = (props) => {
12
+ const [isOpen, setIsOpen] = React.useState(props?.isOpen || false);
13
+ const [menu, setMenu] = React.useState(props?.menu || null);
14
+ const toggleSidebar = () => setIsOpen(!isOpen);
15
+ React.useEffect(() => {
16
+ setIsOpen(props.isOpen || false);
17
+ }, [props.isOpen]);
18
+ React.useEffect(() => {
19
+ setMenu(props.menu || null);
20
+ }, [props.menu]);
21
+ return (_jsx(SidebarContext.Provider, { value: { ...props, isOpen, menu, setIsOpen, setMenu, toggleSidebar }, children: props.children }));
22
+ };
23
+ export const useSidebar = () => React.useContext(SidebarContext);
24
+ export const SidebarToggleButton = (props) => {
25
+ const { toggleSidebar } = useSidebar();
26
+ return (_jsx(IconButton, { onClick: toggleSidebar, position: 'absolute', bottom: 2, right: 2, zIndex: 3, variant: 'ghost', ...props, children: _jsx(LuMenu, {}) }));
27
+ };
28
+ export const Sidebar = forwardRef((props, ref) => {
29
+ const sidebar = useSidebar();
30
+ const { colorMode } = useColorMode();
31
+ const breakpoint = useBreakpoint();
32
+ const isMobile = useIsMobile();
33
+ const width = {
34
+ base: '100vw',
35
+ sm: '100vw',
36
+ md: '200px',
37
+ lg: '300px',
38
+ xl: '300px',
39
+ '2xl': '300px',
40
+ };
41
+ const open = {
42
+ initial: { width: '0' },
43
+ animate: { width: width[breakpoint || 'base'] },
44
+ transition: { duration: 0.2 }
45
+ };
46
+ const close = {
47
+ initial: { width: width[breakpoint || 'base'] },
48
+ animate: { width: '0' },
49
+ transition: { duration: 0.2 }
50
+ };
51
+ const action = sidebar.isOpen ? open : close;
52
+ const borderColors = { ...defaultSystem }._config.theme?.semanticTokens?.colors.border.DEFAULT.value;
53
+ const borderColor = colorMode === 'light' ? COLOR_GRAY_200 : COLOR_GRAY_800;
54
+ console.log(borderColor);
55
+ return (_jsx(SidebarContext.Provider, { value: sidebar, children: _jsx(motion.div, { style: {
56
+ position: 'relative',
57
+ display: 'flex',
58
+ flexDirection: 'column',
59
+ flex: '0 0 auto',
60
+ zIndex: 1,
61
+ overflow: 'hidden',
62
+ height: 'inherit',
63
+ borderRight: `1px solid ${borderColor}`,
64
+ }, ...action, ref: ref, children: _jsx(Box, { width: width[breakpoint || 'base'], children: sidebar.menu }) }) }));
65
+ });
66
+ Sidebar.displayName = 'Sidebar';
@@ -0,0 +1,8 @@
1
+ export * from './ui/color-mode';
2
+ export * from './Breadcrumbs';
3
+ export * from './Display';
4
+ export * from './Frame';
5
+ export * from './Header';
6
+ export * from './Logo';
7
+ export * from './Menu';
8
+ export * from './Sidebar';
@@ -0,0 +1,8 @@
1
+ export * from './ui/color-mode';
2
+ export * from './Breadcrumbs';
3
+ export * from './Display';
4
+ export * from './Frame';
5
+ export * from './Header';
6
+ export * from './Logo';
7
+ export * from './Menu';
8
+ export * from './Sidebar';
@@ -0,0 +1,21 @@
1
+ import type { IconButtonProps, SpanProps } from "@chakra-ui/react";
2
+ import { ThemeProviderProps } from "next-themes";
3
+ import * as React from "react";
4
+ export interface ColorModeProviderProps extends ThemeProviderProps {
5
+ }
6
+ export declare function ColorModeProvider(props: ColorModeProviderProps): import("react/jsx-runtime").JSX.Element;
7
+ export type ColorMode = "light" | "dark";
8
+ export interface UseColorModeReturn {
9
+ colorMode: ColorMode;
10
+ setColorMode: (colorMode: ColorMode) => void;
11
+ toggleColorMode: () => void;
12
+ }
13
+ export declare function useColorMode(): UseColorModeReturn;
14
+ export declare function useColorModeValue<T>(light: T, dark: T): T;
15
+ export declare function ColorModeIcon(): import("react/jsx-runtime").JSX.Element;
16
+ interface ColorModeButtonProps extends Omit<IconButtonProps, "aria-label"> {
17
+ }
18
+ export declare const ColorModeButton: React.ForwardRefExoticComponent<ColorModeButtonProps & React.RefAttributes<HTMLButtonElement>>;
19
+ export declare const LightMode: React.ForwardRefExoticComponent<SpanProps & React.RefAttributes<HTMLSpanElement>>;
20
+ export declare const DarkMode: React.ForwardRefExoticComponent<SpanProps & React.RefAttributes<HTMLSpanElement>>;
21
+ export {};
@@ -0,0 +1,44 @@
1
+ "use client";
2
+ import { jsx as _jsx } from "react/jsx-runtime";
3
+ import { ClientOnly, IconButton, Skeleton, Span } from "@chakra-ui/react";
4
+ import { ThemeProvider, useTheme } from "next-themes";
5
+ import * as React from "react";
6
+ import { LuMoon, LuSun } from "react-icons/lu";
7
+ export function ColorModeProvider(props) {
8
+ return (_jsx(ThemeProvider, { attribute: "class", disableTransitionOnChange: true, ...props }));
9
+ }
10
+ export function useColorMode() {
11
+ const { resolvedTheme, setTheme, forcedTheme } = useTheme();
12
+ const colorMode = forcedTheme || resolvedTheme;
13
+ const toggleColorMode = () => {
14
+ setTheme(resolvedTheme === "dark" ? "light" : "dark");
15
+ };
16
+ return {
17
+ colorMode: colorMode,
18
+ setColorMode: setTheme,
19
+ toggleColorMode,
20
+ };
21
+ }
22
+ export function useColorModeValue(light, dark) {
23
+ const { colorMode } = useColorMode();
24
+ return colorMode === "dark" ? dark : light;
25
+ }
26
+ export function ColorModeIcon() {
27
+ const { colorMode } = useColorMode();
28
+ return colorMode === "dark" ? _jsx(LuMoon, {}) : _jsx(LuSun, {});
29
+ }
30
+ export const ColorModeButton = React.forwardRef(function ColorModeButton(props, ref) {
31
+ const { toggleColorMode } = useColorMode();
32
+ return (_jsx(ClientOnly, { fallback: _jsx(Skeleton, { boxSize: "9" }), children: _jsx(IconButton, { onClick: toggleColorMode, variant: "ghost", "aria-label": "Toggle color mode", size: "sm", ref: ref, ...props, css: {
33
+ _icon: {
34
+ width: "5",
35
+ height: "5",
36
+ },
37
+ }, children: _jsx(ColorModeIcon, {}) }) }));
38
+ });
39
+ export const LightMode = React.forwardRef(function LightMode(props, ref) {
40
+ return (_jsx(Span, { color: "fg", display: "contents", className: "chakra-theme light", colorPalette: "gray", colorScheme: "light", ref: ref, ...props }));
41
+ });
42
+ export const DarkMode = React.forwardRef(function DarkMode(props, ref) {
43
+ return (_jsx(Span, { color: "fg", display: "contents", className: "chakra-theme dark", colorPalette: "gray", colorScheme: "dark", ref: ref, ...props }));
44
+ });
@@ -0,0 +1,3 @@
1
+ export * from './useBreakpoint';
2
+ export * from './useSelectedColorSchema';
3
+ export * from './useIsMobile';
@@ -0,0 +1,3 @@
1
+ export * from './useBreakpoint';
2
+ export * from './useSelectedColorSchema';
3
+ export * from './useIsMobile';
@@ -0,0 +1 @@
1
+ export declare const useBreakpoint: () => string | undefined;
@@ -0,0 +1,12 @@
1
+ import { useBreakpointValue } from "@chakra-ui/react";
2
+ export const useBreakpoint = () => {
3
+ const breakpoint = useBreakpointValue({
4
+ base: "base",
5
+ sm: "sm",
6
+ md: "md",
7
+ lg: "lg",
8
+ xl: "xl",
9
+ "2xl": "2xl",
10
+ });
11
+ return breakpoint;
12
+ };
@@ -0,0 +1 @@
1
+ export declare const useIsMobile: () => boolean;
@@ -0,0 +1,6 @@
1
+ import { useBreakpoint } from "./useBreakpoint";
2
+ export const useIsMobile = () => {
3
+ const breakpoint = useBreakpoint();
4
+ const isMobile = ['base', 'sm'].includes(breakpoint);
5
+ return isMobile;
6
+ };
@@ -0,0 +1,5 @@
1
+ import { TColor } from "../types";
2
+ export declare const useSelectedColorSchema: (color: TColor) => {
3
+ color: string;
4
+ bgColor: string;
5
+ };
@@ -0,0 +1,8 @@
1
+ import { useColorMode } from "../components";
2
+ export const useSelectedColorSchema = (color) => {
3
+ const { colorMode } = useColorMode();
4
+ return {
5
+ color: colorMode === 'light' ? `${color}.800` : `${color}.400`,
6
+ bgColor: colorMode === 'light' ? `${color}.200` : `${color}.800`,
7
+ };
8
+ };
@@ -0,0 +1,18 @@
1
+ import type { StoryObj } from '@storybook/react-vite';
2
+ import { IMenuItemsProps } from '../components';
3
+ declare const meta: {
4
+ title: string;
5
+ component: ({ src, name, menu, }: import("../components/AvatarIconMenu").IAvatarIconMenuProps) => import("react/jsx-runtime").JSX.Element;
6
+ tags: string[];
7
+ parameters: {
8
+ layout: string;
9
+ };
10
+ args: {
11
+ name: string;
12
+ src: string;
13
+ menu: IMenuItemsProps[];
14
+ };
15
+ };
16
+ export default meta;
17
+ type Story = StoryObj<typeof meta>;
18
+ export declare const Component: Story;
@@ -0,0 +1,27 @@
1
+ import { AvatarIconMenu } from '../components/AvatarIconMenu';
2
+ const menu = [
3
+ { label: 'Account', value: 'account' },
4
+ { label: 'Settings', value: 'settings' },
5
+ { label: 'Logout', value: 'logout' },
6
+ ];
7
+ const meta = {
8
+ title: 'Navigation/AvatarIconMenu',
9
+ component: AvatarIconMenu,
10
+ tags: ['autodocs'],
11
+ parameters: {
12
+ layout: 'fullscreen',
13
+ },
14
+ args: {
15
+ name: "Segun Adebayo",
16
+ src: "https://bit.ly/sage-adebayo",
17
+ menu,
18
+ }
19
+ };
20
+ export default meta;
21
+ export const Component = {
22
+ args: {
23
+ name: "Segun Adebayo",
24
+ src: "https://bit.ly/sage-adebayo",
25
+ menu,
26
+ }
27
+ };
@@ -0,0 +1,14 @@
1
+ import type { StoryObj } from '@storybook/react-vite';
2
+ import { IBreadcrumb } from '../components/Breadcrumbs';
3
+ export declare const EXAMPLE_BREADCRUMBS: IBreadcrumb[];
4
+ declare const meta: {
5
+ title: string;
6
+ component: import("react").ForwardRefExoticComponent<import("../components").BreadcrumbProps & import("react").RefAttributes<HTMLDivElement>>;
7
+ tags: string[];
8
+ parameters: {
9
+ layout: string;
10
+ };
11
+ };
12
+ export default meta;
13
+ type Story = StoryObj<typeof meta>;
14
+ export declare const Component: Story;