Skip to content

Commit 1975e08

Browse files
authored
Design system yay (codesandbox#2295)
* add more stories * add more * add more * Update packages/common/src/templates/configuration/sandbox/ui.tsx Co-Authored-By: Ives van Hoorne <[email protected]> * fix ts * fix ts * fix tests * add now.json
1 parent c18c081 commit 1975e08

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

65 files changed

+574
-75
lines changed

packages/common/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
lib
2+
public
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,5 @@
11
import '@storybook/addon-actions/register';
22
import '@storybook/addon-knobs/register';
3+
import '@storybook/addon-storysource/register';
4+
import '@storybook/addon-viewport/register';
5+
import '@storybook/addon-a11y/register';

packages/common/.storybook/config.tsx

Lines changed: 38 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import React, { Fragment } from 'react';
22

33
import { withKnobs } from '@storybook/addon-knobs';
4+
import { withA11y } from '@storybook/addon-a11y';
45
import { addDecorator, addParameters, configure } from '@storybook/react';
56
import { themes } from '@storybook/theming';
67

@@ -10,21 +11,57 @@ import { createGlobalStyle } from 'styled-components';
1011

1112
import global from '../src/global.css';
1213

14+
const viewports = {
15+
mobile: {
16+
name: 'Mobile',
17+
styles: {
18+
width: '375px',
19+
height: '667px',
20+
},
21+
},
22+
tablet: {
23+
name: 'Tablet',
24+
styles: {
25+
width: '768px',
26+
height: '1024px',
27+
},
28+
},
29+
laptop: {
30+
name: 'Laptop',
31+
styles: {
32+
width: '1366px',
33+
height: '768px',
34+
},
35+
},
36+
desktop: {
37+
name: 'Desktop',
38+
styles: {
39+
width: '1920px',
40+
height: '1080px',
41+
},
42+
},
43+
};
44+
1345
const GlobalStyle = createGlobalStyle`
1446
${global}
1547
`;
1648

1749
export const withGlobal = cb => (
1850
<Fragment>
1951
<GlobalStyle />
20-
2152
{cb()}
2253
</Fragment>
2354
);
2455

56+
addDecorator(withA11y);
2557
addDecorator(withKnobs);
2658
addDecorator(withGlobal);
2759
addDecorator(ThemeDecorator);
60+
addParameters({
61+
viewport: {
62+
viewports,
63+
},
64+
});
2865

2966
// Option defaults.
3067
addParameters({

packages/common/.storybook/webpack.config.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,11 @@ module.exports = ({ config }) => {
1010
},
1111
],
1212
});
13+
config.module.rules.push({
14+
test: /\.stories\.jsx?$/,
15+
loaders: [require.resolve('@storybook/addon-storysource/loader')],
16+
enforce: 'pre',
17+
});
1318
config.resolve.extensions.push('.ts', '.tsx');
1419
return config;
1520
};

packages/common/now.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"version": 2,
3+
"name": "storybook",
4+
"alias": "storybook-codesandbox"
5+
}

packages/common/package.json

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,18 @@
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",
19-
"build": "yarn clean && yarn tsc && yarn babel src --out-dir lib && yarn cpx \"src/**/*.{css,svg,png,jpg}\" lib",
18+
"build:storybook": "build-storybook -c .storybook -o public",
19+
"build:lib": "yarn clean && yarn tsc && yarn babel src --out-dir lib && yarn cpx \"src/**/*.{css,svg,png,jpg}\" lib",
20+
"build": "yarn build:lib && yarn build:storybook",
2021
"build:dev": "yarn build",
2122
"prepublish": "yarn build"
2223
},
2324
"dependencies": {
2425
"@babel/plugin-transform-flow-strip-types": "^7.0.0",
2526
"@sentry/browser": "^5.6.2",
27+
"@babel/polyfill": "^7.4.4",
28+
"@codesandbox/notifications": "^1.0.3",
29+
"@codesandbox/template-icons": "^0.7.0",
2630
"@tippy.js/react": "^2.1.1",
2731
"babel-plugin-preval": "^3.0.1",
2832
"codesandbox-api": "^0.0.22",
@@ -50,8 +54,16 @@
5054
"devDependencies": {
5155
"@babel/cli": "^7.2.3",
5256
"@babel/core": "^7.5.5",
57+
"@babel/plugin-proposal-class-properties": "^7.5.5",
58+
"@babel/plugin-proposal-object-rest-spread": "^7.5.5",
59+
"@babel/plugin-syntax-dynamic-import": "^7.2.0",
60+
"@babel/plugin-transform-async-to-generator": "^7.5.0",
61+
"@babel/plugin-transform-runtime": "^7.5.5",
62+
"@storybook/addon-a11y": "^5.1.11",
5363
"@storybook/addon-actions": "^5.1.9",
5464
"@storybook/addon-knobs": "^5.1.9",
65+
"@storybook/addon-storysource": "^5.1.11",
66+
"@storybook/addon-viewport": "^5.1.11",
5567
"@storybook/react": "^5.1.9",
5668
"@types/color": "0.12.1",
5769
"@types/humps": "^1.1.2",
@@ -64,6 +76,9 @@
6476
"@types/styled-components": "^4.1.13",
6577
"babel-jest": "^24.8.0",
6678
"babel-loader": "^8.0.6",
79+
"babel-plugin-lodash": "^3.3.4",
80+
"babel-plugin-macros": "^2.6.1",
81+
"babel-plugin-system-import-transformer": "^4.0.0",
6782
"cpx": "^1.5.0",
6883
"jest": "^24.8.0",
6984
"rimraf": "^2.6.3",
Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
1-
import * as React from 'react';
1+
import React from 'react';
22
import { storiesOf } from '@storybook/react';
33
import AutosizeInput from './';
44

55
const stories = storiesOf('components/Input', module);
66

7-
stories.add('Basic AutosizeInput', () => <AutosizeInput />);
7+
stories.add('Basic AutosizeInput', () => (
8+
<AutosizeInput value="I am a fancy input" />
9+
));
Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
1-
import * as React from 'react';
1+
import React from 'react';
22
import { storiesOf } from '@storybook/react';
33
import AutosizeTextArea from './';
44

55
const stories = storiesOf('components/Input', module);
6-
stories.add('Basic AutosizeTextArea', () => <AutosizeTextArea />);
6+
stories.add('Basic AutosizeTextArea', () => (
7+
<AutosizeTextArea value="I am a fancy textarea" />
8+
));

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import * as React from 'react';
1+
import React from 'react';
22
import { storiesOf } from '@storybook/react';
33
import { action } from '@storybook/addon-actions';
44
import { text, boolean } from '@storybook/addon-knobs';

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
import * as React from 'react';
1+
import React from 'react';
22
import { storiesOf } from '@storybook/react';
33
import { action } from '@storybook/addon-actions';
44
import { Checkbox } from './';
55

6-
const stories = storiesOf('components/Input', module);
6+
const stories = storiesOf('components/Checkbox', module);
77

88
stories
99
.add('Basic Checkbox', () => (

0 commit comments

Comments
 (0)