Skip to content

Commit

Permalink
chore: Updates Storybook to version 6 (#712)
Browse files Browse the repository at this point in the history
* Removing story.name

Signed-off-by: Marcos Iglesias <[email protected]>

* Adding pre-push hook

Signed-off-by: Marcos Iglesias <[email protected]>

* Updating Flag and Card

Signed-off-by: Marcos Iglesias <[email protected]>

* Updating Storybook to version 6

Signed-off-by: Marcos Iglesias <[email protected]>

* Updating betterer results

Signed-off-by: Marcos Iglesias <[email protected]>

* Update eslint config

Signed-off-by: Marcos Iglesias <[email protected]>

* Update eslint config

Signed-off-by: Marcos Iglesias <[email protected]>

* Removing pre-push hook as it runs on .src-custom

Signed-off-by: Marcos Iglesias <[email protected]>
Signed-off-by: dikshathakur3119 <[email protected]>
  • Loading branch information
Golodhros authored Oct 7, 2020
1 parent 00a3cb3 commit 3e00260
Show file tree
Hide file tree
Showing 12 changed files with 3,047 additions and 1,546 deletions.
4 changes: 2 additions & 2 deletions amundsen_application/static/.betterer.results
Original file line number Diff line number Diff line change
Expand Up @@ -343,8 +343,8 @@ exports[`strict null compilation`] = {
"js/utils/navigationUtils.ts:1127210474": [
[19, 50, 21, "Type \'undefined\' cannot be used as an index type.", "602535635"]
],
"webpack.common.ts:368637609": [
[34, 24, 20, "No overload matches this call.\\n Overload 1 of 2, \'(...items: ConcatArray<never>[]): never[]\', gave the following error.\\n Argument of type \'string\' is not assignable to parameter of type \'ConcatArray<never>\'.\\n Overload 2 of 2, \'(...items: ConcatArray<never>[]): never[]\', gave the following error.\\n Argument of type \'string\' is not assignable to parameter of type \'ConcatArray<never>\'.", "806093104"]
"webpack.common.ts:1615757453": [
[42, 24, 20, "No overload matches this call.\\n Overload 1 of 2, \'(...items: ConcatArray<never>[]): never[]\', gave the following error.\\n Argument of type \'string\' is not assignable to parameter of type \'ConcatArray<never>\'.\\n Overload 2 of 2, \'(...items: ConcatArray<never>[]): never[]\', gave the following error.\\n Argument of type \'string\' is not assignable to parameter of type \'ConcatArray<never>\'.", "806093104"]
]
}`
};
1 change: 1 addition & 0 deletions amundsen_application/static/.eslintignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,4 @@ stylesheets/*
vendor/*
docs/*
appbuilder/*
.src-custom/*
29 changes: 24 additions & 5 deletions amundsen_application/static/.storybook/main.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,34 @@
import merge from 'webpack-merge';
// Copyright Contributors to the Amundsen project.
// SPDX-License-Identifier: Apache-2.0

import customWebpackConfig from './webpack.config.js';
import MiniCssExtractPlugin from 'mini-css-extract-plugin';

import devWebpackConfig from '../webpack.dev';

module.exports = {
stories: ['../js/**/*.story.tsx'],
addons: [
'@storybook/addon-actions',
'@storybook/addon-links',
'@storybook/addon-knobs',
'@storybook/addon-knobs'
],
webpackFinal: async (config) => {
return merge(devWebpackConfig, config);
webpackFinal: (config) => {
return {
...config,
module: {
...config.module,
rules: customWebpackConfig.module.rules,
},
resolve: {
...config.resolve,
...customWebpackConfig.resolve,
},
plugins: [
new MiniCssExtractPlugin({
filename: "[name].[contenthash].css",
}),
...config.plugins
]
};
},
};
2 changes: 1 addition & 1 deletion amundsen_application/static/.storybook/manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,5 @@ addons.setConfig({
theme: amundsenTheme,
selectedPanel: undefined,
initialActive: 'sidebar',
showRoots: false,
showRoots: true,
});
22 changes: 9 additions & 13 deletions amundsen_application/static/.storybook/preview.ts
Original file line number Diff line number Diff line change
@@ -1,22 +1,18 @@
import anysort from 'anysort';
import { addParameters } from '@storybook/react';
// Copyright Contributors to the Amundsen project.
// SPDX-License-Identifier: Apache-2.0

import '../css/styles.scss';

const categoriesOrder = [
'Overview/Introduction',
'Attributes/**',
'Components/**',
'Overview',
'Attributes',
'Components',
];

addParameters({
export const parameters = {
options: {
showRoots: true,
storySort: (previous, next) => {
const [previousStory, previousMeta] = previous;
const [nextStory, nextMeta] = next;

return anysort(previousMeta.kind, nextMeta.kind, categoriesOrder);
storySort: {
order: categoriesOrder,
},
},
});
};
77 changes: 77 additions & 0 deletions amundsen_application/static/.storybook/webpack.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
// Copyright Contributors to the Amundsen project.
// SPDX-License-Identifier: Apache-2.0

const path = require('path');
const MiniCssExtractPlugin = require('mini-css-extract-plugin');

function resolve(dir) {
return path.join(__dirname, dir);
}

const TSX_PATTERN = /\.ts|\.tsx$/;
const JSX_PATTERN = /\.jsx?$/;
const CSS_PATTERN = /\.(sa|sc|c)ss$/;
const IMAGE_PATTERN = /\.(png|svg|jpg|gif)$/;
const FONT_PATTERN = /\.(ttf|woff2|otf)$/;
const RESOLVED_EXTENSIONS = ['.tsx', '.ts', '.js', '.jsx', '.css', '.scss'];
const PATHS = {
dist: resolve('../dist'),
pages: resolve('../js/pages'),
components: resolve('../js/components'),
config: resolve('../js/config'),
ducks: resolve('../js/ducks'),
interfaces: resolve('../js/interfaces'),
utils: resolve('../js/utils'),
css: resolve('../css/'),
};

module.exports = {
module: {
rules: [
{
test: TSX_PATTERN,
exclude: /node_modules/,
loader: 'ts-loader',
},
{
test: JSX_PATTERN,
exclude: /node_modules/,
use: 'babel-loader',
},
{
test: CSS_PATTERN,
use: [
MiniCssExtractPlugin.loader,
'css-loader',
{
loader: 'sass-loader',
options: {
sassOptions: {
includePaths: [PATHS.css],
},
},
},
],
},
{
test: IMAGE_PATTERN,
use: 'file-loader',
},
{
test: FONT_PATTERN,
use: 'file-loader',
},
]
},
resolve: {
extensions: RESOLVED_EXTENSIONS,
alias: {
pages: PATHS.pages,
components: PATHS.components,
config: PATHS.config,
ducks: PATHS.ducks,
interfaces: PATHS.interfaces,
utils: PATHS.utils,
},
},
};
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,15 @@
// SPDX-License-Identifier: Apache-2.0

import React from 'react';
import { storiesOf } from '@storybook/react';

import StorySection from '../StorySection';
import Card from '.';

const stories = storiesOf('Components/Cards', module);
export default {
title: 'Components/Cards',
};

stories.add('Cards', () => (
export const Cards = () => (
<>
<StorySection title="Loading Card">
<Card isLoading />
Expand All @@ -28,4 +29,6 @@ stories.add('Cards', () => (
/>
</StorySection>
</>
));
);

Cards.storyName = 'Cards';
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,16 @@
// SPDX-License-Identifier: Apache-2.0

import React from 'react';
import { storiesOf } from '@storybook/react';

import { BadgeStyle } from 'config/config-types';
import StorySection from '../StorySection';
import Flag, { CaseType } from '.';

const stories = storiesOf('Components/Flags', module);
export default {
title: 'Components/Flags',
};

stories.add('Flags', () => (
export const Flags = () => (
<>
<StorySection title="Lower Case Flag">
<Flag caseType={CaseType.LOWER_CASE} text="Test Flag" />
Expand Down Expand Up @@ -64,4 +65,6 @@ stories.add('Flags', () => (
/>
</StorySection>
</>
));
);

Flags.storyName = 'Flags';
8 changes: 2 additions & 6 deletions amundsen_application/static/js/stories/typography.story.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,7 @@ export const TypographyUpdated = () => {
);
};

TypographyUpdated.story = {
name: 'Typography',
};
TypographyUpdated.storyName = 'Typography';

export const Typography = () => {
return (
Expand Down Expand Up @@ -102,6 +100,4 @@ export const Typography = () => {
);
};

Typography.story = {
name: 'Deprecated: Headings & Body',
};
Typography.storyName = 'Deprecated: Headings & Body';
Loading

0 comments on commit 3e00260

Please sign in to comment.