Skip to content

Commit ebdfb52

Browse files
docs: upgrade storybook to 6.1.x. HVUIKIT-5637
1 parent 426c4e6 commit ebdfb52

File tree

126 files changed

+7247
-10413
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

126 files changed

+7247
-10413
lines changed

.storybook/blocks/ArgsTable.js

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
import React, { useContext } from "react";
2+
import { ArgsTableError } from "@storybook/components";
3+
import { DocsContext, CURRENT_SELECTION, PRIMARY_STORY } from "@storybook/addon-docs/blocks";
4+
import { StoryTable } from "@storybook/addon-docs/dist/blocks/ArgsTable";
5+
6+
const isShortcut = (value) => {
7+
return value && [CURRENT_SELECTION, PRIMARY_STORY].includes(value);
8+
};
9+
10+
export const getComponent = (props = {}, context) => {
11+
const { of } = props;
12+
const { story } = props;
13+
const { parameters = {} } = context;
14+
const { component } = parameters;
15+
if (isShortcut(of) || isShortcut(story)) {
16+
return component.Naked || component || null;
17+
}
18+
if (!of) {
19+
throw new Error(ArgsTableError.NO_COMPONENT);
20+
}
21+
return of;
22+
};
23+
24+
export const ArgsTable = (props) => {
25+
const context = useContext(DocsContext);
26+
const { parameters: { subcomponents } = {} } = context;
27+
const { include, exclude, components } = props;
28+
const { story } = props;
29+
30+
const main = getComponent(props, context);
31+
32+
if (story) {
33+
return <StoryTable {...props} component={main} subcomponents={subcomponents} />;
34+
}
35+
};
36+
37+
ArgsTable.defaultProps = {
38+
of: ".",
39+
};

.storybook/blocks/Deprecated.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
import React, { useContext } from "react";
22
import { Subtitle } from "@storybook/components";
33
import { DocsContext } from "@storybook/addon-docs/blocks";
4-
import { getStoredTheme, getStorybookTheme } from "../themes";
4+
import { getTheme } from "../theme";
55

66
export const Deprecated = () => {
77
const context = useContext(DocsContext);
88
const { compNameToUse, deprecated } = context.parameters;
9-
const theme = getStorybookTheme(getStoredTheme());
9+
const theme = getTheme();
1010

1111
return deprecated ? (
1212
<Subtitle style={{ color: theme.hv.palette.semantic.sema4 }}>

.storybook/blocks/DocsContainer.js

Lines changed: 9 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,21 @@
1-
// Copied from https://github.com/storybookjs/storybook/blob/v5.3.18/addons/docs/src/blocks/DocsContainer.tsx
2-
// to update storybook theme at runtime and apply stylesheet overrides
3-
4-
import * as React from "react";
5-
1+
import React from "react";
62
import { DocsContainer } from "@storybook/addon-docs/blocks";
73
import { Global } from "@storybook/theming";
8-
9-
import HvProvider from "@hv/uikit-react-core/dist/Provider";
10-
11-
import { getStoredTheme, getStorybookTheme, getDocsStylesOverrides } from "../themes";
4+
import { getTheme } from "../theme";
5+
import { getDocsStyles } from "../theme/styles/docs";
126

137
export default ({ context, children }) => {
14-
const themeName = getStoredTheme();
15-
const theme = getStorybookTheme(themeName);
8+
const theme = getTheme();
169

17-
const docsContext = { ...context };
18-
docsContext.parameters = { ...context.parameters };
19-
docsContext.parameters.options = {
20-
...context.parameters.options,
21-
theme: theme,
10+
const docsContext = {
11+
...context,
12+
parameters: { ...context.parameters, docs: { ...context.parameters.docs, theme } },
2213
};
2314

2415
return (
2516
<>
26-
<Global styles={getDocsStylesOverrides(theme)} />
27-
28-
<DocsContainer context={docsContext}>
29-
<HvProvider uiKitTheme={themeName}>{children}</HvProvider>
30-
</DocsContainer>
17+
<Global styles={getDocsStyles(theme)} />
18+
<DocsContainer context={docsContext}>{children}</DocsContainer>
3119
</>
3220
);
3321
};

.storybook/blocks/DocsPage.js

Lines changed: 22 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,25 @@
1-
// Copied from https://github.com/storybookjs/storybook/blob/v5.3.18/addons/docs/src/blocks/DocsPage.tsx
2-
// to add a Usage block, customize the stories title and replace some blocks with our own versions
3-
41
import React from "react";
5-
import { Title, Subtitle, Description, Primary } from "@storybook/addon-docs/blocks";
6-
7-
import { Usage } from "./Usage";
8-
import { Props } from "./Props";
9-
import { Stories } from "./Stories";
10-
import { Deprecated } from "./Deprecated";
2+
import {
3+
Title,
4+
Subtitle,
5+
Description,
6+
Primary,
7+
Stories,
8+
PRIMARY_STORY,
9+
} from "@storybook/addon-docs/blocks";
1110
import { MaturityStatus } from "./MaturityStatus";
11+
import { Usage } from "./Usage";
12+
import { ArgsTable } from "./ArgsTable";
1213

13-
export default ({
14-
titleSlot,
15-
maturityStatusSlot,
16-
subtitleSlot,
17-
descriptionSlot,
18-
primarySlot,
19-
usageSlot,
20-
propsSlot,
21-
storiesSlot,
22-
}) => {
23-
return (
24-
<>
25-
<Title slot={titleSlot} />
26-
<MaturityStatus slot={maturityStatusSlot} />
27-
<Subtitle slot={subtitleSlot} />
28-
<Description slot={descriptionSlot} />
29-
<Usage code={usageSlot} />
30-
<Deprecated />
31-
<Primary slot={primarySlot} />
32-
<Props slot={propsSlot} />
33-
<Stories title="Examples" slot={storiesSlot} />
34-
</>
35-
);
36-
};
14+
export default ({}) => (
15+
<>
16+
<Title />
17+
<MaturityStatus />
18+
<Subtitle />
19+
<Description />
20+
<Usage />
21+
<Primary />
22+
<ArgsTable story={PRIMARY_STORY} />
23+
<Stories />
24+
</>
25+
);

.storybook/blocks/Props.js

Lines changed: 0 additions & 108 deletions
This file was deleted.

.storybook/blocks/Stories.js

Lines changed: 0 additions & 41 deletions
This file was deleted.

0 commit comments

Comments
 (0)