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: Upgrade Storybook to v6.1.3 #897

Merged
merged 40 commits into from
Nov 24, 2020
Merged
Show file tree
Hide file tree
Changes from 38 commits
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
31b9050
fix(badge): Remove trailing slash from count badge story
anicholls Oct 28, 2020
7c1aa63
refactor: Remove hierarchy separator from stories
anicholls Oct 28, 2020
50b101f
fix: Add new line between JSX tags for welcome docs
anicholls Nov 3, 2020
602a5b7
refactor: Rename card mdx story to have the correct suffix
anicholls Nov 3, 2020
744d01c
refactor: Remove hierarchy separator from stories
anicholls Oct 28, 2020
dd1e1f9
chore: Upgrade storybook
anicholls Oct 28, 2020
c11128d
chore: Update card story imports to the new names
anicholls Oct 28, 2020
b58d452
refactor: Adopt new storybook config format
anicholls Oct 29, 2020
663e506
chore: Rename doc stories now that mdx requires .stories suffix
anicholls Nov 3, 2020
8fc91e6
fix: Tweak how static members are defined
anicholls Nov 3, 2020
b10a11c
build: Add babel config back into storybook
anicholls Nov 3, 2020
e80d07d
fix: Resolve type export warnings
anicholls Nov 3, 2020
7db881d
refactor: Rename card mdx story to have the correct suffix
anicholls Nov 3, 2020
fc885a0
fix: Resolve browserslist warning
anicholls Nov 3, 2020
a6cfb40
chore: Upgrade to storybook@6.0.28
anicholls Nov 3, 2020
78752a1
feat: Re-add travis filter for storybook webpack config
anicholls Nov 3, 2020
71f7c97
build: Generate stories.json file on master merge
anicholls Nov 3, 2020
47e8342
build: Add babel config to make IE11 happy
anicholls Nov 4, 2020
13657bd
build: Remove unecessary babel config (dupes)
anicholls Nov 12, 2020
f836015
fix: Also convert mdx github links
anicholls Nov 12, 2020
3cd5a29
fix: Upgrade cypress-storybook (causing IE compat issue)
anicholls Nov 12, 2020
ccdeaad
chore: Update publish-canary.js
lychyi Nov 12, 2020
220c4f7
refactor: Update stories to remove files referencing the same "kind"
anicholls Nov 13, 2020
b84d3e4
fix: Upgrade cypress-storybook for IE Compat
anicholls Nov 13, 2020
a46e440
fix: Use generics instead of overloading to prevent TS error
anicholls Nov 13, 2020
8057f6e
ci: Try to fix cache warning
anicholls Nov 18, 2020
9c6d80f
fix: Enforce story preview body margin for snapshot review
anicholls Nov 18, 2020
bada390
Revert "refactor: Update stories to remove files referencing the same…
anicholls Nov 18, 2020
e3117ce
fix: Update withSnapshotsEnabled helper
anicholls Nov 18, 2020
399a0ec
fix: Update stories to prevent duplicate kind warning
anicholls Nov 18, 2020
3454c12
fix: Fix spacing differences in preview body
anicholls Nov 18, 2020
ce80843
chore: Remove unnecessary comments
anicholls Nov 20, 2020
4a50441
chore: Revert change to cypress dep after rebase error
anicholls Nov 20, 2020
70a1357
fix: Fix duplicate kind warning without putting theme stories in folder
anicholls Nov 23, 2020
2d1ccc0
chore: Upgrade storybook to 6.1.3
anicholls Nov 23, 2020
b07029b
docs: Update documentation using storybook APIs
anicholls Nov 23, 2020
73e70d8
Merge branch 'master' into storybook-upgrade
anicholls Nov 23, 2020
86cc97d
fix: De-dupe yarn.lock to fix popper type error
anicholls Nov 24, 2020
eff6e78
chore: Rename story file to make contents clearer
anicholls Nov 24, 2020
9205bf2
fix: Remove max-buffer from canary script added in merge
anicholls Nov 24, 2020
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
10 changes: 0 additions & 10 deletions .storybook/addons.js

This file was deleted.

81 changes: 0 additions & 81 deletions .storybook/config.js

This file was deleted.

66 changes: 66 additions & 0 deletions .storybook/main.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
const path = require('path');
const DocgenPlugin = require('./docgen-plugin');

const modulesPath = path.resolve(__dirname, '../modules');

