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

chore(storybook): upgrade to 5.3 - INNO-2075 #1520

Merged
merged 6 commits into from
Jan 30, 2020
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
18 changes: 13 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,10 @@
"eslint-plugin-react-hooks": "2.3.0",
"eslint-plugin-unicorn": "15.0.1",
"glob": "7.1.6",
"husky": "4.2.0",
"husky": "4.2.1",
"lerna": "3.20.2",
"lerna-changelog": "1.0.0",
"lint-staged": "10.0.1",
"lint-staged": "10.0.2",
"netlify-cli": "2.30.0",
"node-fetch": "2.6.0",
"npm-run-all": "4.1.5",
Expand All @@ -78,9 +78,17 @@
"yarn": "^1.10.1"
},
"lint-staged": {
"*.{md,mdx,html,json,yml}": [ "prettier --write" ],
"*.{js,jsx}": [ "prettier --write", "eslint" ],
"*.scss": [ "prettier --write", "stylelint" ]
"*.{md,mdx,html,json,yml}": [
"prettier --write"
],
"*.{js,jsx}": [
"prettier --write",
"eslint"
],
"*.scss": [
"prettier --write",
"stylelint"
]
},
"workspaces": [
"examples/*",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { withKnobs, text, array } from '@storybook/addon-knobs';
import demoContentCard from '@ecl/ec-specs-card/demo/data--card';
import demoContentTile from '@ecl/ec-specs-card/demo/data--tile';

import template from './Template';
import { Template as template } from './Template';

import Card from '../src/Card';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@ import demoContentTile from '@ecl/ec-specs-card/demo/data--tile';

import Card from '../src/Card';

const Template = () => {
// Storybook issues with modules' resolutions https://github.com/storybookjs/storybook/issues/9621
/* eslint-disable-next-line import/prefer-default-export */
export const Template = () => {
const image1 = {
alt: demoContentCard.image.alt,
src: demoContentCard.image.src,
Expand Down Expand Up @@ -97,5 +99,3 @@ const Template = () => {
</div>
);
};

export default Template;

This file was deleted.

36 changes: 36 additions & 0 deletions src/systems/ec/implementations/react/storybook/.storybook/main.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
const path = require('path');

const stories = [
'../../templates/**/*/stories/*.jsx',
'../../page-structure/**/*/stories/*.jsx',
'../../layout/**/*/stories/*.jsx',
'../../components/**/*/stories/*.jsx',
'../../utilities/**/*/stories/*.jsx',
'../../deprecated/**/*/stories/*.jsx',
];

const addons = [
'@storybook/addon-options',
'@storybook/addon-knobs',
'@storybook/addon-viewport',
'@storybook/addon-a11y',
'@storybook/addon-cssresources',
];

const managerEntries = [
'../../../../../../src/tools/storybook-addon-code/register',
];

const managerWebpack = async baseConfig => {
// Babel loader: include "src"
baseConfig.module.rules[0].include.push(
path.resolve(__dirname, '../../../../../..')
);

// Exclude node_modules
baseConfig.module.rules[0].exclude = /node_modules/;

return baseConfig;
};

module.exports = { stories, addons, managerEntries, managerWebpack };
Original file line number Diff line number Diff line change
@@ -1,14 +1,36 @@
const path = require('path');
import { addons } from '@storybook/addons';
import { create } from '@storybook/theming/create';

// Provide a custom webpack config for the manager
module.exports.managerWebpack = async (baseConfig, options) => {
// Babel loader: include "src"
baseConfig.module.rules[0].include.push(
path.resolve(__dirname, '../../../../../..')
);
const theme = create({
base: 'light',
colorSecondary: '#004494',
appBorderRadius: 0,
inputBorderRadius: 0,
brandTitle: 'ECL v2 - EC',
brandUrl: 'https://github.com/ec-europa/europa-component-library',
brandImage: null,
});

// Exclude node_modules
baseConfig.module.rules[0].exclude = /node_modules/;
const storySort = (a, b) => {
const aParentKind = a[1].kind.split('|').shift();
const aKind = a[1].kind
.split('|')
.slice(1)
.join('|');
const bParentKind = b[1].kind.split('|').shift();
const bKind = b[1].kind
.split('|')
.slice(1)
.join('|');

return baseConfig;
return aParentKind !== bParentKind
? 0
: aKind.localeCompare(bKind, { numeric: true });
};

addons.setConfig({
theme,
storySort,
sidebarAnimations: false,
panelPosition: 'right',
});

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
import { configure, addDecorator, addParameters } from '@storybook/react';
import { withOptions } from '@storybook/addon-options';
import { create } from '@storybook/theming';
import { addDecorator, addParameters } from '@storybook/react';
import { withA11y } from '@storybook/addon-a11y';
import { INITIAL_VIEWPORTS } from '@storybook/addon-viewport';
import { withCssResources } from '@storybook/addon-cssresources';
Expand Down Expand Up @@ -51,35 +49,6 @@ html {
picked: false,
},
],
options: {
theme: create({
base: 'light',
colorSecondary: '#004494',
appBorderRadius: 0,
inputBorderRadius: 0,
brandTitle: 'ECL v2 - EC',
brandUrl: 'https://github.com/ec-europa/europa-component-library',
brandImage: null,
}),
sidebarAnimations: false,
panelPosition: 'right',
storySort: (a, b) => {
const aParentKind = a[1].kind.split('|').shift();
const aKind = a[1].kind
.split('|')
.slice(1)
.join('|');
const bParentKind = b[1].kind.split('|').shift();
const bKind = b[1].kind
.split('|')
.slice(1)
.join('|');

return aParentKind !== bParentKind
? 0
: aKind.localeCompare(bKind, { numeric: true });
},
},
viewport: {
defaultViewport: 'iphone6',
viewports: {
Expand Down Expand Up @@ -115,21 +84,3 @@ html {
},
},
});

const contexts = [
require.context('../../templates', true, /stories.*\.jsx?$/),
require.context('../../page-structure', true, /stories.*\.jsx?$/),
require.context('../../layout', true, /stories.*\.jsx?$/),
require.context('../../components', true, /stories.*\.jsx?$/),
require.context('../../utilities', true, /stories.*\.jsx?$/),
require.context('../../deprecated', true, /stories.*\.jsx?$/),
];

configure(() => {
contexts.forEach(context => {
context
.keys()
.filter(key => !key.includes('node_modules'))
.forEach(context);
});
}, module);
Original file line number Diff line number Diff line change
@@ -1,4 +1,11 @@
const path = require('path');

module.exports = ({ config: defaultConfig }) => {
// Babel loader: include "src"
defaultConfig.module.rules[0].include.push(
path.resolve(__dirname, '../../../../../..')
);

defaultConfig.module.rules[0].exclude.push(/node_modules/);

// Change media dist folder
Expand Down
16 changes: 8 additions & 8 deletions src/systems/ec/implementations/react/storybook/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,14 @@
"@babel/plugin-proposal-export-namespace-from": "7.8.3",
"@babel/runtime": "7.8.3",
"@ecl/story-wrapper": "^2.22.0",
"@storybook/addon-a11y": "5.2.8",
"@storybook/addon-cssresources": "5.2.8",
"@storybook/addon-knobs": "5.2.8",
"@storybook/addon-options": "5.2.8",
"@storybook/addon-viewport": "5.2.8",
"@storybook/addons": "5.2.8",
"@storybook/react": "5.2.8",
"@storybook/theming": "5.2.8",
"@storybook/addon-a11y": "5.3.9",
"@storybook/addon-cssresources": "5.3.9",
"@storybook/addon-knobs": "5.3.9",
"@storybook/addon-options": "5.3.9",
"@storybook/addon-viewport": "5.3.9",
"@storybook/addons": "5.3.9",
"@storybook/react": "5.3.9",
"@storybook/theming": "5.3.9",
"babel-core": "^7.0.0-bridge.0",
"babel-loader": "8.0.6",
"core-js": "3.6.4",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { withKnobs, text, array } from '@storybook/addon-knobs';
import demoContentCard from '@ecl/eu-specs-card/demo/data--card';
import demoContentTile from '@ecl/eu-specs-card/demo/data--tile';

import template from './Template';
import { Template as template } from './Template';

import Card from '../src/Card';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@ import demoContentTile from '@ecl/eu-specs-card/demo/data--tile';

import Card from '../src/Card';

const Template = () => {
// Storybook issues with modules' resolutions https://github.com/storybookjs/storybook/issues/9621
/* eslint-disable-next-line import/prefer-default-export */
export const Template = () => {
const image1 = {
alt: demoContentCard.image.alt,
src: demoContentCard.image.src,
Expand Down Expand Up @@ -97,5 +99,3 @@ const Template = () => {
</div>
);
};

export default Template;

This file was deleted.

35 changes: 35 additions & 0 deletions src/systems/eu/implementations/react/storybook/.storybook/main.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
const path = require('path');

const stories = [
'../../templates/**/*/stories/*.jsx',
'../../page-structure/**/*/stories/*.jsx',
'../../layout/**/*/stories/*.jsx',
'../../components/**/*/stories/*.jsx',
'../../utilities/**/*/stories/*.jsx',
];

const addons = [
'@storybook/addon-options',
'@storybook/addon-knobs',
'@storybook/addon-viewport',
'@storybook/addon-a11y',
'@storybook/addon-cssresources',
];

const managerEntries = [
'../../../../../../src/tools/storybook-addon-code/register',
];

const managerWebpack = async baseConfig => {
// Babel loader: include "src"
baseConfig.module.rules[0].include.push(
path.resolve(__dirname, '../../../../../..')
);

// Exclude node_modules
baseConfig.module.rules[0].exclude = /node_modules/;

return baseConfig;
};

module.exports = { stories, addons, managerEntries, managerWebpack };
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,10 @@
x: window.innerWidth - rightPanelWidth,
y: 0,
},
resizerNav: { x: leftPanelWidth, y: 0 },
resizerNav: {
x: leftPanelWidth,
y: 0,
},
})
);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,36 @@
const path = require('path');
import { addons } from '@storybook/addons';
import { create } from '@storybook/theming/create';

// Provide a custom webpack config for the manager
module.exports.managerWebpack = async (baseConfig, options) => {
// Babel loader: include "src"
baseConfig.module.rules[0].include.push(
path.resolve(__dirname, '../../../../../..')
);
const theme = create({
base: 'light',
colorSecondary: '#004494',
appBorderRadius: 0,
inputBorderRadius: 0,
brandTitle: 'ECL v2 - EU',
brandUrl: 'https://github.com/ec-europa/europa-component-library',
brandImage: null,
});

// Exclude node_modules
baseConfig.module.rules[0].exclude = /node_modules/;
const storySort = (a, b) => {
const aParentKind = a[1].kind.split('|').shift();
const aKind = a[1].kind
.split('|')
.slice(1)
.join('|');
const bParentKind = b[1].kind.split('|').shift();
const bKind = b[1].kind
.split('|')
.slice(1)
.join('|');

return baseConfig;
return aParentKind !== bParentKind
? 0
: aKind.localeCompare(bKind, { numeric: true });
};

addons.setConfig({
theme,
storySort,
sidebarAnimations: false,
panelPosition: 'right',
});

This file was deleted.