@uni-design-system/uni-core 1.0.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.
- package/.editorconfig +10 -0
- package/.storybook/main.js +13 -0
- package/.storybook/preview.js +24 -0
- package/LICENSE +201 -0
- package/README.md +2 -0
- package/package.json +49 -0
- package/src/components/button/button.component.tsx +18 -0
- package/src/components/button/button.stories.tsx +22 -0
- package/src/components/card/card.component.tsx +14 -0
- package/src/core/backgrounds/background.model.ts +10 -0
- package/src/core/backgrounds/background.types.ts +2 -0
- package/src/core/border/border.types.ts +1 -0
- package/src/core/color/color.helper.ts +16 -0
- package/src/core/color/color.model.ts +42 -0
- package/src/core/color/color.types.ts +76 -0
- package/src/core/container/container.component.tsx +14 -0
- package/src/core/container/container.model.ts +50 -0
- package/src/core/core.types.ts +63 -0
- package/src/core/gradients/gradiennt.helper.ts +7 -0
- package/src/core/gradients/gradient.model.ts +7 -0
- package/src/core/gradients/gradient.types.ts +0 -0
- package/src/core/iconography/icon.model.ts +8 -0
- package/src/core/iconography/icon.types.ts +68 -0
- package/src/core/layout/layout.types.ts +5 -0
- package/src/core/masking/masking.model.ts +7 -0
- package/src/core/masking/masking.types.ts +1 -0
- package/src/core/shadow/shadow.types.ts +9 -0
- package/src/core/theme/theme.context.tsx +10 -0
- package/src/core/theme/theme.hook.tsx +18 -0
- package/src/core/theme/theme.model.ts +12 -0
- package/src/core/theme/theme.provider.tsx +56 -0
- package/src/core/theme/theme.records.ts +11 -0
- package/src/core/theme/theme.types.ts +2 -0
- package/src/core/theme/themes/dark.theme.ts +9 -0
- package/src/core/theme/themes/light.theme.ts +13 -0
- package/src/core/typography/typography.types.ts +10 -0
- package/src/stories/Button.stories.tsx +54 -0
- package/src/stories/Button.tsx +48 -0
- package/src/stories/Header.stories.tsx +25 -0
- package/src/stories/Header.tsx +56 -0
- package/src/stories/Introduction.stories.mdx +211 -0
- package/src/stories/Page.stories.tsx +26 -0
- package/src/stories/Page.tsx +73 -0
- package/src/stories/assets/code-brackets.svg +1 -0
- package/src/stories/assets/colors.svg +1 -0
- package/src/stories/assets/comments.svg +1 -0
- package/src/stories/assets/direction.svg +1 -0
- package/src/stories/assets/flow.svg +1 -0
- package/src/stories/assets/plugin.svg +1 -0
- package/src/stories/assets/repo.svg +1 -0
- package/src/stories/assets/stackalt.svg +1 -0
- package/src/stories/button.css +30 -0
- package/src/stories/header.css +32 -0
- package/src/stories/page.css +69 -0
- package/tsconfig.json +19 -0
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
export type color = 'white' | 'black' | 'red' | 'blue' | 'green';
|
|
2
|
+
|
|
3
|
+
export type style = 'solid' | 'outline' | 'gradient';
|
|
4
|
+
|
|
5
|
+
export type display = 'logo'
|
|
6
|
+
| 'alert'
|
|
7
|
+
| 'warn'
|
|
8
|
+
| 'disabled'
|
|
9
|
+
| 'trash'
|
|
10
|
+
| 'user'
|
|
11
|
+
| 'back'
|
|
12
|
+
| 'next'
|
|
13
|
+
| 'unlock'
|
|
14
|
+
| 'view'
|
|
15
|
+
| 'hide'
|
|
16
|
+
;
|
|
17
|
+
|
|
18
|
+
export type actionable = 'add'
|
|
19
|
+
| 'create'
|
|
20
|
+
| 'copy'
|
|
21
|
+
| 'edit'
|
|
22
|
+
| 'disable'
|
|
23
|
+
| 'save'
|
|
24
|
+
| 'pin'
|
|
25
|
+
| 'fav'
|
|
26
|
+
| 'tag'
|
|
27
|
+
| 'update'
|
|
28
|
+
| 'archive'
|
|
29
|
+
| 'delete'
|
|
30
|
+
| 'lock'
|
|
31
|
+
| 'unlock'
|
|
32
|
+
| 'view'
|
|
33
|
+
| 'hide'
|
|
34
|
+
;
|
|
35
|
+
|
|
36
|
+
export type behavior = 'open'
|
|
37
|
+
| 'expand'
|
|
38
|
+
| 'collapse'
|
|
39
|
+
;
|
|
40
|
+
|
|
41
|
+
export type messaging = 'alert'
|
|
42
|
+
| 'info'
|
|
43
|
+
| 'success'
|
|
44
|
+
| 'warn'
|
|
45
|
+
| 'warning'
|
|
46
|
+
;
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
export type usage = 'logo'
|
|
50
|
+
| 'alert'
|
|
51
|
+
| 'chat'
|
|
52
|
+
| 'down'
|
|
53
|
+
| 'favorite'
|
|
54
|
+
| 'info'
|
|
55
|
+
| 'location'
|
|
56
|
+
| 'lock'
|
|
57
|
+
| 'message'
|
|
58
|
+
| 'profile'
|
|
59
|
+
| 'question'
|
|
60
|
+
| 'remove'
|
|
61
|
+
| 'schedule'
|
|
62
|
+
| 'search'
|
|
63
|
+
| 'send'
|
|
64
|
+
| 'settings'
|
|
65
|
+
| 'share'
|
|
66
|
+
| 'unlock'
|
|
67
|
+
| 'up'
|
|
68
|
+
;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export type MaskingShape = 'square' | 'circle' | 'squircle' | 'rounded';
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { ThemeProps } from './theme.model';
|
|
3
|
+
|
|
4
|
+
const ThemeContext = React.createContext<ThemeProps>({});
|
|
5
|
+
|
|
6
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
7
|
+
ThemeContext.displayName = 'ThemeContext';
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export default ThemeContext;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import ThemeContext from './theme.context';
|
|
3
|
+
import { ThemeModel} from './theme.model';
|
|
4
|
+
import { LightTheme } from './themes/light.theme';
|
|
5
|
+
|
|
6
|
+
export default function useTheme(): ThemeModel {
|
|
7
|
+
|
|
8
|
+
const themeProps = React.useContext(ThemeContext);
|
|
9
|
+
|
|
10
|
+
const theme = themeProps && themeProps.themes && themeProps.themeId && themeProps.themes[themeProps.themeId];
|
|
11
|
+
|
|
12
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
13
|
+
// eslint-disable-next-line react-hooks/rules-of-hooks
|
|
14
|
+
React.useDebugValue(theme);
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
return theme || LightTheme;
|
|
18
|
+
}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import React, { useState, useEffect } from 'react';
|
|
2
|
+
import { DefaultThemeId } from './theme.records'
|
|
3
|
+
import { ThemeModel } from './theme.model';
|
|
4
|
+
import ThemeContext from './theme.context';
|
|
5
|
+
|
|
6
|
+
const STORAGE_KEY = 'THEME_ID';
|
|
7
|
+
|
|
8
|
+
interface ThemeProviderProps {
|
|
9
|
+
themeId: string;
|
|
10
|
+
themes: Record<string, ThemeModel>;
|
|
11
|
+
children?: React.ReactChild;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export const ThemeProvider = ({ children, themeId, themes }: ThemeProviderProps) => {
|
|
15
|
+
|
|
16
|
+
const [_themeId, setThemeId] = useState<string>(themeId);
|
|
17
|
+
|
|
18
|
+
useEffect(() => {
|
|
19
|
+
(async () => {
|
|
20
|
+
const id = localStorage.getItem(STORAGE_KEY);
|
|
21
|
+
if (id) {
|
|
22
|
+
setThemeId(id);
|
|
23
|
+
} else {
|
|
24
|
+
setThemeId(DefaultThemeId);
|
|
25
|
+
}
|
|
26
|
+
})();
|
|
27
|
+
}, []);
|
|
28
|
+
|
|
29
|
+
return (
|
|
30
|
+
<ThemeContext.Provider value={{themeId, themes}}>
|
|
31
|
+
{_themeId ? children : null}
|
|
32
|
+
</ThemeContext.Provider>
|
|
33
|
+
);
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
/*export function withTheme(Component: ({children, theme, themes }: (any & ThemeProps)) => JSX.Element) {
|
|
37
|
+
|
|
38
|
+
return (props: JSX.IntrinsicAttributes) => {
|
|
39
|
+
const { themeId, setThemeId } = useContext(ThemeContext);
|
|
40
|
+
|
|
41
|
+
const getTheme = (themeId: string) => themes[themeId];
|
|
42
|
+
const setTheme = (themeId: string) => {
|
|
43
|
+
localStorage.setItem(STORAGE_KEY, themeId);
|
|
44
|
+
setThemeId(themeId);
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
return (
|
|
48
|
+
<Component
|
|
49
|
+
{...props}
|
|
50
|
+
themes={Themes}
|
|
51
|
+
theme={getTheme(themeId)}
|
|
52
|
+
setTheme={setTheme}
|
|
53
|
+
/>
|
|
54
|
+
);
|
|
55
|
+
};
|
|
56
|
+
}*/
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { ThemeModel } from './theme.model';
|
|
2
|
+
import { DarkTheme } from './themes/dark.theme';
|
|
3
|
+
import { LightTheme } from './themes/light.theme';
|
|
4
|
+
|
|
5
|
+
export const BuiltInThemes: Record<string, ThemeModel> = {
|
|
6
|
+
LightTheme,
|
|
7
|
+
DarkTheme
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
// First Theme is default.
|
|
11
|
+
export const DefaultThemeId = Object.keys(BuiltInThemes)[0];
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { ThemeModel } from '../theme.model';
|
|
2
|
+
|
|
3
|
+
export const LightTheme: ThemeModel = {
|
|
4
|
+
id: 'LightTheme',
|
|
5
|
+
name: 'Light Theme',
|
|
6
|
+
colors: {
|
|
7
|
+
primary: '#35A7FF',
|
|
8
|
+
secondary: '#38618C',
|
|
9
|
+
error: '#FFE74C',
|
|
10
|
+
warn: '#FF5964',
|
|
11
|
+
background: '#FFFFFF'
|
|
12
|
+
}
|
|
13
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
|
|
2
|
+
export type classes = 'sanserif' | 'serif' | 'slab' | 'script' | 'display' | 'monospace';
|
|
3
|
+
|
|
4
|
+
export type families = 'Open-Sans' | 'Times-New-Roman' | 'Noto-Serif-Display';
|
|
5
|
+
|
|
6
|
+
export type styles = 'thin' | 'light' | 'regular' | 'medium' | 'bold' | 'semi-bold' | 'black';
|
|
7
|
+
|
|
8
|
+
export type placement = 'overline' | 'title' | 'underline' | 'body' | 'label' | 'note' | 'footer';
|
|
9
|
+
|
|
10
|
+
export type alignment = 'left' | 'right' | 'center';
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { ComponentStory, ComponentMeta } from '@storybook/react';
|
|
3
|
+
|
|
4
|
+
// @ts-ignore
|
|
5
|
+
import { withThemes } from '@react-theming/storybook-addon';
|
|
6
|
+
|
|
7
|
+
import { Button } from './Button';
|
|
8
|
+
import { BuiltInThemes, DefaultThemeId } from '../core/theme/theme.records';
|
|
9
|
+
import { ThemeProvider } from '../core/theme/theme.provider';
|
|
10
|
+
import { ThemeProps } from '../core/theme/theme.model';
|
|
11
|
+
|
|
12
|
+
// create decorator
|
|
13
|
+
const themingDecorator = withThemes(ThemeProvider, [DefaultThemeId]);
|
|
14
|
+
|
|
15
|
+
const providerFn = ({theme, children}: any & ThemeProps) => {
|
|
16
|
+
return <ThemeProvider themeId={theme.id} themes={BuiltInThemes}>{children}</ThemeProvider>;
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
// More on default export: https://storybook.js.org/docs/react/writing-stories/introduction#default-export
|
|
20
|
+
export default {
|
|
21
|
+
title: 'Example/Button',
|
|
22
|
+
component: Button,
|
|
23
|
+
// More on argTypes: https://storybook.js.org/docs/react/api/argtypes
|
|
24
|
+
argTypes: {
|
|
25
|
+
backgroundColor: { control: 'color' },
|
|
26
|
+
},
|
|
27
|
+
} as ComponentMeta<typeof Button>;
|
|
28
|
+
|
|
29
|
+
// More on component templates: https://storybook.js.org/docs/react/writing-stories/introduction#using-args
|
|
30
|
+
const Template: ComponentStory<typeof Button> = (args) => <Button {...args} />;
|
|
31
|
+
|
|
32
|
+
export const Primary = Template.bind({});
|
|
33
|
+
// More on args: https://storybook.js.org/docs/react/writing-stories/args
|
|
34
|
+
Primary.args = {
|
|
35
|
+
primary: true,
|
|
36
|
+
label: 'Button',
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
export const Secondary = Template.bind({});
|
|
40
|
+
Secondary.args = {
|
|
41
|
+
label: 'Button',
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
export const Large = Template.bind({});
|
|
45
|
+
Large.args = {
|
|
46
|
+
size: 'large',
|
|
47
|
+
label: 'Button',
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
export const Small = Template.bind({});
|
|
51
|
+
Small.args = {
|
|
52
|
+
size: 'small',
|
|
53
|
+
label: 'Button',
|
|
54
|
+
};
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import './button.css';
|
|
3
|
+
|
|
4
|
+
interface ButtonProps {
|
|
5
|
+
/**
|
|
6
|
+
* Is this the principal call to action on the page?
|
|
7
|
+
*/
|
|
8
|
+
primary?: boolean;
|
|
9
|
+
/**
|
|
10
|
+
* What background color to use
|
|
11
|
+
*/
|
|
12
|
+
backgroundColor?: string;
|
|
13
|
+
/**
|
|
14
|
+
* How large should the button be?
|
|
15
|
+
*/
|
|
16
|
+
size?: 'small' | 'medium' | 'large';
|
|
17
|
+
/**
|
|
18
|
+
* Button contents
|
|
19
|
+
*/
|
|
20
|
+
label: string;
|
|
21
|
+
/**
|
|
22
|
+
* Optional click handler
|
|
23
|
+
*/
|
|
24
|
+
onClick?: () => void;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* Primary UI component for user interaction
|
|
29
|
+
*/
|
|
30
|
+
export const Button = ({
|
|
31
|
+
primary = false,
|
|
32
|
+
size = 'medium',
|
|
33
|
+
backgroundColor,
|
|
34
|
+
label,
|
|
35
|
+
...props
|
|
36
|
+
}: ButtonProps) => {
|
|
37
|
+
const mode = primary ? 'storybook-button--primary' : 'storybook-button--secondary';
|
|
38
|
+
return (
|
|
39
|
+
<button
|
|
40
|
+
type="button"
|
|
41
|
+
className={['storybook-button', `storybook-button--${size}`, mode].join(' ')}
|
|
42
|
+
style={{ backgroundColor }}
|
|
43
|
+
{...props}
|
|
44
|
+
>
|
|
45
|
+
{label}
|
|
46
|
+
</button>
|
|
47
|
+
);
|
|
48
|
+
};
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { ComponentStory, ComponentMeta } from '@storybook/react';
|
|
3
|
+
|
|
4
|
+
import { Header } from './Header';
|
|
5
|
+
|
|
6
|
+
export default {
|
|
7
|
+
title: 'Example/Header',
|
|
8
|
+
component: Header,
|
|
9
|
+
parameters: {
|
|
10
|
+
// More on Story layout: https://storybook.js.org/docs/react/configure/story-layout
|
|
11
|
+
layout: 'fullscreen',
|
|
12
|
+
},
|
|
13
|
+
} as ComponentMeta<typeof Header>;
|
|
14
|
+
|
|
15
|
+
const Template: ComponentStory<typeof Header> = (args) => <Header {...args} />;
|
|
16
|
+
|
|
17
|
+
export const LoggedIn = Template.bind({});
|
|
18
|
+
LoggedIn.args = {
|
|
19
|
+
user: {
|
|
20
|
+
name: 'Jane Doe',
|
|
21
|
+
},
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
export const LoggedOut = Template.bind({});
|
|
25
|
+
LoggedOut.args = {};
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
|
|
3
|
+
import { Button } from './Button';
|
|
4
|
+
import './header.css';
|
|
5
|
+
|
|
6
|
+
type User = {
|
|
7
|
+
name: string;
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
interface HeaderProps {
|
|
11
|
+
user?: User;
|
|
12
|
+
onLogin: () => void;
|
|
13
|
+
onLogout: () => void;
|
|
14
|
+
onCreateAccount: () => void;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export const Header = ({ user, onLogin, onLogout, onCreateAccount }: HeaderProps) => (
|
|
18
|
+
<header>
|
|
19
|
+
<div className="wrapper">
|
|
20
|
+
<div>
|
|
21
|
+
<svg width="32" height="32" viewBox="0 0 32 32" xmlns="http://www.w3.org/2000/svg">
|
|
22
|
+
<g fill="none" fillRule="evenodd">
|
|
23
|
+
<path
|
|
24
|
+
d="M10 0h12a10 10 0 0110 10v12a10 10 0 01-10 10H10A10 10 0 010 22V10A10 10 0 0110 0z"
|
|
25
|
+
fill="#FFF"
|
|
26
|
+
/>
|
|
27
|
+
<path
|
|
28
|
+
d="M5.3 10.6l10.4 6v11.1l-10.4-6v-11zm11.4-6.2l9.7 5.5-9.7 5.6V4.4z"
|
|
29
|
+
fill="#555AB9"
|
|
30
|
+
/>
|
|
31
|
+
<path
|
|
32
|
+
d="M27.2 10.6v11.2l-10.5 6V16.5l10.5-6zM15.7 4.4v11L6 10l9.7-5.5z"
|
|
33
|
+
fill="#91BAF8"
|
|
34
|
+
/>
|
|
35
|
+
</g>
|
|
36
|
+
</svg>
|
|
37
|
+
<h1>Acme</h1>
|
|
38
|
+
</div>
|
|
39
|
+
<div>
|
|
40
|
+
{user ? (
|
|
41
|
+
<>
|
|
42
|
+
<span className="welcome">
|
|
43
|
+
Welcome, <b>{user.name}</b>!
|
|
44
|
+
</span>
|
|
45
|
+
<Button size="small" onClick={onLogout} label="Log out" />
|
|
46
|
+
</>
|
|
47
|
+
) : (
|
|
48
|
+
<>
|
|
49
|
+
<Button size="small" onClick={onLogin} label="Log in" />
|
|
50
|
+
<Button primary size="small" onClick={onCreateAccount} label="Sign up" />
|
|
51
|
+
</>
|
|
52
|
+
)}
|
|
53
|
+
</div>
|
|
54
|
+
</div>
|
|
55
|
+
</header>
|
|
56
|
+
);
|
|
@@ -0,0 +1,211 @@
|
|
|
1
|
+
import { Meta } from '@storybook/addon-docs';
|
|
2
|
+
import Code from './assets/code-brackets.svg';
|
|
3
|
+
import Colors from './assets/colors.svg';
|
|
4
|
+
import Comments from './assets/comments.svg';
|
|
5
|
+
import Direction from './assets/direction.svg';
|
|
6
|
+
import Flow from './assets/flow.svg';
|
|
7
|
+
import Plugin from './assets/plugin.svg';
|
|
8
|
+
import Repo from './assets/repo.svg';
|
|
9
|
+
import StackAlt from './assets/stackalt.svg';
|
|
10
|
+
|
|
11
|
+
<Meta title="Example/Introduction" />
|
|
12
|
+
|
|
13
|
+
<style>{`
|
|
14
|
+
.subheading {
|
|
15
|
+
--mediumdark: '#999999';
|
|
16
|
+
font-weight: 900;
|
|
17
|
+
font-size: 13px;
|
|
18
|
+
color: #999;
|
|
19
|
+
letter-spacing: 6px;
|
|
20
|
+
line-height: 24px;
|
|
21
|
+
text-transform: uppercase;
|
|
22
|
+
margin-bottom: 12px;
|
|
23
|
+
margin-top: 40px;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
.link-list {
|
|
27
|
+
display: grid;
|
|
28
|
+
grid-template-columns: 1fr;
|
|
29
|
+
grid-template-rows: 1fr 1fr;
|
|
30
|
+
row-gap: 10px;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
@media (min-width: 620px) {
|
|
34
|
+
.link-list {
|
|
35
|
+
row-gap: 20px;
|
|
36
|
+
column-gap: 20px;
|
|
37
|
+
grid-template-columns: 1fr 1fr;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
@media all and (-ms-high-contrast:none) {
|
|
42
|
+
.link-list {
|
|
43
|
+
display: -ms-grid;
|
|
44
|
+
-ms-grid-columns: 1fr 1fr;
|
|
45
|
+
-ms-grid-rows: 1fr 1fr;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
.link-item {
|
|
50
|
+
display: block;
|
|
51
|
+
padding: 20px 30px 20px 15px;
|
|
52
|
+
border: 1px solid #00000010;
|
|
53
|
+
border-radius: 5px;
|
|
54
|
+
transition: background 150ms ease-out, border 150ms ease-out, transform 150ms ease-out;
|
|
55
|
+
color: #333333;
|
|
56
|
+
display: flex;
|
|
57
|
+
align-items: flex-start;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
.link-item:hover {
|
|
61
|
+
border-color: #1EA7FD50;
|
|
62
|
+
transform: translate3d(0, -3px, 0);
|
|
63
|
+
box-shadow: rgba(0, 0, 0, 0.08) 0 3px 10px 0;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
.link-item:active {
|
|
67
|
+
border-color: #1EA7FD;
|
|
68
|
+
transform: translate3d(0, 0, 0);
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
.link-item strong {
|
|
72
|
+
font-weight: 700;
|
|
73
|
+
display: block;
|
|
74
|
+
margin-bottom: 2px;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
.link-item img {
|
|
78
|
+
height: 40px;
|
|
79
|
+
width: 40px;
|
|
80
|
+
margin-right: 15px;
|
|
81
|
+
flex: none;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
.link-item span {
|
|
85
|
+
font-size: 14px;
|
|
86
|
+
line-height: 20px;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
.tip {
|
|
90
|
+
display: inline-block;
|
|
91
|
+
border-radius: 1em;
|
|
92
|
+
font-size: 11px;
|
|
93
|
+
line-height: 12px;
|
|
94
|
+
font-weight: 700;
|
|
95
|
+
background: #E7FDD8;
|
|
96
|
+
color: #66BF3C;
|
|
97
|
+
padding: 4px 12px;
|
|
98
|
+
margin-right: 10px;
|
|
99
|
+
vertical-align: top;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
.tip-wrapper {
|
|
103
|
+
font-size: 13px;
|
|
104
|
+
line-height: 20px;
|
|
105
|
+
margin-top: 40px;
|
|
106
|
+
margin-bottom: 40px;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
.tip-wrapper code {
|
|
110
|
+
font-size: 12px;
|
|
111
|
+
display: inline-block;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
|
|
115
|
+
`}</style>
|
|
116
|
+
|
|
117
|
+
# Welcome to Storybook
|
|
118
|
+
|
|
119
|
+
Storybook helps you build UI components in isolation from your app's business logic, data, and context.
|
|
120
|
+
That makes it easy to develop hard-to-reach states. Save these UI states as **stories** to revisit during development, testing, or QA.
|
|
121
|
+
|
|
122
|
+
Browse example stories now by navigating to them in the sidebar.
|
|
123
|
+
View their code in the `src/stories` directory to learn how they work.
|
|
124
|
+
We recommend building UIs with a [**component-driven**](https://componentdriven.org) process starting with atomic components and ending with pages.
|
|
125
|
+
|
|
126
|
+
<div className="subheading">Configure</div>
|
|
127
|
+
|
|
128
|
+
<div className="link-list">
|
|
129
|
+
<a
|
|
130
|
+
className="link-item"
|
|
131
|
+
href="https://storybook.js.org/docs/react/addons/addon-types"
|
|
132
|
+
target="_blank"
|
|
133
|
+
>
|
|
134
|
+
<img src={Plugin} alt="plugin" />
|
|
135
|
+
<span>
|
|
136
|
+
<strong>Presets for popular tools</strong>
|
|
137
|
+
Easy setup for TypeScript, SCSS and more.
|
|
138
|
+
</span>
|
|
139
|
+
</a>
|
|
140
|
+
<a
|
|
141
|
+
className="link-item"
|
|
142
|
+
href="https://storybook.js.org/docs/react/configure/webpack"
|
|
143
|
+
target="_blank"
|
|
144
|
+
>
|
|
145
|
+
<img src={StackAlt} alt="Build" />
|
|
146
|
+
<span>
|
|
147
|
+
<strong>Build configuration</strong>
|
|
148
|
+
How to customize webpack and Babel
|
|
149
|
+
</span>
|
|
150
|
+
</a>
|
|
151
|
+
<a
|
|
152
|
+
className="link-item"
|
|
153
|
+
href="https://storybook.js.org/docs/react/configure/styling-and-css"
|
|
154
|
+
target="_blank"
|
|
155
|
+
>
|
|
156
|
+
<img src={Colors} alt="colors" />
|
|
157
|
+
<span>
|
|
158
|
+
<strong>Styling</strong>
|
|
159
|
+
How to load and configure CSS libraries
|
|
160
|
+
</span>
|
|
161
|
+
</a>
|
|
162
|
+
<a
|
|
163
|
+
className="link-item"
|
|
164
|
+
href="https://storybook.js.org/docs/react/get-started/setup#configure-storybook-for-your-stack"
|
|
165
|
+
target="_blank"
|
|
166
|
+
>
|
|
167
|
+
<img src={Flow} alt="flow" />
|
|
168
|
+
<span>
|
|
169
|
+
<strong>Data</strong>
|
|
170
|
+
Providers and mocking for data libraries
|
|
171
|
+
</span>
|
|
172
|
+
</a>
|
|
173
|
+
</div>
|
|
174
|
+
|
|
175
|
+
<div className="subheading">Learn</div>
|
|
176
|
+
|
|
177
|
+
<div className="link-list">
|
|
178
|
+
<a className="link-item" href="https://storybook.js.org/docs" target="_blank">
|
|
179
|
+
<img src={Repo} alt="repo" />
|
|
180
|
+
<span>
|
|
181
|
+
<strong>Storybook documentation</strong>
|
|
182
|
+
Configure, customize, and extend
|
|
183
|
+
</span>
|
|
184
|
+
</a>
|
|
185
|
+
<a className="link-item" href="https://storybook.js.org/tutorials/" target="_blank">
|
|
186
|
+
<img src={Direction} alt="direction" />
|
|
187
|
+
<span>
|
|
188
|
+
<strong>In-depth guides</strong>
|
|
189
|
+
Best practices from leading teams
|
|
190
|
+
</span>
|
|
191
|
+
</a>
|
|
192
|
+
<a className="link-item" href="https://github.com/storybookjs/storybook" target="_blank">
|
|
193
|
+
<img src={Code} alt="code" />
|
|
194
|
+
<span>
|
|
195
|
+
<strong>GitHub project</strong>
|
|
196
|
+
View the source and add issues
|
|
197
|
+
</span>
|
|
198
|
+
</a>
|
|
199
|
+
<a className="link-item" href="https://discord.gg/storybook" target="_blank">
|
|
200
|
+
<img src={Comments} alt="comments" />
|
|
201
|
+
<span>
|
|
202
|
+
<strong>Discord chat</strong>
|
|
203
|
+
Chat with maintainers and the community
|
|
204
|
+
</span>
|
|
205
|
+
</a>
|
|
206
|
+
</div>
|
|
207
|
+
|
|
208
|
+
<div className="tip-wrapper">
|
|
209
|
+
<span className="tip">Tip</span>Edit the Markdown in{' '}
|
|
210
|
+
<code>src/stories/Introduction.stories.mdx</code>
|
|
211
|
+
</div>
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { ComponentStory, ComponentMeta } from '@storybook/react';
|
|
3
|
+
import { within, userEvent } from '@storybook/testing-library';
|
|
4
|
+
import { Page } from './Page';
|
|
5
|
+
|
|
6
|
+
export default {
|
|
7
|
+
title: 'Example/Page',
|
|
8
|
+
component: Page,
|
|
9
|
+
parameters: {
|
|
10
|
+
// More on Story layout: https://storybook.js.org/docs/react/configure/story-layout
|
|
11
|
+
layout: 'fullscreen',
|
|
12
|
+
},
|
|
13
|
+
} as ComponentMeta<typeof Page>;
|
|
14
|
+
|
|
15
|
+
const Template: ComponentStory<typeof Page> = (args) => <Page {...args} />;
|
|
16
|
+
|
|
17
|
+
export const LoggedOut = Template.bind({});
|
|
18
|
+
|
|
19
|
+
export const LoggedIn = Template.bind({});
|
|
20
|
+
|
|
21
|
+
// More on interaction testing: https://storybook.js.org/docs/react/writing-tests/interaction-testing
|
|
22
|
+
LoggedIn.play = async ({ canvasElement }) => {
|
|
23
|
+
const canvas = within(canvasElement);
|
|
24
|
+
const loginButton = await canvas.getByRole('button', { name: /Log in/i });
|
|
25
|
+
await userEvent.click(loginButton);
|
|
26
|
+
};
|