module.exports = {
stories: [
'./stories/*.stories.mdx',
'../modules/**/*.stories.mdx',
'../modules/**/stories*.@(js|jsx|ts|tsx)',
],
addons: [
{
name: '@storybook/addon-essentials',
options: {
actions: false, // Disabled because actions is SLOW
},
},
'storybook-readme',
'@storybook/addon-knobs',
'@storybook/addon-storysource',
'@storybook/preset-scss',
],
webpackFinal: async config => {
// Convert mdx links to point to github
config.module.rules.push({
test: /\.mdx?$/,
include: [path.resolve(__dirname, '..')],
exclude: [/node_modules/],
use: [
{
loader: path.resolve(__dirname, 'webpack-loader-redirect-mdx-to-github'),
},
],
});

// Load the source code of story files to display in docs.
config.module.rules.push({
test: /stories.*\.tsx?$/,
include: [modulesPath],
loaders: [
{
loader: require.resolve('@storybook/source-loader'),
options: {parser: 'typescript'},
},
],
enforce: 'pre',
});

config.plugins.push(new DocgenPlugin());

// Remove progress updates to reduce log lines in Travis
// See: https://github.com/storybookjs/storybook/issues/2029
if (process.env.TRAVIS) {
config.plugins = config.plugins.filter(
plugin => plugin.constructor.name !== 'ProgressPlugin'
);
}

return config;
},
babel: async options => ({
...options,
plugins: [...options.plugins, '@babel/plugin-transform-modules-commonjs'],
}),
};
6 changes: 6 additions & 0 deletions .storybook/manager.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import {addons} from '@storybook/addons';
import theme from './theme';

addons.setConfig({
theme,
});
4 changes: 2 additions & 2 deletions .storybook/preview-head.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
</script>
<style type="text/css">
body {
margin: 40px;
padding: 0;
margin: 40px !important;
padding: 0 !important;
font-family: sans-serif;
}

Expand Down
48 changes: 48 additions & 0 deletions .storybook/preview.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
import {DocsPage, DocsContainer} from '@storybook/addon-docs/blocks';
import 'cypress-storybook/react';

import {CanvasProviderDecorator, FontsDecorator} from '../utils/storybook';
import theme from './theme';

/** If the string contains a phrase, prefix it. This is useful for making ordering sections */
const prefix = (phrase, prefix) => (/** @type {string} */ value) => {
const index = value.indexOf(phrase);
return index > -1 ? value.substr(0, index) + prefix + value.substr(index) : value;
};
const pipe = (...fns) => value => fns.reduce((result, fn) => fn(result), value);

function storySort(a, b) {
const prefixFn = pipe(
prefix('welcome-', '0'),
prefix('getting-started', 'a'),
prefix('tokens-', '1'),
prefix('components-', '2'),
prefix('labs-', '3'),
prefix('default', 'aa'),
prefix('visual-testing', 'zz')
);

const left = prefixFn(a[0]);
const right = prefixFn(b[0]);

return left === right ? 0 : left.localeCompare(right);
}

export const decorators = [FontsDecorator, CanvasProviderDecorator];

export const parameters = {
options: {
storySort,
},
docs: {
theme,
container: DocsContainer,
page: DocsPage,
},
readme: {
codeTheme: 'github',
},
chromatic: {
disable: true,
},
};
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@ import {Meta} from '@storybook/addon-docs/blocks';
import ApiPatternGuidelines from '../../API_PATTERN_GUIDELINES.md';
import Markdown from '../../utils/storybook/Markdown.tsx';

<Meta title="Welcome|API & Pattern Guidelines" />
<Meta title="Welcome/API & Pattern Guidelines" />

<Markdown content={ApiPatternGuidelines} />
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@ import {Meta} from '@storybook/addon-docs/blocks';
import Changelog from '../../CHANGELOG.md';
import Markdown from '../../utils/storybook/Markdown.tsx';

<Meta title="Welcome|Changelog" />
<Meta title="Welcome/Changelog" />

<Markdown content={Changelog} />
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@ import {Meta} from '@storybook/addon-docs/blocks';
import ComponentStatus from '../../COMPONENT_STATUS.md';
import Markdown from '../../utils/storybook/Markdown.tsx';

<Meta title="Welcome|Component Status" />
<Meta title="Welcome/Component Status" />

<Markdown content={ComponentStatus} />
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@ import {Meta} from '@storybook/addon-docs/blocks';
import Contributing from '../../CONTRIBUTING.md';
import Markdown from '../../utils/storybook/Markdown.tsx';

<Meta title="Welcome|Contributing" />
<Meta title="Welcome/Contributing" />

<Markdown content={Contributing} />
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@ import {Meta} from '@storybook/addon-docs/blocks';
import Readme from '../../README.md';
import Markdown from '../../utils/storybook/Markdown.tsx';

<Meta title="Welcome|Getting Started" />
<Meta title="Welcome/Getting Started" />

<Markdown content={Readme} />
10 changes: 10 additions & 0 deletions .storybook/theme.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import {themes, create} from '@storybook/theming';
import {commonColors, typeColors, fontFamily} from '../modules/core/react';

export default create({
...themes.light, // Overrides a user's preferred color scheme (e.g. Dark Mode), will need to flesh this out later when CK is compatible with a dark mode
brandTitle: 'Canvas Kit',
mainTextColor: typeColors.body,
mainTextFace: fontFamily,
mainBackground: commonColors.backgroundAlt,
});
Loading