Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

plasma-infra: Migrate to storybook 7 [Web] #850

Merged
merged 44 commits into from
Nov 15, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
44 commits
Select commit Hold shift + click to select a range
9611d4f
chore(web): migrate to CSF 3 [AudioPlayer]
Yakutoc Nov 14, 2023
ec80407
chore(web): migrate to CSF 3 [Button]
Yakutoc Nov 14, 2023
43f0752
chore(web): migrate to CSF 3 [Badge]
Yakutoc Nov 14, 2023
88a5ff7
chore(web): migrate to CSF 3 [Cell]
Yakutoc Nov 14, 2023
663ed24
chore(web): migrate to CSF 3 [Card]
Yakutoc Nov 14, 2023
4042373
chore(web): migrate to CSF 3 [Carousel]
Yakutoc Nov 14, 2023
b879245
chore(web): migrate to CSF 3 [Calendar]
Yakutoc Nov 15, 2023
28892dc
chore(web): migrate to CSF 3 [Checkbox]
Yakutoc Nov 15, 2023
b7e94f0
chore(web): migrate to CSF 3 [Dropdown]
Yakutoc Nov 15, 2023
289134f
chore(web): migrate to CSF 3 [Editable]
Yakutoc Nov 15, 2023
775ccb0
chore(web): migrate to CSF 3 [ElasticGrid]
Yakutoc Nov 15, 2023
a7cd667
chore(web): migrate to CSF 3 [Grid]
Yakutoc Nov 15, 2023
2731df2
chore(web): migrate to CSF 3 [Image]
Yakutoc Nov 15, 2023
3634495
chore(web): migrate to CSF 3 [Link]
Yakutoc Nov 15, 2023
4e1513e
chore(web): migrate to CSF 3 [Modal]
Yakutoc Nov 15, 2023
72ec61c
chore(web): migrate to CSF 3 [ModalBase]
Yakutoc Nov 15, 2023
5ed4633
chore(web): migrate to CSF 3 [Notification]
Yakutoc Nov 15, 2023
da5127b
chore(web): migrate to CSF 3 [PaginationDots]
Yakutoc Nov 15, 2023
f1741b6
chore(web): migrate to CSF 3 [Popover]
Yakutoc Nov 15, 2023
9ab5faf
chore(web): migrate to CSF 3 [PopupBase]
Yakutoc Nov 15, 2023
cc297a5
chore(web): migrate to CSF 3 [PreviewGallery]
Yakutoc Nov 15, 2023
5713786
chore(web): migrate to CSF 3 [Price]
Yakutoc Nov 15, 2023
d394ff3
chore(web): migrate to CSF 3 [Progress]
Yakutoc Nov 15, 2023
640109f
chore(web): migrate to CSF 3 [Radiobox]
Yakutoc Nov 15, 2023
14042e3
chore(web): migrate to CSF 3 [Select]
Yakutoc Nov 15, 2023
84ed815
chore(web): migrate to CSF 3 [Skeleton]
Yakutoc Nov 15, 2023
f6e9f1b
chore(web): migrate to CSF 3 [Slider]
Yakutoc Nov 15, 2023
373b458
chore(web): migrate to CSF 3 [Spinner]
Yakutoc Nov 15, 2023
ae678a9
chore(web): migrate to CSF 3 [Switch]
Yakutoc Nov 15, 2023
5733379
chore(web): migrate to CSF 3 [Tabs]
Yakutoc Nov 15, 2023
74f3cf8
chore(web): migrate to CSF 3 [TextArea]
Yakutoc Nov 15, 2023
dcefbf6
chore(web): migrate to CSF 3 [TextField]
Yakutoc Nov 15, 2023
9b87d32
chore(web): migrate to CSF 3 [Toast]
Yakutoc Nov 15, 2023
77253b2
chore(web): migrate to CSF 3 [Tooltip]
Yakutoc Nov 15, 2023
dcd79dd
chore(web): migrate to CSF 3 [Upload]
Yakutoc Nov 15, 2023
3849f3f
chore(web): migrate to CSF 3 [UploadAudio]
Yakutoc Nov 15, 2023
a0264ac
chore(web): migrate to CSF 3 [UploadVisual]
Yakutoc Nov 15, 2023
4b4c17d
chore(web): migrate to CSF 3 [Colors]
Yakutoc Nov 15, 2023
ac19a90
chore(web): migrate to CSF 3 [Typography]
Yakutoc Nov 15, 2023
14181c2
chore(web): bump storybook to latest(7.5.3)
Yakutoc Nov 15, 2023
95cf68d
chore(web): migrate "Preview.ts" to storybook@latest
Yakutoc Nov 15, 2023
ba3a0c9
chore(web): add decorators: Theme, Toast, Docs
Yakutoc Nov 15, 2023
18c03e8
chore(web): migrate "Main.ts" to storybook@latest
Yakutoc Nov 15, 2023
78c4737
docs(web): fix typo
Yakutoc Nov 15, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
93 changes: 93 additions & 0 deletions packages/plasma-web/.storybook/decoratorThemes.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
import React from 'react';
import type { Decorator } from '@storybook/react';
import { createGlobalStyle } from 'styled-components';
import {
light as b2bLight,
dark as b2bDark,
b2b as b2bTypo,
link,
linkHover,
linkActive,
surfaceSolid01,
} from '@salutejs/plasma-tokens-b2b';
import { light as b2cLight, dark as b2cDark } from '@salutejs/plasma-tokens-b2c';
import { light as legacyLight, dark as legacyDark } from '@salutejs/plasma-tokens-web';
import { standard as standardTypo, compatible as compatibleTypo } from '@salutejs/plasma-typo';

