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

feat: storybook update #3036

Merged
merged 4 commits into from
Dec 29, 2021
Merged
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: 4 additions & 1 deletion .eslintrc.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
{
"extends": "eslint:recommended",
"extends": [
"eslint:recommended",
"plugin:storybook/recommended"
],
"parser": "babel-eslint",
"env": {
"node": true,
Expand Down
8 changes: 6 additions & 2 deletions .storybook/custom/components/DocsPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,14 +60,14 @@ const DocsPage = () => {
});
previousDirectionality.current = directionalityState;
}

if (!previousTheme.current || previousTheme.current !== themeState) {
changeDocumentTheme(themeState, context?.parameters?.components || [])
}
}, [themeState, directionalityState]);

// do not display disabled stories (dev only)
const stories = context.storyStore?.getStoriesForKind(context.kind)?.filter((s) => !s.parameters?.docs?.disable);
const stories = context.componentStories().filter(story => story.kind === context.kind && !story.parameters?.docs?.disable);

const renderInfoLabels = (tags) => {
let infoLabels = []
Expand All @@ -87,6 +87,7 @@ const DocsPage = () => {
return (
<>
<Header onThemeChange={(e) => setThemeState(e.target.value)} onDirectionalityChange={(e) => setDirectionalityState(e.target.value)} />

{/* wrapping intro content in the sb-docs-intro class for appropriate text color in all themes */}
<div className="sb-docs-intro">
<Title />
Expand All @@ -95,12 +96,15 @@ const DocsPage = () => {
{renderInfoLabels(context?.parameters?.tags)}
{context?.parameters?.description && <Description desc={context?.parameters?.description} />}
</div>

<Heading>Examples</Heading>

{stories.map((story) => story && <DocsStory
key={story.id}
{...story}
expanded
withToolbar />)}

<Community />
<Footer />
</>
Expand Down
6 changes: 5 additions & 1 deletion .storybook/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ module.exports = {
test: /\.stories\.js?$/,
use: [{ loader: 'story-description-loader' }],
});

config.module.rules.push({
test: /\.css?$/,
use: [
Expand All @@ -46,8 +47,9 @@ module.exports = {
injectType: 'lazyStyleTag'
}
}
]
]
});

config.plugins.push({
// Custom plugin to add scss files to webpack watcher
apply: (compiler) => {
Expand All @@ -57,12 +59,14 @@ module.exports = {
dot: true,
absolute: true,
});

files.forEach((file) => {
comp.fileDependencies.add(path.resolve(file));
});
});
},
});

config.plugins.push({
// Custom plugin to rebuild css styles for each scss change
apply: (compiler) => {
Expand Down
10 changes: 10 additions & 0 deletions .storybook/manager.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { addons } from '@storybook/addons';

import fundamentals from './custom/fundamentals';

addons.setConfig({
sidebar: {
showRoots: false
},
theme: fundamentals
});
12 changes: 4 additions & 8 deletions .storybook/preview.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,12 @@
import fundamentals from './custom/fundamentals';
import { withCssResources } from "@storybook/addon-cssresources";
import { withThemeProvider } from './custom/themeProvider';
import { DocsContainer } from '@storybook/addon-docs';
import DocsPage from './custom/components/DocsPage';
import { makeDecorator } from '@storybook/addons';
import prettify from 'pretty';

import { withThemeProvider } from './custom/themeProvider';
import DocsPage from './custom/components/DocsPage';
import fundamentals from './custom/fundamentals';

export const parameters = {
options: {
showRoots: true,
theme: fundamentals
},
cssresources: [
{
id: "normalize",
Expand Down
Loading