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

Storybook setup #7

Merged
merged 2 commits into from
Feb 23, 2021
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions .storybook/main.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
module.exports = {
"stories": [
"../src/app/**/*.stories.mdx",
"../src/app/**/*.stories.@(js|jsx|ts|tsx)"
],
"addons": [
"@storybook/addon-links",
"@storybook/addon-essentials",
"@storybook/preset-create-react-app",
"storybook-addon-designs"
]
}
4 changes: 4 additions & 0 deletions .storybook/preview.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@

export const parameters = {
actions: { argTypesRegex: "^on[A-Z].*" },
}
13 changes: 13 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,12 @@ This project was bootstrapped with [Create React App](https://github.com/faceboo

In the project directory, you can run:

### `npm install`

**Note:** Downgrade to NPM V6 for this repo to work correctly. Storybook 6.1.18 is having issues with NPM V7.\
Use `npm install -g npm@6` to downgrade to NPM V6\
https://github.com/storybookjs/storybook/issues/12983

### `npm start`

Runs the app in the development mode.\
Expand All @@ -14,6 +20,13 @@ Open [http://localhost:3000](http://localhost:3000) to view it in the browser.
The page will reload if you make edits.\
You will also see any lint errors in the console.

### `npm run storybook`

Runs the app in [Storybook](https://storybook.js.org) mode. (We are able to run Storybook and React App at the same time)\
When Storybook runs, it looks for all stories in `src/app/**/` with this regex `*.stories.tsx`.

The page will reload if you make edits.

### `npm test`

Launches the test runner in the interactive watch mode.\
Expand Down
13 changes: 11 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,9 @@
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject"
"eject": "react-scripts eject",
"storybook": "start-storybook -p 6006 -s public",
"build-storybook": "build-storybook -s public"
},
"eslintConfig": {
"extends": [
Expand All @@ -46,7 +48,14 @@
]
},
"devDependencies": {
"antd": "^4.12.3"
"@storybook/addon-actions": "^6.1.18",
"@storybook/addon-essentials": "^6.1.18",
"@storybook/addon-links": "^6.1.18",
"@storybook/node-logger": "^6.1.18",
"@storybook/preset-create-react-app": "^3.1.6",
"@storybook/react": "^6.1.18",
"antd": "^4.12.3",
"storybook-addon-designs": "^5.4.5"
},
"jest": {
"transformIgnorePatterns": [
Expand Down
24 changes: 24 additions & 0 deletions src/app/content/Content.stories.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import React from 'react';
// also exported from '@storybook/react' if you can deal with breaking changes in 6.1
import { Story, Meta } from '@storybook/react/types-6-0';

import { Content, ContentProps } from './Content';

export default {
title: 'Content',
component: Content,
} as Meta;

const Template: Story<ContentProps> = (args) => <Content {...args} />;

export const Default = Template.bind({});
Default.args = {
content: 'hello world',
};

Default.parameters = {
design: {
type: 'figma',
url: 'https://www.figma.com/file/taMF1mrqs7jAS7myzk78mT/clockwork?node-id=0%3A1',
},
}
23 changes: 20 additions & 3 deletions src/app/content/Content.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,22 @@
import React from "react";
import React from 'react';

export function Content() {
return <div>content</div>;
export interface ContentProps {
/**
* Content
* Subject to change
*/
content?: string;
}

/**
* Primary UI component for content
*/
export const Content: React.FC<ContentProps> = ({
content
}) => {
return (
<div>
{content}
</div>
)
};
25 changes: 25 additions & 0 deletions src/app/header/Header.stories.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import React from 'react';
// also exported from '@storybook/react' if you can deal with breaking changes in 6.1
import { Story, Meta } from '@storybook/react/types-6-0';

import { Header, HeaderProps } from './Header';

export default {
title: 'Header',
component: Header,
} as Meta;

const Template: Story<HeaderProps> = (args) => <Header {...args} />;

export const Default = Template.bind({});
Default.args = {
content: 'hello world - header',
};

Default.parameters = {
design: {
type: 'figma',
url: 'https://www.figma.com/file/taMF1mrqs7jAS7myzk78mT/clockwork?node-id=0%3A1',
},
}

25 changes: 22 additions & 3 deletions src/app/header/Header.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,24 @@
import React from "react";
import React from 'react';
// import StyledHeader from './Header.styles';

export function Header() {
return <div>header</div>;

export interface HeaderProps {
/**
* Content
* Subject to change
*/
content?: string;
}

/**
* Primary UI component for content
*/
export const Header: React.FC<HeaderProps> = ({
content
}) => {
return (
<div>
{content}
</div>
)
};
25 changes: 25 additions & 0 deletions src/app/sidebar/Sidebar.stories.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import React from 'react';
// also exported from '@storybook/react' if you can deal with breaking changes in 6.1
import { Story, Meta } from '@storybook/react/types-6-0';

import { Sidebar, SidebarProps } from './Sidebar';

export default {
title: 'Sidebar',
component: Sidebar,
} as Meta;

const Template: Story<SidebarProps> = (args) => <Sidebar {...args} />;

export const Default = Template.bind({});
Default.args = {
content: 'hello world - sidebar',
};

Default.parameters = {
design: {
type: 'figma',
url: 'https://www.figma.com/file/taMF1mrqs7jAS7myzk78mT/clockwork?node-id=0%3A1',
},
}

25 changes: 22 additions & 3 deletions src/app/sidebar/Sidebar.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,24 @@
import React from "react";
import React from 'react';
// import StyledHeader from './Header.styles';

export function Sidebar() {
return <div>sidebar</div>;

export interface SidebarProps {
/**
* Content
* Subject to change
*/
content?: string;
}

/**
* Primary UI component for content
*/
export const Sidebar: React.FC<SidebarProps> = ({
content
}) => {
return (
<div>
{content}
</div>
)
};