storybook 1.0.0 → 5.1.11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (62) hide show
  1. package/README.md +2 -89
  2. package/index.js +3 -0
  3. package/package.json +16 -25
  4. package/.npmignore +0 -8
  5. package/CHANGELOG.md +0 -7
  6. package/bin/generate.js +0 -167
  7. package/docs/getstorybook.png +0 -0
  8. package/generators/.eslintrc.js +0 -12
  9. package/generators/METEOR/index.js +0 -81
  10. package/generators/METEOR/template/.stories/index.js +0 -20
  11. package/generators/METEOR/template/.storybook/addons.js +0 -2
  12. package/generators/METEOR/template/.storybook/config.js +0 -7
  13. package/generators/REACT/index.js +0 -25
  14. package/generators/REACT/template/.storybook/addons.js +0 -2
  15. package/generators/REACT/template/.storybook/config.js +0 -7
  16. package/generators/REACT/template/stories/index.js +0 -13
  17. package/generators/REACT_NATIVE/index.js +0 -53
  18. package/generators/REACT_NATIVE/template/storybook/addons.js +0 -2
  19. package/generators/REACT_NATIVE/template/storybook/index.android.js +0 -3
  20. package/generators/REACT_NATIVE/template/storybook/index.ios.js +0 -3
  21. package/generators/REACT_NATIVE/template/storybook/stories/Button/index.android.js +0 -19
  22. package/generators/REACT_NATIVE/template/storybook/stories/Button/index.ios.js +0 -17
  23. package/generators/REACT_NATIVE/template/storybook/stories/CenterView/index.js +0 -16
  24. package/generators/REACT_NATIVE/template/storybook/stories/CenterView/style.js +0 -8
  25. package/generators/REACT_NATIVE/template/storybook/stories/Welcome/index.js +0 -53
  26. package/generators/REACT_NATIVE/template/storybook/stories/index.js +0 -25
  27. package/generators/REACT_NATIVE/template/storybook/storybook.js +0 -15
  28. package/generators/REACT_NATIVE_SCRIPTS/index.js +0 -37
  29. package/generators/REACT_NATIVE_SCRIPTS/template/storybook/addons.js +0 -2
  30. package/generators/REACT_NATIVE_SCRIPTS/template/storybook/index.js +0 -11
  31. package/generators/REACT_NATIVE_SCRIPTS/template/storybook/stories/Button/index.android.js +0 -17
  32. package/generators/REACT_NATIVE_SCRIPTS/template/storybook/stories/Button/index.ios.js +0 -17
  33. package/generators/REACT_NATIVE_SCRIPTS/template/storybook/stories/CenterView/index.js +0 -12
  34. package/generators/REACT_NATIVE_SCRIPTS/template/storybook/stories/CenterView/style.js +0 -8
  35. package/generators/REACT_NATIVE_SCRIPTS/template/storybook/stories/Welcome/index.js +0 -52
  36. package/generators/REACT_NATIVE_SCRIPTS/template/storybook/stories/index.js +0 -25
  37. package/generators/REACT_SCRIPTS/index.js +0 -32
  38. package/generators/REACT_SCRIPTS/template/.storybook/addons.js +0 -2
  39. package/generators/REACT_SCRIPTS/template/.storybook/config.js +0 -7
  40. package/generators/REACT_SCRIPTS/template/src/stories/index.js +0 -13
  41. package/generators/SFC_VUE/index.js +0 -25
  42. package/generators/SFC_VUE/template/.storybook/addons.js +0 -2
  43. package/generators/SFC_VUE/template/.storybook/config.js +0 -7
  44. package/generators/SFC_VUE/template/src/stories/MyButton.vue +0 -28
  45. package/generators/SFC_VUE/template/src/stories/Welcome.vue +0 -120
  46. package/generators/SFC_VUE/template/src/stories/index.js +0 -24
  47. package/generators/UPDATE_PACKAGE_ORGANIZATIONS/index.js +0 -51
  48. package/generators/VUE/index.js +0 -25
  49. package/generators/VUE/template/.storybook/addons.js +0 -2
  50. package/generators/VUE/template/.storybook/config.js +0 -7
  51. package/generators/VUE/template/stories/MyButton.js +0 -29
  52. package/generators/VUE/template/stories/Welcome.js +0 -121
  53. package/generators/VUE/template/stories/index.js +0 -23
  54. package/generators/WEBPACK_REACT/index.js +0 -25
  55. package/generators/WEBPACK_REACT/template/.storybook/config.js +0 -7
  56. package/generators/WEBPACK_REACT/template/.storybook/webpack.config.js +0 -18
  57. package/generators/WEBPACK_REACT/template/stories/index.js +0 -13
  58. package/lib/detect.js +0 -87
  59. package/lib/has_yarn.js +0 -6
  60. package/lib/helpers.js +0 -104
  61. package/lib/project_types.js +0 -14
  62. package/yarn.lock +0 -2380
