File tree Expand file tree Collapse file tree 9 files changed +146
-3
lines changed
hackathon/offline-with-legend-state Expand file tree Collapse file tree 9 files changed +146
-3
lines changed Original file line number Diff line number Diff line change
1
+ import AsyncStorage from '@react-native-async-storage/async-storage' ;
2
+ import { view } from './storybook.requires' ;
3
+
4
+ const StorybookUIRoot = view . getStorybookUI ( {
5
+ storage : {
6
+ getItem : AsyncStorage . getItem ,
7
+ setItem : AsyncStorage . setItem ,
8
+ } ,
9
+ } ) ;
10
+
11
+ export default StorybookUIRoot ;
Original file line number Diff line number Diff line change
1
+ import { StorybookConfig } from '@storybook/react-native' ;
2
+
3
+ const main : StorybookConfig = {
4
+ stories : [ './stories/**/*.stories.?(ts|tsx|js|jsx)' ] ,
5
+ addons : [ '@storybook/addon-ondevice-controls' , '@storybook/addon-ondevice-actions' ] ,
6
+ } ;
7
+
8
+ export default main ;
Original file line number Diff line number Diff line change
1
+ import type { Preview } from '@storybook/react' ;
2
+
3
+ const preview : Preview = {
4
+ parameters : {
5
+ controls : {
6
+ matchers : {
7
+ color : / ( b a c k g r o u n d | c o l o r ) $ / i,
8
+ date : / D a t e $ / ,
9
+ } ,
10
+ } ,
11
+ } ,
12
+ } ;
13
+
14
+ export default preview ;
Original file line number Diff line number Diff line change
1
+ import { View } from 'react-native' ;
2
+ import type { Meta , StoryObj } from '@storybook/react' ;
3
+ import { MyButton } from './Button' ;
4
+
5
+ const MyButtonMeta : Meta < typeof MyButton > = {
6
+ title : 'MyButton' ,
7
+ component : MyButton ,
8
+ argTypes : {
9
+ onPress : { action : 'pressed the button' } ,
10
+ } ,
11
+ args : {
12
+ text : 'Hello world' ,
13
+ } ,
14
+ decorators : [
15
+ ( Story ) => (
16
+ < View style = { { alignItems : 'center' , justifyContent : 'center' , flex : 1 } } >
17
+ < Story />
18
+ </ View >
19
+ ) ,
20
+ ] ,
21
+ } ;
22
+
23
+ export default MyButtonMeta ;
24
+
25
+ export const Basic : StoryObj < typeof MyButton > = { } ;
26
+
27
+ export const AnotherExample : StoryObj < typeof MyButton > = {
28
+ args : {
29
+ text : 'Another example' ,
30
+ } ,
31
+ } ;
Original file line number Diff line number Diff line change
1
+ import { TouchableOpacity , Text , StyleSheet } from 'react-native' ;
2
+
3
+ export type MyButtonProps = {
4
+ onPress : ( ) => void ;
5
+ text : string ;
6
+ } ;
7
+
8
+ export const MyButton = ( { onPress, text } : MyButtonProps ) => {
9
+ return (
10
+ < TouchableOpacity style = { styles . container } onPress = { onPress } activeOpacity = { 0.8 } >
11
+ < Text style = { styles . text } > { text } </ Text >
12
+ </ TouchableOpacity >
13
+ ) ;
14
+ } ;
15
+
16
+ const styles = StyleSheet . create ( {
17
+ container : {
18
+ paddingHorizontal : 16 ,
19
+ paddingVertical : 8 ,
20
+ backgroundColor : 'purple' ,
21
+ borderRadius : 8 ,
22
+ } ,
23
+ text : { color : 'white' } ,
24
+ } ) ;
Original file line number Diff line number Diff line change
1
+ /* do not change this file, it is auto generated by storybook. */
2
+
3
+ import { start } from '@storybook/react-native' ;
4
+
5
+ import '@storybook/addon-ondevice-controls/register' ;
6
+ import '@storybook/addon-ondevice-actions/register' ;
7
+
8
+ const normalizedStories = [
9
+ {
10
+ titlePrefix : '' ,
11
+ directory : './.storybook/stories' ,
12
+ files : '**/*.stories.?(ts|tsx|js|jsx)' ,
13
+ importPathMatcher :
14
+ / ^ \. (?: (?: ^ | \/ | (?: (?: (? ! (?: ^ | \/ ) \. ) .) * ?) \/ ) (? ! \. ) (? = .) [ ^ / ] * ?\. s t o r i e s \. (?: t s | t s x | j s | j s x ) ? ) $ / ,
15
+ // @ts -ignore
16
+ req : require . context (
17
+ './stories' ,
18
+ true ,
19
+ / ^ \. (?: (?: ^ | \/ | (?: (?: (? ! (?: ^ | \/ ) \. ) .) * ?) \/ ) (? ! \. ) (? = .) [ ^ / ] * ?\. s t o r i e s \. (?: t s | t s x | j s | j s x ) ? ) $ /
20
+ ) ,
21
+ } ,
22
+ ] ;
23
+
24
+ // @ts -ignore
25
+ global . STORIES = normalizedStories ;
26
+
27
+ export const view = start ( {
28
+ annotations : [
29
+ require ( './preview' ) ,
30
+ require ( '@storybook/react-native/dist/preview' ) ,
31
+ require ( '@storybook/addon-actions/preview' ) ,
32
+ ] ,
33
+ storyEntries : normalizedStories ,
34
+ } ) ;
Original file line number Diff line number Diff line change @@ -41,4 +41,5 @@ const styles = StyleSheet.create({
41
41
} ,
42
42
} ) ;
43
43
44
- export default App ;
44
+ // export default App;
45
+ export { default } from "./.storybook" ;
Original file line number Diff line number Diff line change
1
+ // Learn more https://docs.expo.io/guides/customizing-metro
2
+ const { getDefaultConfig } = require ( 'expo/metro-config' ) ;
3
+
4
+ /** @type {import('expo/metro-config').MetroConfig } */
5
+ const config = getDefaultConfig ( __dirname ) ;
6
+
7
+ config . transformer . unstable_allowRequireContext = true ;
8
+
9
+ module . exports = config ;
Original file line number Diff line number Diff line change 6
6
"start" : " expo start" ,
7
7
"android" : " expo start --android" ,
8
8
"ios" : " expo start --ios" ,
9
- "web" : " expo start --web"
9
+ "web" : " expo start --web" ,
10
+ "storybook-generate" : " sb-rn-get-stories" ,
11
+ "storybook" : " sb-rn-get-stories && expo start"
10
12
},
11
13
"dependencies" : {
12
14
"@legendapp/state" : " ^2.1.8" ,
17
19
},
18
20
"devDependencies" : {
19
21
"@babel/core" : " ^7.20.0" ,
22
+ "@react-native-async-storage/async-storage" : " ^1.22.3" ,
23
+ "@react-native-community/datetimepicker" : " ^7.6.2" ,
24
+ "@react-native-community/slider" : " ^4.5.0" ,
25
+ "@storybook/addon-ondevice-actions" : " ^7.6.15" ,
26
+ "@storybook/addon-ondevice-controls" : " ^7.6.15" ,
27
+ "@storybook/react-native" : " ^7.6.15" ,
20
28
"@types/react" : " ~18.2.45" ,
29
+ "babel-loader" : " ^8.3.0" ,
30
+ "react-dom" : " 18.2.0" ,
31
+ "react-native-safe-area-context" : " ^4.9.0" ,
21
32
"typescript" : " ^5.1.3"
22
33
},
23
34
"private" : true
24
- }
35
+ }
You can’t perform that action at this time.
0 commit comments