-
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.
- Loading branch information
1 parent
a6c2819
commit fca425a
Showing
14 changed files
with
1,898 additions
and
25 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
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,11 @@ | ||
import AsyncStorage from '@react-native-async-storage/async-storage'; | ||
import { view } from './storybook.requires'; | ||
|
||
const StorybookUIRoot = view.getStorybookUI({ | ||
storage: { | ||
getItem: AsyncStorage.getItem, | ||
setItem: AsyncStorage.setItem, | ||
}, | ||
}); | ||
|
||
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,8 @@ | ||
import { StorybookConfig } from '@storybook/react-native'; | ||
|
||
const main: StorybookConfig = { | ||
stories: ['../src/components/**/*.stories.?(ts|tsx|js|jsx)'], | ||
addons: ['@storybook/addon-ondevice-controls', '@storybook/addon-ondevice-actions'], | ||
}; | ||
|
||
export default main; |
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,24 @@ | ||
import type { Preview } from '@storybook/react'; | ||
import React from 'react'; | ||
|
||
import { AppProviders } from '../src/providers/AppProviders'; | ||
|
||
const preview: Preview = { | ||
parameters: { | ||
controls: { | ||
matchers: { | ||
color: /(background|color)$/i, | ||
date: /Date$/, | ||
}, | ||
}, | ||
}, | ||
decorators: [ | ||
(Story) => ( | ||
<AppProviders> | ||
<Story /> | ||
</AppProviders> | ||
), | ||
], | ||
}; | ||
|
||
export default preview; |
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,61 @@ | ||
/* do not change this file, it is auto generated by storybook. */ | ||
|
||
import { | ||
start, | ||
prepareStories, | ||
getProjectAnnotations, | ||
} from "@storybook/react-native"; | ||
|
||
import "@storybook/addon-ondevice-controls/register"; | ||
import "@storybook/addon-ondevice-actions/register"; | ||
|
||
const normalizedStories = [ | ||
{ | ||
titlePrefix: "", | ||
directory: "./src/components", | ||
files: "**/*.stories.?(ts|tsx|js|jsx)", | ||
importPathMatcher: | ||
/^\.(?:(?:^|\/|(?:(?:(?!(?:^|\/)\.).)*?)\/)(?!\.)(?=.)[^/]*?\.stories\.(?:ts|tsx|js|jsx)?)$/, | ||
// @ts-ignore | ||
req: require.context( | ||
"../src/components", | ||
true, | ||
/^\.(?:(?:^|\/|(?:(?:(?!(?:^|\/)\.).)*?)\/)(?!\.)(?=.)[^/]*?\.stories\.(?:ts|tsx|js|jsx)?)$/ | ||
), | ||
}, | ||
]; | ||
|
||
declare global { | ||
var view: ReturnType<typeof start>; | ||
var STORIES: typeof normalizedStories; | ||
} | ||
|
||
const annotations = [ | ||
require("./preview"), | ||
require("@storybook/react-native/dist/preview"), | ||
require("@storybook/addon-actions/preview"), | ||
]; | ||
|
||
global.STORIES = normalizedStories; | ||
|
||
// @ts-ignore | ||
module?.hot?.accept?.(); | ||
|
||
if (!global.view) { | ||
global.view = start({ | ||
annotations, | ||
storyEntries: normalizedStories, | ||
}); | ||
} else { | ||
const { importMap } = prepareStories({ storyEntries: normalizedStories }); | ||
|
||
global.view._preview.onStoriesChanged({ | ||
importFn: async (importPath: string) => importMap[importPath], | ||
}); | ||
|
||
global.view._preview.onGetProjectAnnotationsChanged({ | ||
getProjectAnnotations: getProjectAnnotations(global.view, annotations), | ||
}); | ||
} | ||
|
||
export const view = global.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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,23 @@ | ||
const { getDefaultConfig, mergeConfig } = require('@react-native/metro-config'); | ||
const { generate } = require('@storybook/react-native/scripts/generate'); | ||
|
||
const path = require('path'); | ||
|
||
generate({ | ||
configPath: path.resolve(__dirname, './.storybook'), | ||
}); | ||
|
||
/** | ||
* Metro configuration | ||
* https://facebook.github.io/metro/docs/configuration | ||
* | ||
* @type {import('metro-config').MetroConfig} | ||
*/ | ||
const config = {}; | ||
const config = { | ||
transformer: { | ||
// Required by Storybook | ||
unstable_allowRequireContext: true, | ||
}, | ||
}; | ||
|
||
module.exports = mergeConfig(getDefaultConfig(__dirname), config); |
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,34 @@ | ||
import type { Meta, StoryObj } from '@storybook/react'; | ||
import { View } from 'react-native'; | ||
|
||
import Button from './Button'; | ||
|
||
const ButtonMeta: Meta<typeof Button> = { | ||
title: 'Button', | ||
component: Button, | ||
argTypes: { | ||
onPress: { action: 'pressed the button' }, | ||
}, | ||
args: { | ||
label: 'Hello world', | ||
disabled: false, | ||
}, | ||
decorators: [ | ||
(Story) => ( | ||
// eslint-disable-next-line react-native/no-inline-styles | ||
<View style={{ alignItems: 'center', justifyContent: 'center', flex: 1 }}> | ||
<Story /> | ||
</View> | ||
), | ||
], | ||
}; | ||
|
||
export default ButtonMeta; | ||
|
||
export const Basic: StoryObj<typeof Button> = {}; | ||
|
||
export const AnotherExample: StoryObj<typeof Button> = { | ||
args: { | ||
label: '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,27 @@ | ||
import type { Meta, StoryObj } from '@storybook/react'; | ||
import { View } from 'react-native'; | ||
|
||
import { Translation } from './Translation'; | ||
|
||
const TranslationMeta: Meta<typeof Translation> = { | ||
title: 'Translation', | ||
component: Translation, | ||
args: { | ||
id: 'home.helloWorld', | ||
values: { | ||
name: 'Joe', | ||
}, | ||
}, | ||
decorators: [ | ||
(Story) => ( | ||
// eslint-disable-next-line react-native/no-inline-styles | ||
<View style={{ alignItems: 'center', justifyContent: 'center', flex: 1 }}> | ||
<Story /> | ||
</View> | ||
), | ||
], | ||
}; | ||
|
||
export default TranslationMeta; | ||
|
||
export const Basic: StoryObj<typeof Translation> = {}; |
Oops, something went wrong.