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

Integrate crna-kitchen-sink examples app into the monorepo #6125

Merged
merged 7 commits into from
Mar 17, 2019
Merged
Show file tree
Hide file tree
Changes from 6 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
2 changes: 1 addition & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ jobs:
at: .
- run:
name: Bootstrap
command: yarn bootstrap --reactnativeapp
command: yarn bootstrap --core
- run:
name: Run React-Native-App example
command: |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ object OpenSourceProjects_Storybook_NativeSmokeTests : BuildType({
set -e -x
yarn
yarn bootstrap --reactnativeapp
yarn bootstrap --core
cd examples-native/crna-kitchen-sink
yarn storybook --smoke-test
""".trimIndent()
Expand Down
2 changes: 2 additions & 0 deletions addons/knobs/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,8 @@ export const withKnobs = makeDecorator({
},
});

export * from './shared';

if (module && module.hot && module.hot.decline) {
module.hot.decline();
}
2 changes: 1 addition & 1 deletion addons/ondevice-knobs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
"react-native-switch": "^1.5.0"
},
"peerDependencies": {
"@storybook/addon-knobs": "5.1.0-alpha.6",
"@storybook/addon-knobs": "5.1.0-alpha.7",
"react": "*",
"react-native": "*"
},
Expand Down
2 changes: 1 addition & 1 deletion addons/ondevice-knobs/src/panel.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import React from 'react';
import { View, Text, TouchableOpacity } from 'react-native';
import PropTypes from 'prop-types';
import { SELECT_STORY, FORCE_RE_RENDER } from '@storybook/core-events';
import { SET, SET_OPTIONS, RESET, CHANGE, CLICK } from '@storybook/addon-knobs/events';
import { SET, SET_OPTIONS, RESET, CHANGE, CLICK } from '@storybook/addon-knobs';
import GroupTabs from './GroupTabs';
import PropForm from './PropForm';

Expand Down
1 change: 0 additions & 1 deletion app/react-native/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
"prepare": "node ../../scripts/prepare.js"
},
"dependencies": {
"@react-native-community/async-storage": "^1.2.1",
"@storybook/addons": "5.1.0-alpha.7",
"@storybook/channel-websocket": "5.1.0-alpha.7",
"@storybook/channels": "5.1.0-alpha.7",
Expand Down
8 changes: 6 additions & 2 deletions app/react-native/src/preview/index.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/* eslint-disable no-underscore-dangle */

import React from 'react';
import AsyncStorage from '@react-native-community/async-storage';
import { AsyncStorage } from 'react-native';
import getHost from 'rn-host-detect';
import addons from '@storybook/addons';
import Events from '@storybook/core-events';
Expand Down Expand Up @@ -135,9 +135,12 @@ export default class Preview {

_sendSetStories() {
const channel = addons.getChannel();
const stories = this._stories.dumpStoryBook();
const stories = this._stories.extract();
channel.emit(Events.SET_STORIES, { stories });
channel.emit(Events.STORIES_CONFIGURED);
if (this.currentStory) {
channel.emit(Events.SET_CURRENT_STORY, this.currentStory);
}
}

_sendGetCurrentStory() {
Expand Down Expand Up @@ -196,6 +199,7 @@ export default class Preview {
}

_selectStory(story) {
this.currentStory = story;
const channel = addons.getChannel();
channel.emit(Events.SELECT_STORY, story);
}
Expand Down
11 changes: 3 additions & 8 deletions examples-native/crna-kitchen-sink/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,6 @@ This project was bootstrapped wit [Expo](https://github.com/expo/expo-cli) and s

## Getting started

1. Install dependencies: `yarn install`
2. Delete node_modules/@storybook
3. Run the storybook server: `yarn storybook`
4. Run the app: `yarn start`

## Iterate on app/react-native

Changes to the yarn workspace do not currently reflect live in this app. To iterate on the react native pieces of storybook, use `scripts/update-crna-kitchen-sink`.
1. Install dependencies: `yarn install` at the root
2. Run the storybook server: `yarn storybook`
3. Run the app: `yarn start`
5 changes: 4 additions & 1 deletion examples-native/crna-kitchen-sink/app.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@
"barStyle": "light-content",
"backgroundColor": "#C2185B"
},
"assetBundlePatterns": ["**/*"]
"assetBundlePatterns": ["**/*"],
"packagerOpts": {
"config": "metro.config.js"
}
}
}
22 changes: 22 additions & 0 deletions examples-native/crna-kitchen-sink/metro.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
const path = require('path');
const blacklist = require('metro-config/src/defaults/blacklist');

module.exports = {
watchFolders: [
// The monorepo
path.resolve(__dirname, '../..'),
],
resolver: {
blacklistRE: blacklist([
// exclude react-native modules outside of this package
/app\/.*\/node_modules\/react-native\/.*/,
/node_modules\/.*\/node_modules\/react-native\/.*/,
// duplicate packages in server mocks. We don't need them so it's safe to exclude.
/__mocks__\/.*/,
]),
extraNodeModules: {
// resolve react-native to this package's node_modules
'react-native': path.resolve(__dirname, 'node_modules/react-native'),
},
},
};
36 changes: 13 additions & 23 deletions examples-native/crna-kitchen-sink/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,34 +24,24 @@
"devDependencies": {
"@babel/core": "^7.2.2",
"@babel/plugin-transform-react-jsx-source": "^7.2.0",
"@storybook/addon-actions": "file:../../packs/storybook-addon-actions.tgz",
"@storybook/addon-knobs": "file:../../packs/storybook-addon-knobs.tgz",
"@storybook/addon-links": "file:../../packs/storybook-addon-links.tgz",
"@storybook/addon-options": "file:../../packs/storybook-addon-options.tgz",
"@storybook/addons": "file:../../packs/storybook-addons.tgz",
"@storybook/channel-postmessage": "file:../../packs/storybook-channel-postmessage.tgz",
"@storybook/channel-websocket": "file:../../packs/storybook-channel-websocket.tgz",
"@storybook/channels": "file:../../packs/storybook-channels.tgz",
"@storybook/client-api": "file:../../packs/storybook-client-api.tgz",
"@storybook/client-logger": "file:../../packs/storybook-client-logger.tgz",
"@storybook/components": "file:../../packs/storybook-components.tgz",
"@storybook/router": "file:../../packs/storybook-router.tgz",
"@storybook/core": "file:../../lib/core",
"@storybook/core-events": "file:../../packs/storybook-core-events.tgz",
"@storybook/node-logger": "file:../../packs/storybook-node-logger.tgz",
"@storybook/react-native": "file:../../packs/storybook-react-native.tgz",
"@storybook/react-native-server": "file:../../packs/storybook-react-native-server.tgz",
"@storybook/addon-notes": "file:../../packs/storybook-addon-notes.tgz",
"@storybook/addon-ondevice-backgrounds": "file:../../packs/storybook-addon-ondevice-backgrounds.tgz",
"@storybook/addon-ondevice-knobs": "file:../../packs/storybook-addon-ondevice-knobs.tgz",
"@storybook/addon-ondevice-notes": "file:../../packs/storybook-addon-ondevice-notes.tgz",
"@storybook/ui": "file:../../packs/storybook-ui.tgz",
"@storybook/theming": "file:../../packs/storybook-theming.tgz",
"@storybook/addon-knobs": "5.1.0-alpha.7",
"@storybook/addon-ondevice-knobs": "^5.1.0-alpha.7",
"@storybook/addon-ondevice-notes": "5.1.0-alpha.7",
"@storybook/addons": "5.1.0-alpha.7",
"@storybook/react-native": "5.1.0-alpha.7",
"core-js": "^2.5.7",
"babel-loader": "^8.0.4",
"babel-preset-expo": "^5.0.0",
"babel-plugin-module-resolver": "^3.2.0",
"jest-expo": "^32.0.0",
"schedule": "^0.4.0",
"react-test-renderer": "16.5.1"
},
"workspaces": {
"nohoist": [
"react-native/**",
"**/app/react-native*",
"expo"
]
}
}
Loading