Skip to content

Commit

Permalink
feat: cli init template
Browse files Browse the repository at this point in the history
  • Loading branch information
dannyhw committed Feb 12, 2023
1 parent a19f756 commit 660515c
Show file tree
Hide file tree
Showing 6 changed files with 72 additions and 1 deletion.
3 changes: 2 additions & 1 deletion app/react-native/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@
"README.md",
"*.js",
"*.d.ts",
"scripts/*"
"scripts/*",
"template/**/*"
],
"scripts": {
"preprepare": "rm -rf dist/",
Expand Down
7 changes: 7 additions & 0 deletions app/react-native/template/cli/index.js
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;
4 changes: 4 additions & 0 deletions app/react-native/template/cli/main.js
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'],
};
8 changes: 8 additions & 0 deletions app/react-native/template/cli/preview.js
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$/,
},
},
};
20 changes: 20 additions & 0 deletions app/react-native/template/cli/stories/Button/Button.js
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' },
});
31 changes: 31 additions & 0 deletions app/react-native/template/cli/stories/Button/Button.stories.js
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',
},
};

0 comments on commit 660515c

Please sign in to comment.