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

Move @automattic/components' Storybook to the root Storybook #76007

Merged
merged 13 commits into from
Apr 21, 2023
6 changes: 5 additions & 1 deletion .storybook/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,11 @@ const devConfig = require( '../config/development.json' );
const storybookDefaultConfig = require( '@automattic/calypso-storybook' );

const storybookConfig = storybookDefaultConfig( {
stories: [ '../client/**/*.stories.{ts,tsx}', '../packages/design-picker/**/*.stories.{ts,tsx}' ],
stories: [
'../client/**/*.stories.{ts,tsx}',
'../packages/design-picker/**/*.stories.{ts,tsx}',
'../packages/components/**/*.stories.{ts,tsx}',
],
} );

const configData = { ...sharedConfig, ...devConfig };
Expand Down
16 changes: 0 additions & 16 deletions .storybook/preview.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,6 @@ import './index.scss';
export const parameters = {
layout: 'fullscreen',
viewport: {
/**
* These viewports are from Gutenberg.
* We can use this to set `parameters.viewport` in a story.
*
* @example
* export default {
* title: 'sample',
* component: Sample,
* parameters: {
* viewport: {
* defaultViewport: 'SMALL',
* },
* },
* }
* @see https://github.com/WordPress/gutenberg/blob/db2f753977d1b5c28f1ff80b3fc32aa1d7a6a773/packages/base-styles/_breakpoints.scss#L6-L13
*/
viewports: {
HUGE: {
name: 'HUGE',
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@
"clean:packages": "yarn workspaces foreach --all --parallel --verbose --exclude 'wp-calypso' run clean",
"clean:public": "rm -rf public",
"clean:translations": "rm -rf build/strings calypso-strings.pot chunks-map.*.json || true",
"components:storybook:start": "echo 'Deprecated, run `yarn workspace @automattic/components run storybook` instead'",
"components:storybook:start": "echo 'Storybook in Calypso moved into the root directory. Run `yarn storybook:start` instead.'",
"composite-checkout:storybook:start": "echo 'Deprecated, run `yarn workspace @automattic/composite-checkout run storybook` instead'",
"distclean": "yarn run clean && rm -rf **/node_modules **/.cache .yarn/install-state.gz || true",
"docker": "docker run -it --name wp-calypso --rm -p 80:3000 wp-calypso",
Expand Down
3 changes: 0 additions & 3 deletions packages/components/.storybook/main.js

This file was deleted.

1 change: 0 additions & 1 deletion packages/components/.storybook/preview.js

This file was deleted.

2 changes: 1 addition & 1 deletion packages/components/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,4 +41,4 @@ in the root of the repository to get the required `devDependencies`.

### Using [Storybook](https://storybook.js.org/)

`yarn workspace @automattic/components run storybook`
In the root of the repository, run `yarn storybook:start`.
4 changes: 1 addition & 3 deletions packages/components/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@
},
"devDependencies": {
"@automattic/calypso-color-schemes": "workspace:^",
"@automattic/calypso-storybook": "workspace:^",
"@automattic/calypso-typescript-config": "workspace:^",
"@storybook/addon-actions": "^6.4.19",
"@storybook/react": "^6.4.18",
Expand All @@ -67,7 +66,6 @@
"scripts": {
"clean": "tsc --build ./tsconfig.json ./tsconfig-cjs.json --clean && rm -rf dist",
"build": "tsc --build ./tsconfig.json ./tsconfig-cjs.json && copy-assets",
"prepack": "yarn run clean && yarn run build",
"storybook": "start-storybook"
Copy link
Member

Choose a reason for hiding this comment

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

Let's keep in mind the READMEs and documentation that we need to update:

https://github.com/Automattic/wp-calypso/blob/trunk/packages/components/README.md#L44

Ideally, we should add a more central section that leads to the central Storybook instance, somewhere in /docs for example in components.md.

Copy link
Member Author

Choose a reason for hiding this comment

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

Thank you for pointing this out, I updated the code about the existing command in this PR. 722e121

And I agree that we must update the document, such as https://github.com/Automattic/wp-calypso/blob/trunk/docs/components.md and https://github.com/Automattic/wp-calypso/blob/trunk/docs/component-libraries.md.

"prepack": "yarn run clean && yarn run build"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import { useRef } from 'react';
import UplotChart from '../';

export default { title: 'Chart (uPlot)' };
export default { title: 'packages/components/Chart (uPlot)' };

const SAMPLE_DATA = [
[
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import JetpackUpsellCard from '..';

export default { title: 'Jetpack Upsell Card' };
export default { title: 'packages/components/Jetpack Upsell Card' };

const upgradeUrls = {
backup: 'https://jetpack.com',
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { css } from '@emotion/css';
import { LoadingPlaceholder } from '.';

export default { title: 'LoadingPlaceholder' };
export default { title: 'packages/components/LoadingPlaceholder' };

export const Normal = () => <LoadingPlaceholder />;
export const Width = () => <LoadingPlaceholder className={ css( { maxWidth: 300 } ) } />;
Expand Down
2 changes: 1 addition & 1 deletion packages/components/src/progress-bar/index.stories.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import ProgressBar from '.';

export default { title: 'ProgressBar' };
export default { title: 'packages/components/ProgressBar' };

export const Normal = () => <ProgressBar value={ 33 } />;
export const Colored = () => <ProgressBar color="red" value={ 33 } />;
Expand Down
2 changes: 1 addition & 1 deletion packages/components/src/ribbon/index.stories.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import Ribbon from '.';

export default { title: 'Ribbon' };
export default { title: 'packages/components/Ribbon' };

export const Default = () => {
return <Ribbon>Buy Now!</Ribbon>;
Expand Down
2 changes: 1 addition & 1 deletion packages/components/src/submenu-popover/index.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { DropdownMenu, Icon, MenuGroup, MenuItem } from '@wordpress/components';
import { chevronRight } from '@wordpress/icons';
import SubmenuPopover, { useSubmenuPopoverProps } from '.';

export default { title: 'SubmenuPopover' };
export default { title: 'packages/components/SubmenuPopover' };

export const Default = () => {
const submenu = useSubmenuPopoverProps< HTMLDivElement >();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { ComponentProps } from 'react';
import ThemeCard from './index';

export default {
title: 'packages/@automattic/design-picker/ThemeCard',
title: 'packages/design-picker/ThemeCard',
component: ThemeCard,
parameters: {
viewport: {
Expand Down
1 change: 0 additions & 1 deletion yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -418,7 +418,6 @@ __metadata:
resolution: "@automattic/components@workspace:packages/components"
dependencies:
"@automattic/calypso-color-schemes": "workspace:^"
"@automattic/calypso-storybook": "workspace:^"
"@automattic/calypso-typescript-config": "workspace:^"
"@automattic/calypso-url": "workspace:^"
"@automattic/data-stores": "workspace:^"
Expand Down