/* stylelint-disable */
const DocumentStyle = createGlobalStyle`
html:root {
min-height: 100vh;
background-color: ${surfaceSolid01};
}
a {
color: ${link};
text-decoration: underline;

&:hover {
color: ${linkHover};
}
&:active {
color: ${linkActive};
}
}
`;
/* stylelint-enable */

const OldTypo = createGlobalStyle(b2bTypo);
const TypoStyle = createGlobalStyle(standardTypo);
const CompatibleTypoStyle = createGlobalStyle(compatibleTypo);

const B2B_LIGHT_THEME = 'b2b:light';
const B2B_DARK_THEME = 'b2b:dark';
const B2C_LIGHT_THEME = 'b2c:light';
const B2C_DARK_THEME = 'b2c:dark';
const LEGACY_LIGHT_THEME = 'light (legacy)';
const LEGACY_DARK_THEME = 'dark (legacy)';

const themes = {
[B2B_LIGHT_THEME]: createGlobalStyle(b2bLight),
[B2B_DARK_THEME]: createGlobalStyle(b2bDark),
[B2C_LIGHT_THEME]: createGlobalStyle(b2cLight),
[B2C_DARK_THEME]: createGlobalStyle(b2cDark),
[LEGACY_LIGHT_THEME]: createGlobalStyle(legacyLight),
[LEGACY_DARK_THEME]: createGlobalStyle(legacyDark),
};

export const themesList = [
B2B_LIGHT_THEME,
B2B_DARK_THEME,
B2C_LIGHT_THEME,
B2C_DARK_THEME,
LEGACY_LIGHT_THEME,
LEGACY_DARK_THEME,
];

export const withTheme: Decorator = (Story, context) => {
let theme = context.globals.theme;

if (theme === 'light') {
theme = LEGACY_LIGHT_THEME;
} else if (theme === 'dark') {
theme = LEGACY_DARK_THEME;
}

const Theme = themes[theme];

return (
<>
{context.globals.typoVersion === 'standard' ? (
<>
<TypoStyle />
<CompatibleTypoStyle />
</>
) : (
<OldTypo />
)}

<Theme />
<DocumentStyle />
<Story {...context} />
</>
);
};
9 changes: 9 additions & 0 deletions packages/plasma-web/.storybook/decoratorToast.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import React from 'react';
import type { Decorator } from '@storybook/react';
import { ToastProvider } from '@salutejs/plasma-core';

export const withToast: Decorator = (Story) => (
<ToastProvider>
<Story />
</ToastProvider>
);
11 changes: 11 additions & 0 deletions packages/plasma-web/.storybook/docsPage.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { ArgsTable, Description, Primary, PRIMARY_STORY, Subtitle, Title } from '@storybook/addon-docs';

export const docsPage = () => (
<>
<Title />
<Subtitle />
<Description />
<Primary />
<ArgsTable story={PRIMARY_STORY} />
</>
);
22 changes: 0 additions & 22 deletions packages/plasma-web/.storybook/main.js

This file was deleted.

32 changes: 32 additions & 0 deletions packages/plasma-web/.storybook/main.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import { mergeConfig } from 'vite';
import type { StorybookConfig } from '@storybook/react-vite';

const config: StorybookConfig = {
staticDirs: ['public'],
stories: ['../src/**/*.stories.tsx', '../README.stories.mdx'],
addons: ['@storybook/addon-essentials'],
framework: {
name: '@storybook/react-vite',
options: {},
},
core: {
disableTelemetry: true,
},
docs: {
autodocs: true,
defaultName: 'Docs',
},
async viteFinal(config) {
return mergeConfig(config, {
base: '',
resolve: {
dedupe: ['react', 'react-dom', 'styled-components'],
},
build: {
sourcemap: false,
},
});
},
};

export default config;
180 changes: 0 additions & 180 deletions packages/plasma-web/.storybook/preview.jsx

This file was deleted.

Loading
Loading