Skip to content

Commit 38398c4

Browse files
authored
Moar storybook (codesandbox#2275)
* add build script * yaaaaas * fix ts * ts
1 parent 3f4fdf9 commit 38398c4

File tree

19 files changed

+198
-62
lines changed

19 files changed

+198
-62
lines changed

packages/app/src/sandbox/eval/npm/fetch-npm-module.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -274,6 +274,11 @@ type DependencyVersionResult =
274274
| {
275275
version: string;
276276
packageJSONPath: null;
277+
}
278+
| {
279+
version: string;
280+
name: string | null;
281+
packageJSONPath: null;
277282
};
278283

279284
async function findDependencyVersion(

packages/common/.storybook/config.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ import { themes } from '@storybook/theming';
55

66
import global from '../src/global.css';
77
import { createGlobalStyle } from 'styled-components';
8+
import { ThemeDecorator } from '../src/stories/decorators';
9+
import { withKnobs } from '@storybook/addon-knobs';
810

911
const GlobalStyle = createGlobalStyle`
1012
${global}
@@ -33,3 +35,5 @@ function loadStories() {
3335

3436
configure(loadStories, module);
3537
addDecorator(withGlobal);
38+
addDecorator(ThemeDecorator);
39+
addDecorator(withKnobs);

packages/common/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
"clean": "rimraf lib && yarn rimraf node_modules/@types/react-native",
1616
"start": "(yarn tsc --watch & yarn babel src --out-dir lib --watch & yarn cpx \"src/**/*.{css,svg,png,jpg}\" lib --watch)",
1717
"start:storybook": "start-storybook",
18+
"build-storybook": "build-storybook -c .storybook -o public",
1819
"build": "yarn clean && yarn tsc && yarn babel src --out-dir lib && yarn cpx \"src/**/*.{css,svg,png,jpg}\" lib",
1920
"build:dev": "yarn build",
2021
"prepublish": "yarn build"
Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,7 @@
11
import * as React from 'react';
22
import { storiesOf } from '@storybook/react';
33
import AutosizeInput from './';
4-
import { ThemeDecorator } from '../../stories/decorators';
54

6-
const stories = storiesOf('components/Input', module).addDecorator(
7-
ThemeDecorator
8-
);
5+
const stories = storiesOf('components/Input', module);
96

107
stories.add('Basic AutosizeInput', () => <AutosizeInput />);
Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,6 @@
11
import * as React from 'react';
22
import { storiesOf } from '@storybook/react';
33
import AutosizeTextArea from './';
4-
import { ThemeDecorator } from '../../stories/decorators';
5-
6-
const stories = storiesOf('components/Input', module).addDecorator(
7-
ThemeDecorator
8-
);
94

5+
const stories = storiesOf('components/Input', module);
106
stories.add('Basic AutosizeTextArea', () => <AutosizeTextArea />);
Lines changed: 35 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,40 @@
11
import * as React from 'react';
22
import { storiesOf } from '@storybook/react';
33
import { action } from '@storybook/addon-actions';
4+
import { text, boolean } from '@storybook/addon-knobs';
45
import { Button } from './';
56

6-
const stories = storiesOf('components/Button', module);
7-
8-
stories.add('Basic button with text', () => (
9-
<Button onClick={action('onClick')}>Text</Button>
10-
));
7+
storiesOf('components/Button', module)
8+
.add('Basic button with text', () => (
9+
<Button onClick={action('onClick')}>{text('Value', 'Text')}</Button>
10+
))
11+
.add('Button small', () => (
12+
<Button small={boolean('small', true)} onClick={action('onClick')}>
13+
{text('Value', 'Text')}
14+
</Button>
15+
))
16+
.add('Button block', () => (
17+
<Button block={boolean('block', true)} onClick={action('onClick')}>
18+
{text('Value', 'Text')}
19+
</Button>
20+
))
21+
.add('Button disabled', () => (
22+
<Button disabled={boolean('disabled', true)} onClick={action('onClick')}>
23+
{text('Value', 'Text')}
24+
</Button>
25+
))
26+
.add('Button red', () => (
27+
<Button red={boolean('red', true)} onClick={action('onClick')}>
28+
{text('Value', 'Text')}
29+
</Button>
30+
))
31+
.add('Button secondary', () => (
32+
<Button secondary={boolean('secondary', true)} onClick={action('onClick')}>
33+
{text('Value', 'Text')}
34+
</Button>
35+
))
36+
.add('Button danger', () => (
37+
<Button danger={boolean('danger', true)} onClick={action('onClick')}>
38+
{text('Value', 'Text')}
39+
</Button>
40+
));

packages/common/src/components/Checkbox/index.stories.tsx

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,8 @@ import * as React from 'react';
22
import { storiesOf } from '@storybook/react';
33
import { action } from '@storybook/addon-actions';
44
import { Checkbox } from './';
5-
import { ThemeDecorator } from '../../stories/decorators';
65

7-
const stories = storiesOf('components/Input', module).addDecorator(
8-
ThemeDecorator
9-
);
6+
const stories = storiesOf('components/Input', module);
107

118
stories
129
.add('Basic Checkbox', () => (

packages/common/src/components/CommunityBadges/index.stories.tsx

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import * as React from 'react';
22
import { storiesOf } from '@storybook/react';
33
import CommunityBadge from './';
4-
import { ThemeDecorator } from '../../stories/decorators';
54

65
const templates = [
76
'create-react-app',
@@ -43,13 +42,13 @@ const FrameworkBadge = ({ template, sandboxNumber = 100 }) => (
4342
);
4443

4544
templates.map(t =>
46-
storiesOf('components/Community Badge/Gold', module)
47-
.addDecorator(ThemeDecorator)
48-
.add(t, () => <FrameworkBadge template={t} />)
45+
storiesOf('components/Community Badge/Gold', module).add(t, () => (
46+
<FrameworkBadge template={t} />
47+
))
4948
);
5049

5150
templates.map(t =>
52-
storiesOf('components/Community Badge/Silver', module)
53-
.addDecorator(ThemeDecorator)
54-
.add(t, () => <FrameworkBadge sandboxNumber={51} template={t} />)
51+
storiesOf('components/Community Badge/Silver', module).add(t, () => (
52+
<FrameworkBadge sandboxNumber={51} template={t} />
53+
))
5554
);
Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
import * as React from 'react';
22
import { storiesOf } from '@storybook/react';
3+
import { text } from '@storybook/addon-knobs';
34
import ContributorsBadge from './';
4-
import { ThemeDecorator } from '../../stories/decorators';
55

6-
const stories = storiesOf('components/ContributorsBadge', module).addDecorator(
7-
ThemeDecorator
8-
);
9-
stories.add('Default', () => <ContributorsBadge username={'SaraVieira'} />);
6+
const stories = storiesOf('components/ContributorsBadge', module);
7+
stories.add('Default', () => (
8+
<ContributorsBadge username={text('name', 'SaraVieira')} />
9+
));

packages/common/src/components/GithubBadge/index.stories.tsx

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,8 @@
11
import * as React from 'react';
22
import { storiesOf } from '@storybook/react';
33
import GithubBadge from './';
4-
import { ThemeDecorator } from '../../stories/decorators';
54

6-
const stories = storiesOf('components/GithubBadge', module).addDecorator(
7-
ThemeDecorator
8-
);
5+
const stories = storiesOf('components/GithubBadge', module);
96

107
stories
118
.add('Master', () => (

0 commit comments

Comments
 (0)