package/README.md CHANGED
@@ -1,90 +1,3 @@
1
- # Storybook (CLI)
1
+ # Storybook CLI
2
2
 
3
- [![Greenkeeper badge](https://badges.greenkeeper.io/storybooks/storybook.svg)](https://greenkeeper.io/)
4
- [![Build Status on CircleCI](https://circleci.com/gh/storybooks/storybook.svg?style=shield)](https://circleci.com/gh/storybooks/storybook)
5
- [![CodeFactor](https://www.codefactor.io/repository/github/storybooks/storybook/badge)](https://www.codefactor.io/repository/github/storybooks/storybook)
6
- [![Known Vulnerabilities](https://snyk.io/test/github/storybooks/storybook/8f36abfd6697e58cd76df3526b52e4b9dc894847/badge.svg)](https://snyk.io/test/github/storybooks/storybook/8f36abfd6697e58cd76df3526b52e4b9dc894847)
7
- [![BCH compliance](https://bettercodehub.com/edge/badge/storybooks/storybook)](https://bettercodehub.com/results/storybooks/storybook) [![codecov](https://codecov.io/gh/storybooks/storybook/branch/master/graph/badge.svg)](https://codecov.io/gh/storybooks/storybook)
8
- [![Storybook Slack](https://now-examples-slackin-nqnzoygycp.now.sh/badge.svg)](https://now-examples-slackin-nqnzoygycp.now.sh/)
9
- [![Backers on Open Collective](https://opencollective.com/storybook/backers/badge.svg)](#backers) [![Sponsors on Open Collective](https://opencollective.com/storybook/sponsors/badge.svg)](#sponsors)
10
-
11
- * * *
12
-
13
- This package provides a CLI for adding [Storybook](https://github.com/storybooks/storybook) to your project.
14
-
15
-
16
- ![Screenshot](docs/getstorybook.png)
17
-
18
- The quickest way to add Storybook to your project is to run this package via [npx](https://www.npmjs.com/package/npx):
19
-
20
- ```sh
21
- cd your-project-folder
22
- npx storybook
23
- ```
24
-
25
- That's all you've to do.
26
-
27
- If you don't use npx install this CLI globally.
28
-
29
- ```sh
30
- npm i -g storybook
31
- ```
32
-
33
- Then go to your project's folder and run:
34
-
35
- ```sh
36
- storybook
37
- ```
38
-
39
- * * *
40
-
41
- After that run Storybook by
42
-
43
- ```sh
44
- npm run storybook
45
- ```
46
-
47
- or
48
-
49
- ```sh
50
- yarn storybook
51
- ```
52
-
53
- For more information visit: [storybook.js.org](https://storybook.js.org)
54
-
55
- * * *
56
-
57
- ## [Yarn](https://github.com/yarnpkg/yarn) support
58
-
59
- It also supports yarn.
60
- If you have installed yarn in your system, it'll detect it and use `yarn` instead of `npm`.
61
-
62
- If you don't want to use `yarn` always you can use the `--use-npm` option like this:
63
-
64
- ```sh
65
- storybook --use-npm
66
- ```
67
-
68
- * * *
69
-
70
- ## [Flow](https://flow.org/) support
71
-
72
- It also supports flow files. By default, [jscodeshift](https://github.com/facebook/jscodeshift), the tool used to transform the source files, uses babel to read the files. To be able to transform any flow annotated file, you need to use the flow parser.
73
-
74
- ```sh
75
- storybook --parser flow
76
- ```
77
-
78
- ## Credits
79
-
80
- npm package: https://www.npmjs.com/package/storybook
81
-
82
- github repo: https://github.com/storybooks/storybook-package
83
-
84
- Storybook monorepo: https://github.com/storybooks/storybook
85
-
86
- in order to have the latest Storybook [CLI](https://github.com/storybooks/storybook/tree/master/lib/cli) install:
87
-
88
- ```sh
89
- npm i -g @storybook/cli
90
- ```
3
+ This is a wrapper for https://www.npmjs.com/package/@storybook/cli
package/index.js ADDED
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env node
2
+
3
+ require('@storybook/cli/bin/index');
package/package.json CHANGED
@@ -1,40 +1,31 @@
1
1
  {
2
2
  "name": "storybook",
3
- "version": "1.0.0",
4
- "description": "Storybook's CLI - easiest method of adding storybook to your projects",
3
+ "version": "5.1.11",
4
+ "description": "Storybook CLI",
5
5
  "keywords": [
6
- "cli",
7
- "generator",
8
6
  "storybook"
9
7
  ],
10
- "homepage": "https://github.com/storybooks/storybook-package/tree/master/lib/cli",
8
+ "homepage": "https://github.com/storybookjs/storybook/tree/master/lib/cli",
11
9
  "bugs": {
12
- "url": "https://github.com/storybooks/storybook-package/issues"
13
- },
14
- "license": "MIT",
15
- "author": "Storybook Team",
16
- "bin": {
17
- "storybook": "./bin/generate.js"
10
+ "url": "https://github.com/storybookjs/storybook/issues"
18
11
  },
19
12
  "repository": {
20
13
  "type": "git",
21
- "url": "https://github.com/storybooks/storybook-package.git"
14
+ "url": "https://github.com/storybookjs/storybook.git",
15
+ "directory": "lib/cli"
22
16
  },
17
+ "bin": {
18
+ "sb": "./index.js",
19
+ "storybook": "./index.js"
20
+ },
21
+ "license": "MIT",
23
22
  "scripts": {
24
- "postinstall": "opencollective postinstall --collective=storybook"
23
+ "prepare": "node ../../scripts/prepare.js"
25
24
  },
26
25
  "dependencies": {
27
- "@storybook/codemod": "^3.2.6",
28
- "chalk": "^2.1.0",
29
- "child-process-promise": "^2.2.1",
30
- "commander": "^2.11.0",
31
- "cross-spawn": "^5.0.1",
32
- "jscodeshift": "^0.3.30",
33
- "json5": "^0.5.1",
34
- "latest-version": "^3.1.0",
35
- "merge-dirs": "^0.2.1",
36
- "opencollective": "^1.0.3",
37
- "shelljs": "^0.7.8",
38
- "update-notifier": "^2.1.0"
26
+ "@storybook/cli": "*"
27
+ },
28
+ "publishConfig": {
29
+ "access": "public"
39
30
  }
40
31
  }
package/.npmignore DELETED
@@ -1,8 +0,0 @@
1
- /src/
2
- /example/
3
- /demo/
4
- /node_modules/
5
- /.storybook/
6
-
7
-
8
- .babelrc
package/CHANGELOG.md DELETED
@@ -1,7 +0,0 @@
1
- # Changelog
2
-
3
- ### v3.2.9
4
-
5
- 13-Sep-2017
6
-
7
- Forked from https://github.com/storybooks/storybook/tree/master/lib/cli
package/bin/generate.js DELETED
@@ -1,167 +0,0 @@
1
- #!/usr/bin/env node
2
-
3
- const updateNotifier = require('update-notifier');
4
- const program = require('commander');
5
- const chalk = require('chalk');
6
- const detect = require('../lib/detect');
7
- const hasYarn = require('../lib/has_yarn');
8
- const types = require('../lib/project_types');
9
- const commandLog = require('../lib/helpers').commandLog;
10
- const codeLog = require('../lib/helpers').codeLog;
11
- const paddedLog = require('../lib/helpers').paddedLog;
12
- const installDeps = require('../lib/helpers').installDeps;
13
-
14
- const logger = console;
15
-
16
- const pkg = require('../package.json');
17
-
18
- program
19
- .version(pkg.version)
20
- .option('-f --force', 'Forcely add storybook')
21
- .option('-N --use-npm', 'Use npm to install deps')
22
- .option('-p --parser <babel | babylon | flow>', 'jscodeshift parser')
23
- .parse(process.argv);
24
-
25
- const welcomeMessage = 'Storybook\'s CLI - The simplest way to add a storybook to your project.';
26
- logger.log(chalk.inverse(`\n ${welcomeMessage} \n`));
27
-
28
- const useYarn = Boolean(program.useNpm !== true) && hasYarn();
29
-
30
- const npmOptions = {
31
- useYarn,
32
- };
33
-
34
- const runStorybookCommand = useYarn ? 'yarn run storybook' : 'npm run storybook';
35
-
36
- // Update notify code.
37
- updateNotifier({
38
- pkg,
39
- updateCheckInterval: 1000 * 60 * 60, // every hour (we could increase this later on.)
40
- }).notify();
41
-
42
- let projectType;
43
-
44
- const done = commandLog('Detecting project type');
45
- try {
46
- projectType = detect({
47
- force: program.force,
48
- });
49
- } catch (ex) {
50
- done(ex.message);
51
- process.exit(1);
52
- }
53
- done();
54
-
55
- const end = () => {
56
- installDeps(npmOptions);
57
-
58
- logger.log('\nTo run your storybook, type:\n');
59
- codeLog([runStorybookCommand]);
60
- logger.log('\nFor more information visit:', chalk.cyan('https://storybook.js.org'));
61
-
62
- // Add a new line for the clear visibility.
63
- logger.log();
64
- };
65
-
66
- const CRNA_DISCUSSION =
67
- 'https://github.com/storybooks/storybook/blob/master/app/react-native/docs/manual-setup.md';
68
-
69
- switch (projectType) {
70
- case types.ALREADY_HAS_STORYBOOK:
71
- logger.log();
72
- paddedLog('There seems to be a storybook already available in this project.');
73
- paddedLog('Apply following command to force:\n');
74
- codeLog(['storybook -f']);
75
-
76
- // Add a new line for the clear visibility.
77
- logger.log();
78
- break;
79
-
80
- case types.UPDATE_PACKAGE_ORGANIZATIONS:
81
- // eslint-disable-next-line
82
- require('../generators/UPDATE_PACKAGE_ORGANIZATIONS')(program.parser)
83
- .then(() => null) // commmandLog doesn't like to see output
84
- .then(commandLog('Upgrading your project to the new storybook packages.'))
85
- .then(end);
86
- break;
87
-
88
- case types.REACT_SCRIPTS:
89
- // eslint-disable-next-line
90
- require('../generators/REACT_SCRIPTS')
91
- .then(commandLog('Adding storybook support to your "Create React App" based project'))
92
- .then(end);
93
- break;
94
-
95
- case types.REACT:
96
- // eslint-disable-next-line
97
- require('../generators/REACT')
98
- .then(commandLog('Adding storybook support to your "React" app'))
99
- .then(end);
100
- break;
101
-
102
- case types.REACT_NATIVE_SCRIPTS: {
103
- const app = chalk.bold('"./App.js"');
104
- // eslint-disable-next-line
105
- require('../generators/REACT_NATIVE_SCRIPTS')
106
- .then(commandLog('Adding storybook support to your "Create React Native App" app'))
107
- .then(end)
108
- .then(() => {
109
- logger.log(chalk.red('NOTE: CRNA app installation is not 100% automated.'));
110
- logger.log(`To quickly run storybook, replace contents of ${app} with:\n`);
111
- codeLog(["export default from './storybook';"]); // eslint-disable-line
112
- logger.log('\nFor a more complete discussion of options, see:\n');
113
- logger.log(chalk.cyan(CRNA_DISCUSSION));
114
- logger.log();
115
- });
116
- break;
117
- }
118
-
119
- case types.REACT_NATIVE:
120
- // eslint-disable-next-line
121
- require('../generators/REACT_NATIVE')
122
- .then(commandLog('Adding storybook support to your "React Native" app'))
123
- .then(end);
124
- break;
125
-
126
- case types.METEOR:
127
- // eslint-disable-next-line
128
- require('../generators/METEOR')
129
- .then(commandLog('Adding storybook support to your "Meteor" app'))
130
- .then(end);
131
- break;
132
-
133
- case types.WEBPACK_REACT:
134
- // eslint-disable-next-line
135
- require('../generators/WEBPACK_REACT')
136
- .then(commandLog('Adding storybook support to your "Webpack React" app'))
137
- .then(end);
138
- break;
139
-
140
- case types.REACT_PROJECT:
141
- // eslint-disable-next-line
142
- require('../generators/REACT')
143
- .then(commandLog('Adding storybook support to your "React" library'))
144
- .then(end);
145
- break;
146
-
147
- case types.SFC_VUE:
148
- // eslint-disable-next-line
149
- require('../generators/SFC_VUE')
150
- .then(commandLog('Adding storybook support to your "Single File Components Vue" app'))
151
- .then(end);
152
- break;
153
-
154
- case types.VUE:
155
- // eslint-disable-next-line
156
- require('../generators/VUE')
157
- .then(commandLog('Adding storybook support to your "Vue" app'))
158
- .then(end);
159
- break;
160
-
161
- default:
162
- paddedLog(`Unsupported Project type. (code: ${projectType})`);
163
- paddedLog('Visit https://storybook.js.org for more information.');
164
-
165
- // Add a new line for the clear visibility.
166
- logger.log();
167
- }
Binary file
@@ -1,12 +0,0 @@
1
- const ignore = 0;
2
-
3
- module.exports = {
4
- overrides: {
5
- files: '*/template/**',
6
- rules: {
7
- 'import/no-unresolved': ignore,
8
- 'import/no-extraneous-dependencies': ignore,
9
- 'global-require': ignore,
10
- },
11
- },
12
- };
@@ -1,81 +0,0 @@
1
- const mergeDirs = require('merge-dirs').default;
2
- const helpers = require('../../lib/helpers');
3
- const path = require('path');
4
- const fs = require('fs');
5
- const JSON5 = require('json5');
6
- const latestVersion = require('latest-version');
7
-
8
- module.exports = Promise.all([
9
- latestVersion('@storybook/react'),
10
- latestVersion('@storybook/addon-actions'),
11
- latestVersion('@storybook/addon-links'),
12
- latestVersion('react'),
13
- latestVersion('react-dom'),
14
- latestVersion('babel-preset-env'),
15
- latestVersion('babel-preset-react'),
16
- latestVersion('babel-preset-stage-1'),
17
- latestVersion('babel-root-slash-import'),
18
- ]).then(
19
- (
20
- [
21
- storybookVersion,
22
- actionsVersion,
23
- linksVersion,
24
- reactVersion,
25
- reactDomVersion,
26
- presetEnvVersion,
27
- presetReactVersion,
28
- presetStage1Version,
29
- rootSlashImportVersion,
30
- ]
31
- ) => {
32
- mergeDirs(path.resolve(__dirname, 'template/'), '.', 'overwrite');
33
-
34
- const packageJson = helpers.getPackageJson();
35
- packageJson.devDependencies = packageJson.devDependencies || {};
36
- packageJson.scripts = packageJson.scripts || {};
37
- packageJson.dependencies = packageJson.dependencies || {};
38
-
39
- // create or update .babelrc
40
- let babelrc = null;
41
- if (fs.existsSync('.babelrc')) {
42
- const babelrcContent = fs.readFileSync('.babelrc', 'utf8');
43
- babelrc = JSON5.parse(babelrcContent);
44
- babelrc.plugins = babelrc.plugins || [];
45
-
46
- if (babelrc.plugins.indexOf('babel-root-slash-import') < 0) {
47
- babelrc.plugins.push('babel-root-slash-import');
48
- packageJson.devDependencies['babel-root-slash-import'] = `^${rootSlashImportVersion}`;
49
- }
50
- } else {
51
- babelrc = {
52
- presets: ['env', 'react', 'stage-1'],
53
- plugins: ['babel-root-slash-import'],
54
- };
55
-
56
- packageJson.devDependencies['babel-preset-env'] = `^${presetEnvVersion}`;
57
- packageJson.devDependencies['babel-preset-react'] = `^${presetReactVersion}`;
58
- packageJson.devDependencies['babel-preset-stage-1'] = `^${presetStage1Version}`;
59
- packageJson.devDependencies['babel-root-slash-import'] = `^${rootSlashImportVersion}`;
60
- }
61
-
62
- fs.writeFileSync('.babelrc', JSON.stringify(babelrc, null, 2), 'utf8');
63
-
64
- // write the new package.json.
65
- packageJson.devDependencies['@storybook/react'] = `^${storybookVersion}`;
66
- packageJson.devDependencies['@storybook/addon-actions'] = `^${actionsVersion}`;
67
- packageJson.devDependencies['@storybook/addon-links'] = `^${linksVersion}`;
68
- packageJson.scripts.storybook = 'start-storybook -p 6006';
69
- packageJson.scripts['build-storybook'] = 'build-storybook';
70
-
71
- // add react packages.
72
- if (!packageJson.dependencies.react) {
73
- packageJson.dependencies.react = `^${reactVersion}`;
74
- }
75
- if (!packageJson.dependencies['react-dom']) {
76
- packageJson.dependencies['react-dom'] = `^${reactDomVersion}`;
77
- }
78
-
79
- helpers.writePackageJson(packageJson);
80
- }
81
- );
@@ -1,20 +0,0 @@
1
- import React from 'react';
2
-
3
- import { storiesOf } from '@storybook/react';
4
- import { action } from '@storybook/addon-actions';
5
- import { linkTo } from '@storybook/addon-links';
6
-
7
- import { Button, Welcome } from '@storybook/react/demo';
8
-
9
- storiesOf('Welcome', module)
10
- .add('to Storybook', () => (
11
- <Welcome showApp={linkTo('Button')}/>
12
- ));
13
-
14
- storiesOf('Button', module)
15
- .add('with text', () => (
16
- <Button onClick={action('clicked')}>Hello Button</Button>
17
- ))
18
- .add('with some emoji', () => (
19
- <Button onClick={action('clicked')}>😀 😎 👍 💯</Button>
20
- ));
@@ -1,2 +0,0 @@
1
- import '@storybook/addon-actions/register';
2
- import '@storybook/addon-links/register';
@@ -1,7 +0,0 @@
1
- import { configure } from '@storybook/react';
2
-
3
- function loadStories() {
4
- require('../.stories');
5
- }
6
-
7
- configure(loadStories, module);
@@ -1,25 +0,0 @@
1
- const mergeDirs = require('merge-dirs').default;
2
- const helpers = require('../../lib/helpers');
3
- const path = require('path');
4
- const latestVersion = require('latest-version');
5
-
6
- module.exports = Promise.all([
7
- latestVersion('@storybook/react'),
8
- latestVersion('@storybook/addon-actions'),
9
- latestVersion('@storybook/addon-links'),
10
- ]).then(([storybookVersion, actionsVersion, linksVersion]) => {
11
- mergeDirs(path.resolve(__dirname, 'template/'), '.', 'overwrite');
12
-
13
- const packageJson = helpers.getPackageJson();
14
-
15
- packageJson.devDependencies = packageJson.devDependencies || {};
16
- packageJson.devDependencies['@storybook/react'] = `^${storybookVersion}`;
17
- packageJson.devDependencies['@storybook/addon-actions'] = `^${actionsVersion}`;
18
- packageJson.devDependencies['@storybook/addon-links'] = `^${linksVersion}`;
19
-
20
- packageJson.scripts = packageJson.scripts || {};
21
- packageJson.scripts.storybook = 'start-storybook -p 6006';
22
- packageJson.scripts['build-storybook'] = 'build-storybook';
23
-
24
- helpers.writePackageJson(packageJson);
25
- });
@@ -1,2 +0,0 @@
1
- import '@storybook/addon-actions/register';
2
- import '@storybook/addon-links/register';
@@ -1,7 +0,0 @@
1
- import { configure } from '@storybook/react';
2
-
3
- function loadStories() {
4
- require('../stories');
5
- }
6
-
7
- configure(loadStories, module);
@@ -1,13 +0,0 @@
1
- import React from 'react';
2
-
3
- import { storiesOf } from '@storybook/react';
4
- import { action } from '@storybook/addon-actions';
5
- import { linkTo } from '@storybook/addon-links';
6
-
7
- import { Button, Welcome } from '@storybook/react/demo';
8
-
9
- storiesOf('Welcome', module).add('to Storybook', () => <Welcome showApp={linkTo('Button')} />);
10
-
11
- storiesOf('Button', module)
12
- .add('with text', () => <Button onClick={action('clicked')}>Hello Button</Button>)
13
- .add('with some emoji', () => <Button onClick={action('clicked')}>😀 😎 👍 💯</Button>);
@@ -1,53 +0,0 @@
1
- const mergeDirs = require('merge-dirs').default;
2
- const path = require('path');
3
- const shell = require('shelljs');
4
- const latestVersion = require('latest-version');
5
- const chalk = require('chalk');
6
- const helpers = require('../../lib/helpers');
7
-
8
- module.exports = Promise.all([
9
- latestVersion('@storybook/react-native'),
10
- latestVersion('@storybook/addon-actions'),
11
- latestVersion('@storybook/addon-links'),
12
- latestVersion('prop-types'),
13
- ]).then(([storybookVersion, actionsVersion, linksVersion, propTypesVersion]) => {
14
- // copy all files from the template directory to project directory
15
- mergeDirs(path.resolve(__dirname, 'template/'), '.', 'overwrite');
16
-
17
- // set correct project name on entry files if possible
18
- const dirname = shell.ls('-d', 'ios/*.xcodeproj').stdout;
19
- const projectName =
20
- dirname && dirname.slice('ios/'.length, dirname.length - '.xcodeproj'.length - 1);
21
- if (projectName) {
22
- shell.sed('-i', '%APP_NAME%', projectName, 'storybook/storybook.js');
23
- } else {
24
- helpers.paddedLog(
25
- chalk.red(
26
- 'ERR: Could not determine project name, to fix: https://github.com/storybooks/storybook/issues/1277'
27
- )
28
- );
29
- }
30
-
31
- const packageJson = helpers.getPackageJson();
32
-
33
- packageJson.dependencies = packageJson.dependencies || {};
34
- packageJson.devDependencies = packageJson.devDependencies || {};
35
-
36
- packageJson.devDependencies['@storybook/react-native'] = `^${storybookVersion}`;
37
- packageJson.devDependencies['@storybook/addon-actions'] = `^${actionsVersion}`;
38
- packageJson.devDependencies['@storybook/addon-links'] = `^${linksVersion}`;
39
-
40
- if (!packageJson.dependencies['react-dom'] && !packageJson.devDependencies['react-dom']) {
41
- const reactVersion = packageJson.dependencies.react;
42
- packageJson.devDependencies['react-dom'] = reactVersion;
43
- }
44
-
45
- if (!packageJson.dependencies['prop-types'] && !packageJson.devDependencies['prop-types']) {
46
- packageJson.devDependencies['prop-types'] = `^${propTypesVersion}`;
47
- }
48
-
49
- packageJson.scripts = packageJson.scripts || {};
50
- packageJson.scripts.storybook = 'storybook start -p 7007';
51
-
52
- helpers.writePackageJson(packageJson);
53
- });
@@ -1,2 +0,0 @@
1
- import '@storybook/addon-actions/register';
2
- import '@storybook/addon-links/register';
@@ -1,3 +0,0 @@
1
- import StorybookUI from './storybook';
2
-
3
- export default StorybookUI;
@@ -1,3 +0,0 @@
1
- import StorybookUI from './storybook';
2
-
3
- export default StorybookUI;
@@ -1,19 +0,0 @@
1
- import React from 'react';
2
- import PropTypes from 'prop-types';
3
- import { TouchableNativeFeedback } from 'react-native';
4
-
5
- export default function Button(props) {
6
- return (
7
- <TouchableNativeFeedback onPress={props.onPress}>{props.children}</TouchableNativeFeedback>
8
- );
9
- }
10
-
11
- Button.defaultProps = {
12
- children: null,
13
- onPress: () => {},
14
- };
15
-
16
- Button.propTypes = {
17
- children: PropTypes.node,
18
- onPress: PropTypes.func,
19
- };
@@ -1,17 +0,0 @@
1
- import React from 'react';
2
- import PropTypes from 'prop-types';
3
- import { TouchableHighlight } from 'react-native';
4
-
5
- export default function Button(props) {
6
- return <TouchableHighlight onPress={props.onPress}>{props.children}</TouchableHighlight>;
7
- }
8
-
9
- Button.defaultProps = {
10
- children: null,
11
- onPress: () => {},
12
- };
13
-
14
- Button.propTypes = {
15
- children: PropTypes.node,
16
- onPress: PropTypes.func,
17
- };
@@ -1,16 +0,0 @@
1
- import React from 'react';
2
- import PropTypes from 'prop-types';
3
- import { View } from 'react-native';
4
- import style from './style';
5
-
6
- export default function CenterView(props) {
7
- return <View style={style.main}>{props.children}</View>;
8
- }
9
-
10
- CenterView.defaultProps = {
11
- children: null,
12
- };
13
-
14
- CenterView.propTypes = {
15
- children: PropTypes.node,
16
- };
@@ -1,8 +0,0 @@
1
- export default {
2
- main: {
3
- flex: 1,
4
- justifyContent: 'center',
5
- alignItems: 'center',
6
- backgroundColor: '#F5FCFF',
7
- },
8
- };