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

docs(carbon-react): update glob pattern to include missing stories #10500

Merged
merged 16 commits into from
Jan 27, 2022
Merged
Show file tree
Hide file tree
Changes from 8 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
47 changes: 40 additions & 7 deletions packages/carbon-react/.storybook/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,48 @@

'use strict';

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

const stories = glob
.sync(
[
'./Welcome/Welcome.stories.js',
'../src/**/*.stories.js',
'../src/**/*.stories.mdx',
'../../react/src/**/next/*.stories.js',
'../../react/src/**/next/*.stories.mdx',
'../../react/src/**/*-story.js',
],
{
cwd: __dirname,
}
)
.filter((match) => {
joshblack marked this conversation as resolved.
Show resolved Hide resolved
const filepath = path.resolve(__dirname, match);
const basename = path.basename(match, '.js');

if (basename.endsWith('-story')) {
const component = basename.replace(/-story$/, '');
const storyName = path.resolve(
filepath,
'..',
'next',
`${component}.stories.js`
);

if (fs.existsSync(storyName)) {
return false;
}

return true;
}

return true;
});

module.exports = {
addons: [
{
Expand All @@ -32,13 +71,7 @@ module.exports = {
features: {
previewCsfV3: true,
},
stories: [
'./Welcome/Welcome.stories.js',
'../src/**/*.stories.js',
'../src/**/*.stories.mdx',
'../../react/src/**/next/*.stories.js',
'../../react/src/**/next/*.stories.mdx',
],
stories: stories,
joshblack marked this conversation as resolved.
Show resolved Hide resolved
webpack(config) {
const babelLoader = config.module.rules.find((rule) => {
return rule.use.some(({ loader }) => {
Expand Down
3 changes: 3 additions & 0 deletions packages/carbon-react/.storybook/preview.js
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,9 @@ export const parameters = {
},
},
},
options: {
method: 'alphabetical',
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We might need to do this via a storySort function instead. The current order appears to be alphabetical per glob order, maybe? I'm not sure, but you can see Button stories aren't next to Breadcrumb in the current v11 deploy preview.

Click to expand screenshot

Screen Shot 2022-01-24 at 10 25 17 AM

},
};

configureActions({
Expand Down
1 change: 1 addition & 0 deletions packages/carbon-react/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@
"babel-preset-carbon": "^0.2.0",
"browserslist-config-carbon": "^10.6.1",
"css-loader": "^6.5.1",
"fast-glob": "^3.2.7",
"fs-extra": "^10.0.0",
"mini-css-extract-plugin": "^2.4.5",
"postcss": "^8.4.5",
Expand Down
1 change: 1 addition & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2104,6 +2104,7 @@ __metadata:
carbon-components-react: ^7.51.0
carbon-icons: ^7.0.7
css-loader: ^6.5.1
fast-glob: ^3.2.7
fs-extra: ^10.0.0
mini-css-extract-plugin: ^2.4.5
postcss: ^8.4.5
Expand Down