-
Notifications
You must be signed in to change notification settings - Fork 317
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
chore(ui-react-native): Add storybook #2464
Merged
ioanabrooks
merged 8 commits into
in-app-messaging/main
from
in-app-messaging/add-storybook-example-app
Aug 16, 2022
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
8a47573
chore(ui-react-native): Add storybook
ioanabrooks b61250f
Fix dependency issues and add readme
ioanabrooks d48c840
Address feedback
ioanabrooks d1eb9ba
Merge branch 'in-app-messaging/main' into in-app-messaging/add-storyb…
ioanabrooks be1aceb
Fix e2e test
ioanabrooks 27303be
Update examples/react-native/README.md
ioanabrooks 3e585ce
Update examples/react-native/README.md
ioanabrooks 3847965
Update examples/react-native/index.js
ioanabrooks File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,12 +4,12 @@ This directory contains example apps for each framework we support. | |
|
||
## Examples Development | ||
|
||
1. Create or Update an example at [`examples/{next,vue,angular}/...`](examples) | ||
1. Create or Update an example at [`examples/{next,react-native,vue,angular}/...`](examples) | ||
|
||
For your `aws-exports.js`, you can [reference an existing or create a new environment](../environments/README.md). | ||
|
||
1. Run your example at monorep root: `yarn {react,vue,angular}-example dev` | ||
1. Run your example at monorep root: `yarn {react,react-native,vue,angular}-example dev` | ||
1. Visit your example (e.g. <http://localhost:3000/ui/components/authenticator/sign-up-with-username>) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Wonder if we should update this line as well since it is specific to browser frameworks |
||
1. Make changes to [`@aws-amplify/ui-{react,vue,angular}`](packages) & save. | ||
1. Make changes to [`@aws-amplify/ui-{react,react-native,vue,angular}`](packages) & save. | ||
|
||
Examples should automatically hot-reload your changes in the example. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -59,3 +59,6 @@ buck-out/ | |
# Ruby / CocoaPods | ||
/ios/Pods/ | ||
/vendor/bundle/ | ||
|
||
# Storybook | ||
/storybook/storyLoader.js |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,11 @@ | ||
import { AppRegistry } from 'react-native'; | ||
import App from './App'; | ||
import StorybookUIRoot from './storybook'; | ||
import { name as appName } from './app.json'; | ||
|
||
AppRegistry.registerComponent(appName, () => App); | ||
//TODO: replace with env var | ||
const isStorybook = false; | ||
|
||
AppRegistry.registerComponent(appName, () => | ||
isStorybook ? StorybookUIRoot : App | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
import '@storybook/addon-actions/register'; | ||
import '@storybook/addon-links/register'; | ||
import '@storybook/addon-knobs/register'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import { getStorybookUI, configure } from '@storybook/react-native'; | ||
import { Platform } from 'react-native'; | ||
|
||
import { loadStories } from './storyLoader'; | ||
|
||
// import stories | ||
configure(() => { | ||
loadStories(); | ||
}, module); | ||
|
||
// Refer to https://github.com/storybookjs/react-native/tree/master/app/react-native#getstorybookui-options | ||
// To find allowed options for getStorybookUI | ||
const StorybookUIRoot = getStorybookUI({ | ||
/* | ||
* Get React Native server IP if hostname is `localhost` | ||
* On Android emulator, the IP of host is `10.0.2.2` | ||
*/ | ||
host: Platform.OS === 'android' ? '10.0.2.2' : '0.0.0.0', | ||
}); | ||
|
||
export default StorybookUIRoot; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
import '@storybook/addon-ondevice-actions/register'; | ||
import '@storybook/addon-ondevice-knobs/register'; |
19 changes: 19 additions & 0 deletions
19
examples/react-native/storybook/stories/Button.stories.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import React from 'react'; | ||
import { Text } from 'react-native'; | ||
import { action } from '@storybook/addon-actions'; | ||
import { text } from '@storybook/addon-knobs'; | ||
import { storiesOf } from '@storybook/react-native'; | ||
import { Button } from '@aws-amplify/ui-react-native/dist/primitives'; | ||
|
||
storiesOf('Button', module) | ||
.add('with text', () => ( | ||
<Button onPress={action('clicked-text')}> | ||
<Text>{text('Button text', 'Hello Button')}</Text> | ||
</Button> | ||
)) | ||
.add('with emoji', () => ( | ||
<Button onPress={action('clicked-emoji')}> | ||
<Text>😀 😎 👍 💯</Text> | ||
</Button> | ||
)) | ||
.add('disabled', () => <Button disabled>Disabled Button</Button>); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👀