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

Upgrade to Storybook 7 #110

Open
wants to merge 20 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
5 changes: 1 addition & 4 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -114,16 +114,13 @@ dist
# Local Netlify folder
.netlify

# TypeScript definition files
*.d.ts

# Style Dictionary related, generated files
/.storybook/IconSprite.js
/.storybook/icons.html
/.storybook/tokens.css
/.storybook/tokens.js
/.storybook/icons.svg

/.storybook/preview.jsx
/src/_token-map.scss
/src/icon-sprite.html
/src/tokens.css
Expand Down
47 changes: 0 additions & 47 deletions .storybook/main.js

This file was deleted.

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

const config: StorybookConfig = {
stories: [
"../docs/**/*.mdx",
"../src/**/*.mdx",
"../src/**/*.stories.@(js|jsx|ts|tsx)",
],
addons: [
"@storybook/addon-essentials",
"@storybook/addon-a11y",
"@kickstartds/storybook-addon-component-tokens",
"@whitespace/storybook-addon-html",
"@kickstartds/storybook-addon-jsonschema",
{
name: "storybook-design-token",
options: {
designTokenGlob: ".storybook/*.{css,svg}",
},
},
],
staticDirs: ["../static"],
framework: {
name: "@storybook/react-vite",
options: {},
},
docs: {
autodocs: true,
},
};

export default config;
87 changes: 0 additions & 87 deletions .storybook/preview.js

This file was deleted.

76 changes: 76 additions & 0 deletions .storybook/preview.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
import { PropsWithChildren } from "react";
import { actions } from "@storybook/addon-actions";
import { Preview } from "@storybook/react";
import { DocsContainer, DocsContainerProps } from "@storybook/addon-docs";
import { Decorator } from "@storybook/react";
import { defaultDecorateStory } from "@storybook/preview-api";
// @see https://github.com/aFarkas/lazysizes/tree/gh-pages/plugins/attrchange
import "lazysizes/plugins/attrchange/ls.attrchange";
import { unpackDecorator } from "@kickstartds/core/lib/storybook";

import "@kickstartds/base/lib/global/base.js";
import "@kickstartds/base/lib/global/base.css";
import "../src/index.js";
import "../static/index.css";
import { IconSprite } from "../src/icon-sprite/IconSpriteComponent";
import Providers from "../src/Providers";
import { LinkProvider } from "../docs/LinkProvider";

const myActions = actions("radio");
window._ks.radio.on("*", myActions.radio);

const providerDecorator: Decorator = (Story, context) => (
<Providers>{Story(context)}</Providers>
);

const preview: Preview = {
parameters: {
actions: { argTypesRegex: "^on[A-Z].*" },
controls: {
matchers: {
color: /(background|color)$/i,
date: /Date$/,
},
},
html: {
prettier: {
tabWidth: 4,
},
decorator: (Story, context) =>
defaultDecorateStory(Story, [unpackDecorator, providerDecorator])(
context
),
},
options: {
storySort: {
order: ["Welcome", "Design Token", "*", "Custom", "Recipes", "Pages"],
method: "alphabetical",
},
},
designToken: {
disable: true,
},
docs: {
container: (props: PropsWithChildren<DocsContainerProps>) => (
<LinkProvider>
<Providers>
<IconSprite />
<DocsContainer {...props} />
</Providers>
</LinkProvider>
),
},
},
decorators: [
unpackDecorator,
providerDecorator,
(Story) => (
<>
<IconSprite />
<Story />
</>
),
],
};

export default preview;
6 changes: 4 additions & 2 deletions docs/Welcome.story.mdx → docs/Welcome.mdx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Meta } from "@storybook/addon-docs";
import { Meta, Unstyled } from "@storybook/blocks";
import { Welcome } from "./WelcomePage";

<Meta
Expand All @@ -8,4 +8,6 @@ import { Welcome } from "./WelcomePage";
}}
/>

<Welcome />
<Unstyled>
<Welcome />
</Unstyled>
10 changes: 2 additions & 8 deletions docs/WelcomePage.jsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
import { Button } from "@kickstartds/base/lib/button";
import { Picture } from "@kickstartds/base/lib/picture";
import { Section } from "@kickstartds/base/lib/section";
import { TeaserBox } from "@kickstartds/base/lib/teaser-box";
import { ContentBox } from "@kickstartds/base/lib/content-box";
import { Headline } from "@kickstartds/base/lib/headline";
import { Visual } from "@kickstartds/content/lib/visual";
import { Inline } from "@bedrock-layout/primitives";

export const Welcome = () => (
<>
Expand Down Expand Up @@ -60,7 +56,6 @@ export const Welcome = () => (
align: "center",
content: "Getting started with ...",
level: "h2",
pageHeader: false,
}}
className="col-four"
mode="tile"
Expand Down Expand Up @@ -121,6 +116,7 @@ export const Welcome = () => (
}}
/>
</Section>

<Section
className="col-four"
spaceAfter="small"
Expand Down Expand Up @@ -151,8 +147,8 @@ export const Welcome = () => (
variant: "solid",
}}
/>

</Section>

<Section
className="col-four"
spaceAfter="small"
Expand Down Expand Up @@ -191,14 +187,12 @@ export const Welcome = () => (
align: "left",
content: "Next-gen UI-development toolkit",
level: "h2",
pageHeader: false,
subheadline: "and framework for Design System creation",
}}
mode="list"
spaceAfter="small"
spaceBefore="small"
width="max"
deko="true"
pattern="1"
ks-inverted="true"
>
Expand Down
Loading