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: Getting fancier with Storybook #10647

Merged
merged 10 commits into from
Aug 21, 2020
47 changes: 35 additions & 12 deletions superset-frontend/.eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,12 +87,18 @@ module.exports = {
'no-prototype-builtins': 0,
'no-restricted-properties': 0,
'no-restricted-syntax': 0,
'no-restricted-imports': ['error', {
'paths': [{
'name': 'antd',
'message': 'Please import Ant components from the index of common/components',
}]
}],
'no-restricted-imports': [
'error',
{
paths: [
{
name: 'antd',
message:
'Please import Ant components from the index of common/components',
},
],
},
],
'padded-blocks': 0,
'prefer-arrow-callback': 0,
'react/forbid-prop-types': 0,
Expand All @@ -114,6 +120,17 @@ module.exports = {
},
},
},
{
files: ['*.stories.jsx', '*.stories.tsx'],
rules: {
// this is to keep eslint from complaining about storybook addons,
// since they are included as dev dependencies rather than direct dependencies.
'import/no-extraneous-dependencies': [
'error',
{ devDependencies: true },
],
},
},
],
rules: {
camelcase: [
Expand Down Expand Up @@ -152,12 +169,18 @@ module.exports = {
'no-prototype-builtins': 0,
'no-restricted-properties': 0,
'no-restricted-syntax': 0,
'no-restricted-imports': ['error', {
'paths': [{
'name': 'antd',
'message': 'Please import Ant components from the index of common/components',
}]
}],
'no-restricted-imports': [
'error',
{
paths: [
{
name: 'antd',
message:
'Please import Ant components from the index of common/components',
},
],
},
],
'padded-blocks': 0,
'prefer-arrow-callback': 0,
'prefer-object-spread': 1,
Expand Down
5 changes: 3 additions & 2 deletions superset-frontend/.storybook/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,14 @@ const path = require('path');
const customConfig = require('../webpack.config.js');

module.exports = {
stories: ['../src/components/**/*.stories.(t|j)sx'],
stories: ['../src/components/**/*.stories.@(t|j)sx'],
addons: [
'@storybook/addon-actions',
'@storybook/addon-essentials',
'@storybook/addon-links',
'@storybook/preset-typescript',
'storybook-addon-jsx',
'@storybook/addon-knobs/register',
'storybook-addon-paddings',
],
webpackFinal: config => ({
...config,
Expand Down
13 changes: 13 additions & 0 deletions superset-frontend/.storybook/preview.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,27 @@
import React from 'react';
import { addDecorator } from '@storybook/react';
import { jsxDecorator } from 'storybook-addon-jsx';
import { addParameters } from '@storybook/react';
import { withPaddings } from 'storybook-addon-paddings';

import { supersetTheme, ThemeProvider } from '@superset-ui/style';

import '../src/theme.ts';
import './storybook.css';

const themeDecorator = storyFn => (
<ThemeProvider theme={supersetTheme}>{storyFn()}</ThemeProvider>
);

addDecorator(jsxDecorator);
addDecorator(themeDecorator);
addDecorator(withPaddings);

addParameters({
paddings: [
{ name: 'None', value: '0px' },
{ name: 'Small', value: '16px' },
{ name: 'Medium', value: '32px', default: true },
{ name: 'Large', value: '64px' },
],
});
3 changes: 3 additions & 0 deletions superset-frontend/.storybook/storybook.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
body{
background: transparent;
}
Loading