@vrobots/storybook 0.2.6 → 0.2.8
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/Loader.d.ts +13 -0
- package/dist/src/components/Loader.js +25 -0
- package/dist/src/components/index.d.ts +1 -0
- package/dist/src/components/index.js +1 -0
- package/dist/src/stories/Loader.stories.d.ts +19 -0
- package/dist/src/stories/Loader.stories.js +57 -0
- package/package.json +1 -1
package/dist/package.json
CHANGED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import React, { ReactNode } from "react";
|
|
2
|
+
export interface ILoaderProps {
|
|
3
|
+
component?: ReactNode;
|
|
4
|
+
isLoading?: boolean;
|
|
5
|
+
isFullscreen?: boolean;
|
|
6
|
+
hideBackground?: boolean;
|
|
7
|
+
children?: React.ReactNode;
|
|
8
|
+
}
|
|
9
|
+
export declare const useLoader: () => {
|
|
10
|
+
isLoading: boolean;
|
|
11
|
+
setIsLoading: React.Dispatch<React.SetStateAction<boolean>>;
|
|
12
|
+
};
|
|
13
|
+
export declare const Loader: ({ isLoading, isFullscreen, component, hideBackground, children }: ILoaderProps) => string | number | bigint | boolean | Iterable<React.ReactNode> | Promise<string | number | bigint | boolean | React.ReactPortal | React.ReactElement<unknown, string | React.JSXElementConstructor<any>> | Iterable<React.ReactNode> | null | undefined> | import("react/jsx-runtime").JSX.Element | null;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { Box, Spinner } from "@chakra-ui/react";
|
|
3
|
+
import React from "react";
|
|
4
|
+
export const useLoader = () => {
|
|
5
|
+
const [isLoading, setIsLoading] = React.useState(false);
|
|
6
|
+
return {
|
|
7
|
+
isLoading,
|
|
8
|
+
setIsLoading,
|
|
9
|
+
};
|
|
10
|
+
};
|
|
11
|
+
export const Loader = ({ isLoading, isFullscreen, component, hideBackground, children }) => {
|
|
12
|
+
if (!!isLoading) {
|
|
13
|
+
return (_jsx(Box, { style: {
|
|
14
|
+
position: isFullscreen ? 'fixed' : 'absolute',
|
|
15
|
+
top: 0,
|
|
16
|
+
right: 0,
|
|
17
|
+
bottom: 0,
|
|
18
|
+
left: 0,
|
|
19
|
+
zIndex: 100000,
|
|
20
|
+
maxHeight: '100vh',
|
|
21
|
+
display: 'flex',
|
|
22
|
+
}, bgColor: !hideBackground ? { _light: 'blue.50', _dark: 'gray.900' } : 'transparent', children: _jsxs(Box, { m: 'auto', children: [component && component, _jsx(Spinner, { position: 'static', m: 'auto' })] }) }));
|
|
23
|
+
}
|
|
24
|
+
return children ?? null;
|
|
25
|
+
};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { StoryObj } from '@storybook/react-vite';
|
|
2
|
+
declare const meta: {
|
|
3
|
+
title: string;
|
|
4
|
+
component: ({ isLoading, isFullscreen, component, hideBackground, children }: import("../components").ILoaderProps) => string | number | bigint | boolean | Iterable<import("react").ReactNode> | Promise<string | number | bigint | boolean | import("react").ReactPortal | import("react").ReactElement<unknown, string | import("react").JSXElementConstructor<any>> | Iterable<import("react").ReactNode> | null | undefined> | import("react/jsx-runtime").JSX.Element | null;
|
|
5
|
+
tags: string[];
|
|
6
|
+
parameters: {
|
|
7
|
+
layout: string;
|
|
8
|
+
};
|
|
9
|
+
args: {
|
|
10
|
+
isLoading: true;
|
|
11
|
+
};
|
|
12
|
+
};
|
|
13
|
+
export default meta;
|
|
14
|
+
type Story = StoryObj<typeof meta>;
|
|
15
|
+
export declare const Default: Story;
|
|
16
|
+
export declare const Fullscreen: Story;
|
|
17
|
+
export declare const NoBackground: Story;
|
|
18
|
+
export declare const CustomComponent: Story;
|
|
19
|
+
export declare const NotLoading: Story;
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { Box, Text } from '@chakra-ui/react';
|
|
3
|
+
import { Loader } from '../components';
|
|
4
|
+
const meta = {
|
|
5
|
+
title: 'Feedback/Loader',
|
|
6
|
+
component: Loader,
|
|
7
|
+
tags: ['autodocs'],
|
|
8
|
+
parameters: {
|
|
9
|
+
layout: 'centered',
|
|
10
|
+
},
|
|
11
|
+
args: {
|
|
12
|
+
isLoading: true,
|
|
13
|
+
},
|
|
14
|
+
};
|
|
15
|
+
export default meta;
|
|
16
|
+
export const Default = {
|
|
17
|
+
args: {
|
|
18
|
+
isLoading: true,
|
|
19
|
+
},
|
|
20
|
+
parameters: {
|
|
21
|
+
layout: 'fullscreen',
|
|
22
|
+
},
|
|
23
|
+
};
|
|
24
|
+
export const Fullscreen = {
|
|
25
|
+
args: {
|
|
26
|
+
isLoading: true,
|
|
27
|
+
isFullscreen: true,
|
|
28
|
+
},
|
|
29
|
+
parameters: {
|
|
30
|
+
layout: 'fullscreen',
|
|
31
|
+
},
|
|
32
|
+
};
|
|
33
|
+
export const NoBackground = {
|
|
34
|
+
args: {
|
|
35
|
+
isLoading: true,
|
|
36
|
+
hideBackground: true,
|
|
37
|
+
},
|
|
38
|
+
parameters: {
|
|
39
|
+
layout: 'fullscreen',
|
|
40
|
+
},
|
|
41
|
+
};
|
|
42
|
+
export const CustomComponent = {
|
|
43
|
+
args: {
|
|
44
|
+
isLoading: true,
|
|
45
|
+
component: _jsx(Text, { fontWeight: "bold", mb: 2, children: "Loading your data\u2026" }),
|
|
46
|
+
},
|
|
47
|
+
parameters: {
|
|
48
|
+
layout: 'fullscreen',
|
|
49
|
+
},
|
|
50
|
+
};
|
|
51
|
+
export const NotLoading = {
|
|
52
|
+
name: 'Not Loading — renders children',
|
|
53
|
+
args: {
|
|
54
|
+
isLoading: false,
|
|
55
|
+
children: (_jsx(Box, { p: 6, borderWidth: "1px", borderRadius: "md", children: _jsx(Text, { children: "Content is visible because isLoading is false." }) })),
|
|
56
|
+
},
|
|
57
|
+
};
|