-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This comment helped resolve it: storybookjs/react-native#405 (comment)
- Loading branch information
1 parent
0c0a701
commit eb58744
Showing
11 changed files
with
3,105 additions
and
110 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,7 @@ | ||
import { getStorybookUI } from '@storybook/react-native'; | ||
|
||
import './storybook.requires'; | ||
|
||
const StorybookUIRoot = getStorybookUI({}); | ||
|
||
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,4 @@ | ||
module.exports = { | ||
stories: ['./stories/**/*.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,20 @@ | ||
import React from 'react'; | ||
import { TouchableOpacity, Text, StyleSheet } from 'react-native'; | ||
|
||
export const MyButton = ({ onPress, text }) => { | ||
return ( | ||
<TouchableOpacity style={styles.container} onPress={onPress} activeOpacity={0.8}> | ||
<Text style={styles.text}>{text}</Text> | ||
</TouchableOpacity> | ||
); | ||
}; | ||
|
||
const styles = StyleSheet.create({ | ||
container: { | ||
paddingHorizontal: 16, | ||
paddingVertical: 8, | ||
backgroundColor: 'purple', | ||
borderRadius: 8, | ||
}, | ||
text: { color: 'white' }, | ||
}); |
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,31 @@ | ||
import React from 'react'; | ||
import { View } from 'react-native'; | ||
import { MyButton } from './Button'; | ||
|
||
const MyButtonMeta = { | ||
title: 'MyButton', | ||
component: MyButton, | ||
argTypes: { | ||
onPress: { action: 'pressed the button' }, | ||
}, | ||
args: { | ||
text: 'Hello world', | ||
}, | ||
decorators: [ | ||
(Story) => ( | ||
<View style={{ alignItems: 'center', justifyContent: 'center', flex: 1 }}> | ||
<Story /> | ||
</View> | ||
), | ||
], | ||
}; | ||
|
||
export default MyButtonMeta; | ||
|
||
export const Basic = {}; | ||
|
||
export const AnotherExample = { | ||
args: { | ||
text: 'Another 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 |
---|---|---|
@@ -0,0 +1,58 @@ | ||
/* do not change this file, it is auto generated by storybook. */ | ||
|
||
import { | ||
configure, | ||
addDecorator, | ||
addParameters, | ||
addArgsEnhancer, | ||
clearDecorators, | ||
} from '@storybook/react-native'; | ||
|
||
import '@storybook/addon-ondevice-controls/register'; | ||
import '@storybook/addon-ondevice-actions/register'; | ||
|
||
import { argsEnhancers } from '@storybook/addon-actions/dist/modern/preset/addArgs'; | ||
|
||
// eslint-disable-next-line import/named | ||
import { decorators, parameters } from './preview'; | ||
|
||
global.STORIES = [ | ||
{ | ||
titlePrefix: '', | ||
directory: './.storybook/stories', | ||
files: '**/*.stories.?(ts|tsx|js|jsx)', | ||
importPathMatcher: | ||
'^\\.[\\\\/](?:\\.storybook\\/stories(?:\\/(?!\\.)(?:(?:(?!(?:^|\\/)\\.).)*?)\\/|\\/|$)(?!\\.)(?=.)[^/]*?\\.stories\\.(?:ts|tsx|js|jsx)?)$', | ||
}, | ||
]; | ||
|
||
if (decorators) { | ||
// eslint-disable-next-line no-undef | ||
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 { | ||
/* workaround for occasional crash */ | ||
} | ||
|
||
const getStories = () => { | ||
return { | ||
'./.storybook/stories/Button/Button.stories.js': require('./stories/Button/Button.stories.js'), | ||
}; | ||
}; | ||
|
||
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
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
Oops, something went wrong.