-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
`yarn storybook` will launch the application in storybook mode. This will allow you to view all the components in the application and their various states. `yarn prestorybook` is launched automatically before `yarn storybook` and will update the storybook.requires.js file with the latest components. This is required to ensure that the storybook is up to date. # Known issues: - Bad handling of file creation during Metro watch (storybook.requires isn't rebuilt) - Should implement a path alias to the Storybook folder
- Loading branch information
Showing
11 changed files
with
2,692 additions
and
32 deletions.
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 |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import React from 'react' | ||
import { View } from 'react-native' | ||
|
||
export const StoryWrapper = (Story: () => JSX.Element): JSX.Element => ( | ||
<View style={{ alignItems: 'center', justifyContent: 'center', flex: 1 }}> | ||
<Story /> | ||
</View> | ||
) |
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,5 @@ | ||
module.exports = { | ||
stories: ['../src/**/*.stories.?(ts|tsx|js|jsx)'], | ||
addons: ['@storybook/addon-ondevice-controls', '@storybook/addon-ondevice-actions'], | ||
}; | ||
|
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,8 @@ | ||
export const parameters = { | ||
controls: { | ||
matchers: { | ||
color: /(background|color)$/i, | ||
date: /Date$/, | ||
}, | ||
}, | ||
}; |
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,12 @@ | ||
# Storybook usage | ||
|
||
`yarn storybook` will launch the application in storybook mode. This will allow you to view all the components in the application and their various states. | ||
|
||
`yarn prestorybook` is launched automatically before `yarn storybook` and will update the storybook.requires.js file with the latest components. This is required to ensure that the storybook is up to date. | ||
|
||
Refer to the [Storybook documentation](https://github.com/storybookjs/react-native) for more information. | ||
|
||
# Known issues: | ||
- Bad handling of file creation during Metro watch (storybook.requires isn't rebuilt) | ||
|
||
- Should implement a path alias to the Storybook folder |
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,54 @@ | ||
/* do not change this file, it is auto generated by storybook. */ | ||
|
||
import { | ||
configure, | ||
addDecorator, | ||
addParameters, | ||
addArgsEnhancer, | ||
clearDecorators, | ||
} from "@storybook/react-native"; | ||
|
||
global.STORIES = [ | ||
{ | ||
titlePrefix: "", | ||
directory: "./src", | ||
files: "**/*.stories.?(ts|tsx|js|jsx)", | ||
importPathMatcher: | ||
"^\\.[\\\\/](?:src(?:\\/(?!\\.)(?:(?:(?!(?:^|\\/)\\.).)*?)\\/|\\/|$)(?!\\.)(?=.)[^/]*?\\.stories\\.(?:ts|tsx|js|jsx)?)$", | ||
}, | ||
]; | ||
|
||
import "@storybook/addon-ondevice-controls/register"; | ||
import "@storybook/addon-ondevice-actions/register"; | ||
|
||
import { argsEnhancers } from "@storybook/addon-actions/dist/modern/preset/addArgs"; | ||
|
||
import { decorators, parameters } from "./preview"; | ||
|
||
if (decorators) { | ||
if (__DEV__) { | ||
// stops the warning from showing on every HMR | ||
require("react-native").LogBox.ignoreLogs([ | ||
"`clearDecorators` is deprecated and will be removed in Storybook 7.0", | ||
]); | ||
} | ||
// workaround for global decorators getting infinitely applied on HMR, see https://github.com/storybookjs/react-native/issues/185 | ||
clearDecorators(); | ||
decorators.forEach((decorator) => addDecorator(decorator)); | ||
} | ||
|
||
if (parameters) { | ||
addParameters(parameters); | ||
} | ||
|
||
try { | ||
argsEnhancers.forEach((enhancer) => addArgsEnhancer(enhancer)); | ||
} catch {} | ||
|
||
const getStories = () => { | ||
return { | ||
"./src/ui/Typography/Typography.stories.tsx": require("../src/ui/Typography/Typography.stories.tsx"), | ||
}; | ||
}; | ||
|
||
configure(getStories, module, false); |
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,12 @@ | ||
import { getStorybookUI } from '@storybook/react-native' | ||
import { AppRegistry } from 'react-native' | ||
import RNBootSplash from 'react-native-bootsplash' | ||
|
||
import './.storybook/storybook.requires' | ||
import { name as appName } from './src/app.json' | ||
|
||
const StorybookUIRoot = getStorybookUI({}) | ||
|
||
AppRegistry.registerComponent(appName, () => StorybookUIRoot) | ||
|
||
RNBootSplash.hide({ fade: true }) // Have to manually hide the splash screen for now. Might cause issues when hot reloading. |
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
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,16 @@ | ||
import React from 'react' | ||
|
||
import { StoryWrapper } from '/../.storybook/StoryWrapper' | ||
import { Typography } from '/ui/Typography/index' | ||
|
||
const TypographyMeta = { | ||
title: 'Typography', | ||
component: Typography, | ||
decorators: [StoryWrapper] | ||
} | ||
|
||
export default TypographyMeta | ||
|
||
export const Default = (): JSX.Element => ( | ||
<Typography>Default Typography</Typography> | ||
) |
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.