Skip to content

Commit

Permalink
Merge branch 'master' into ts-distribution
Browse files Browse the repository at this point in the history
  • Loading branch information
igor-dv authored Jan 31, 2018
2 parents 1362d49 + 5eca2b3 commit ad905a2
Show file tree
Hide file tree
Showing 29 changed files with 169 additions and 49 deletions.
1 change: 1 addition & 0 deletions .babelrc
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"presets": ["env", "stage-0", "react"],
"plugins": [
"babel-plugin-macros",
["transform-runtime", {
"polyfill": false,
"regenerator": true
Expand Down
4 changes: 2 additions & 2 deletions addons/notes/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
"description": "Write notes for your Storybook stories.",
"keywords": [
"addon",
"storybook",
"notes"
"notes",
"storybook"
],
"license": "MIT",
"main": "dist/index.js",
Expand Down
4 changes: 2 additions & 2 deletions addons/storyshots/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@
},
"scripts": {
"build-storybook": "build-storybook",
"example": "jest storyshot.test",
"prepare": "node ../../scripts/prepare.js",
"storybook": "start-storybook -p 6006",
"example": "jest storyshot.test"
"storybook": "start-storybook -p 6006"
},
"dependencies": {
"@storybook/channels": "^3.4.0-alpha.6",
Expand Down
4 changes: 2 additions & 2 deletions addons/viewport/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@
"name": "@storybook/addon-viewport",
"version": "3.4.0-alpha.6",
"description": "Storybook addon to change the viewport size to mobile",
"main": "register.js",
"keywords": [
"storybook"
],
"license": "MIT",
"main": "register.js",
"scripts": {
"prepare": "node ../../scripts/prepare.js"
},
"license": "MIT",
"dependencies": {
"@storybook/components": "^3.4.0-alpha.6",
"global": "^4.3.2",
Expand Down
1 change: 1 addition & 0 deletions app/angular/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
"autoprefixer": "^7.2.5",
"babel-core": "^6.26.0",
"babel-loader": "^7.0.0",
"babel-plugin-macros": "^2.0.0",
"babel-plugin-react-docgen": "^1.8.2",
"babel-preset-env": "^1.6.0",
"babel-preset-react": "^6.24.1",
Expand Down
37 changes: 21 additions & 16 deletions app/angular/src/server/config/babel.js
Original file line number Diff line number Diff line change
@@ -1,24 +1,29 @@
/**
* Copyright (c) 2015-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*/

const findCacheDir = require('find-cache-dir');

module.exports = {
// Don't try to find .babelrc because we want to force this configuration.
babelrc: false,
// This is a feature of `babel-loader` for webpack (not Babel itself).
// It enables a cache directory for faster-rebuilds
// `find-cache-dir` will create the cache directory under the node_modules directory.
cacheDirectory: findCacheDir({ name: 'react-storybook' }),
presets: [
require.resolve('babel-preset-env'),
[
require.resolve('babel-preset-env'),
{
targets: {
browsers: ['last 2 versions', 'safari >= 7'],
},
modules: process.env.NODE_ENV === 'test' ? 'commonjs' : false,
},
],
require.resolve('babel-preset-stage-0'),
require.resolve('babel-preset-react'),
],
plugins: [
require.resolve('babel-plugin-macros'),
require.resolve('babel-plugin-transform-regenerator'),
[
require.resolve('babel-plugin-transform-runtime'),
{
helpers: true,
polyfill: true,
regenerator: true,
},
],
],
};
1 change: 1 addition & 0 deletions app/polymer/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
"autoprefixer": "^7.1.6",
"babel-core": "^6.26.0",
"babel-loader": "^7.1.2",
"babel-plugin-macros": "^2.0.0",
"babel-plugin-react-docgen": "^1.8.2",
"babel-plugin-transform-regenerator": "^6.26.0",
"babel-plugin-transform-runtime": "^6.23.0",
Expand Down
1 change: 1 addition & 0 deletions app/polymer/src/server/config/babel.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ module.exports = {
require.resolve('babel-preset-react'),
],
plugins: [
require.resolve('babel-plugin-macros'),
require.resolve('babel-plugin-transform-regenerator'),
[
require.resolve('babel-plugin-transform-runtime'),
Expand Down
1 change: 1 addition & 0 deletions app/react-native/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
"@storybook/ui": "^3.4.0-alpha.6",
"autoprefixer": "^7.2.5",
"babel-loader": "^7.1.2",
"babel-plugin-macros": "^2.0.0",
"babel-plugin-syntax-async-functions": "^6.13.0",
"babel-plugin-syntax-trailing-function-commas": "^6.22.0",
"babel-plugin-transform-class-properties": "^6.24.1",
Expand Down
1 change: 1 addition & 0 deletions app/react-native/src/server/config/babel.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ module.exports = {
require.resolve('babel-preset-react'),
],
plugins: [
require.resolve('babel-plugin-macros'),
require.resolve('babel-plugin-syntax-trailing-function-commas'),
require.resolve('babel-plugin-syntax-async-functions'),
require.resolve('babel-plugin-transform-class-properties'),
Expand Down
1 change: 1 addition & 0 deletions app/react/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
"airbnb-js-shims": "^1.4.1",
"autoprefixer": "^7.2.5",
"babel-loader": "^7.1.2",
"babel-plugin-macros": "^2.0.0",
"babel-plugin-react-docgen": "^1.8.2",
"babel-plugin-transform-regenerator": "^6.26.0",
"babel-plugin-transform-runtime": "^6.23.0",
Expand Down
1 change: 1 addition & 0 deletions app/react/src/server/config/babel.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ module.exports = {
require.resolve('babel-preset-react'),
],
plugins: [
require.resolve('babel-plugin-macros'),
require.resolve('babel-plugin-transform-regenerator'),
[
require.resolve('babel-plugin-transform-runtime'),
Expand Down
1 change: 1 addition & 0 deletions app/vue/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
"airbnb-js-shims": "^1.4.1",
"autoprefixer": "^7.2.5",
"babel-loader": "^7.1.2",
"babel-plugin-macros": "^2.0.0",
"babel-plugin-react-docgen": "^1.8.2",
"babel-plugin-transform-regenerator": "^6.26.0",
"babel-plugin-transform-runtime": "^6.23.0",
Expand Down
1 change: 1 addition & 0 deletions app/vue/src/server/config/babel.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ module.exports = {
require.resolve('babel-preset-react'),
],
plugins: [
require.resolve('babel-plugin-macros'),
require.resolve('babel-plugin-transform-regenerator'),
[
require.resolve('babel-plugin-transform-runtime'),
Expand Down
20 changes: 20 additions & 0 deletions docs/src/pages/basics/writing-stories/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,26 @@ storiesOf('My App/Buttons/Emoji', module)
));
```

## Generating nesting path based on __dirname

The name is just a javascript string, by using a template literal, you can easily interpolate data.

One example would be to use `base` from [`paths.macro`](https://github.com/storybooks/paths.macro):
```js
import React from 'react';
import base from 'paths.macro';

import { storiesOf } from '@storybook/react';

import BaseButton from '../components/BaseButton';

storiesOf(`Other|${base}/Dirname Example`, module)
.add('story 1', () => <BaseButton label="Story 1" />)
.add('story 2', () => <BaseButton label="Story 2" />);
```

*This uses [babel-plugin-macros](https://github.com/kentcdodds/babel-plugin-macros)*.

## Run multiple storybooks

You can run multiple storybooks for different kinds of stories (or components). To do that, you can create different NPM scripts to start different stories. See:
Expand Down
10 changes: 5 additions & 5 deletions examples/angular-cli/package.json
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
{
"name": "angular-cli",
"version": "3.4.0-alpha.6",
"private": true,
"license": "MIT",
"scripts": {
"ng": "ng",
"start": "ng serve",
"build": "ng build",
"test": "ng test",
"build-storybook": "build-storybook -s src",
"e2e": "ng e2e",
"ng": "ng",
"start": "ng serve",
"storybook": "start-storybook -p 9008 -s src/assets",
"build-storybook": "build-storybook -s src"
"test": "ng test"
},
"private": true,
"dependencies": {
"@angular/animations": "^5.2.2",
"@angular/common": "^5.2.2",
Expand Down
4 changes: 2 additions & 2 deletions examples/cra-kitchen-sink/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"name": "cra-kitchen-sink",
"version": "3.4.0-alpha.6",
"private": true,
"scripts": {
"build": "react-scripts build",
"build-storybook": "build-storybook -s public",
Expand Down Expand Up @@ -41,6 +42,5 @@
"enzyme-to-json": "^3.3.1",
"jest": "^22.1.4",
"react-scripts": "^1.1.0"
},
"private": true
}
}
1 change: 1 addition & 0 deletions examples/official-storybook/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@ This storybook includes stories for:
- `@storybook/components` - reusable UI components for addon authors
- `@storybook/ui` - the UI of storybook itself
- `@storybook/addon-*` - various addons.
- `@storybook/other-*` - various examples.
9 changes: 5 additions & 4 deletions examples/official-storybook/package.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
{
"name": "official-storybook",
"version": "3.4.0-alpha.6",
"private": true,
"scripts": {
"build-storybook": "build-storybook -c ./",
"storybook": "start-storybook -p 9010 -c ./",
"chromatic": "chromatic test --storybook-addon --exit-zero-on-changes --app-code ab7m45tp9p",
"generate-addon-jest-testresults": "jest --config=tests/addon-jest.config.json --json --outputFile=stories/addon-jest.testresults.json",
"image-snapshots": "yarn run build-storybook && jest --projects=./image-snapshots"
"image-snapshots": "yarn run build-storybook && jest --projects=./image-snapshots",
"storybook": "start-storybook -p 9010 -c ./"
},
"devDependencies": {
"@storybook/addon-a11y": "^3.4.0-alpha.6",
Expand All @@ -33,11 +34,11 @@
"format-json": "^1.0.3",
"global": "^4.3.2",
"jest": "^21.2.1",
"paths.macro": "^2.0.2",
"prop-types": "^15.6.0",
"react": "^16.2.0",
"react-chromatic": "^0.7.9",
"react-dom": "^16.2.0",
"uuid": "^3.2.1"
},
"private": true
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`Storyshots Other|/stories//Dirname Example story 1 1`] = `
<button>
Story 1
</button>
`;

exports[`Storyshots Other|/stories//Dirname Example story 2 1`] = `
<button>
Story 2
</button>
`;
10 changes: 10 additions & 0 deletions examples/official-storybook/stories/other-dirname.stories.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import React from 'react';
import base from 'paths.macro';

import { storiesOf } from '@storybook/react';

import BaseButton from '../components/BaseButton';

storiesOf(`Other|${base}/Dirname Example`, module)
.add('story 1', () => <BaseButton label="Story 1" />)
.add('story 2', () => <BaseButton label="Story 2" />);
2 changes: 1 addition & 1 deletion examples/polymer-cli/package.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
{
"name": "polymer-cli",
"version": "3.4.0-alpha.6",
"private": true,
"scripts": {
"start": "webpack-dev-server",
"storybook": "start-storybook -p 9001 -c .storybook"
},
"private": true,
"dependencies": {
"@polymer/polymer": "^2.4.0",
"@storybook/addon-actions": "^3.4.0-alpha.6",
Expand Down
20 changes: 10 additions & 10 deletions examples/vue-kitchen-sink/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,16 @@
"name": "vue-example",
"version": "3.4.0-alpha.6",
"private": true,
"scripts": {
"build": "cross-env NODE_ENV=production webpack --progress --hide-modules",
"build-storybook": "build-storybook -s public",
"dev": "cross-env NODE_ENV=development webpack-dev-server --open --hot",
"storybook": "start-storybook -p 9009 -s public"
},
"dependencies": {
"vue": "^2.5.13",
"vuex": "^3.0.0"
},
"devDependencies": {
"@storybook/addon-actions": "^3.4.0-alpha.6",
"@storybook/addon-centered": "^3.4.0-alpha.6",
Expand All @@ -25,15 +35,5 @@
"vue-template-compiler": "^2.5.13",
"webpack": "^3.10.0",
"webpack-dev-server": "^2.11.1"
},
"dependencies": {
"vue": "^2.5.13",
"vuex": "^3.0.0"
},
"scripts": {
"dev": "cross-env NODE_ENV=development webpack-dev-server --open --hot",
"build": "cross-env NODE_ENV=production webpack --progress --hide-modules",
"storybook": "start-storybook -p 9009 -s public",
"build-storybook": "build-storybook -s public"
}
}
4 changes: 2 additions & 2 deletions lib/cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@
"url": "https://github.com/storybooks/storybook.git"
},
"scripts": {
"test-latest-cra": "cd test && ./test_latest_cra.sh",
"test": "cd test && ./run_tests.sh"
"test": "cd test && ./run_tests.sh",
"test-latest-cra": "cd test && ./test_latest_cra.sh"
},
"dependencies": {
"@storybook/codemod": "^3.4.0-alpha.6",
Expand Down
4 changes: 2 additions & 2 deletions lib/components/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@
"url": "https://github.com/storybooks/storybook.git"
},
"scripts": {
"build-storybook": "build-storybook",
"prepare": "node ../../scripts/prepare.js",
"storybook": "start-storybook -p 6006",
"build-storybook": "build-storybook"
"storybook": "start-storybook -p 6006"
},
"dependencies": {
"glamor": "^2.20.40",
Expand Down
2 changes: 1 addition & 1 deletion lib/ui/src/modules/ui/libs/hierarchy.js
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ export function resolveStoryHierarchy(storyName = '', hierarchySeparator) {
return [storyName];
}

return storyName.split(new RegExp(hierarchySeparator));
return storyName.split(new RegExp(hierarchySeparator)).filter(segment => !!segment);
}

export function prepareStoriesForHierarchy(stories, hierarchySeparator, hierarchyRootSeparator) {
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@
"babel-plugin-transform-runtime": "^6.23.0",
"babel-polyfill": "^6.26.0",
"babel-preset-env": "^1.6.1",
"babel-plugin-macros": "^2.0.0",
"babel-preset-react": "^6.24.1",
"babel-preset-stage-0": "^6.24.1",
"chalk": "^2.3.0",
Expand Down
Empty file modified scripts/netlify-build.sh
100644 → 100755
Empty file.
Loading

0 comments on commit ad905a2

Please sign in to comment.