@storybook/react-native 7.6.10-alpha.4 → 7.6.11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@storybook/react-native",
3
- "version": "7.6.10-alpha.4",
3
+ "version": "7.6.11",
4
4
  "description": "A better way to develop React Native Components for your app",
5
5
  "keywords": [
6
6
  "react",
@@ -63,7 +63,7 @@
63
63
  "@storybook/preview-api": "^7.6.10",
64
64
  "@storybook/preview-web": "^7.6.10",
65
65
  "@storybook/react": "^7.6.10",
66
- "@storybook/react-native-theming": "^7.6.10-alpha.4",
66
+ "@storybook/react-native-theming": "^7.6.11",
67
67
  "chokidar": "^3.5.1",
68
68
  "commander": "^8.2.0",
69
69
  "dedent": "^1.5.1",
@@ -97,5 +97,5 @@
97
97
  "publishConfig": {
98
98
  "access": "public"
99
99
  },
100
- "gitHead": "43c2b5b932a0361178b010f90533069f14007677"
100
+ "gitHead": "5aed8e2d2ddc4fe76dd5f883aeb35e3fb48cae87"
101
101
  }
package/readme.md CHANGED
@@ -2,11 +2,13 @@
2
2
 
3
3
  With Storybook for React Native you can design and develop individual React Native components without running your app.
4
4
 
5
- This readme is for the 7.6 version, you can find older versions by browsing the different version tags.
5
+ This readme is for the 7.6.10 version, you can find the 6.5 docs [here](https://github.com/storybookjs/react-native/tree/v6.5-stable).
6
+
7
+ If you are migrating from 6.5 to 7.6 you can find the migration guide [here](https://github.com/storybookjs/react-native/blob/next/MIGRATION.md#from-version-65x-to-76x)
6
8
 
7
9
  For more information about storybook visit: [storybook.js.org](https://storybook.js.org)
8
10
 
9
- > NOTE: `@storybook/react-native` requires atleast 7.6.9, if you install other storybook core packages they should be `^7.6.9` or newer.
11
+ > NOTE: `@storybook/react-native` requires atleast 7.6.10, if you install other storybook core packages they should be `^7.6.10` or newer.
10
12
 
11
13
  If you want to help out or are just curious then check out the [project board](https://github.com/orgs/storybookjs/projects/12) to see the open issues.
12
14
 
@@ -35,12 +37,6 @@ For expo you can use this [template](https://github.com/dannyhw/expo-template-st
35
37
  ```sh
36
38
  # With NPM
37
39
  npx create-expo-app --template expo-template-storybook AwesomeStorybook
38
-
39
- # With Yarn
40
- yarn create expo-app --template expo-template-storybook AwesomeStorybook
41
-
42
- # With pnpm
43
- pnpm create expo-app --template expo-template-storybook AwesomeStorybook
44
40
  ```
45
41
 
46
42
  For react native cli you can use this [template](https://github.com/dannyhw/react-native-template-storybook)
@@ -54,12 +50,12 @@ npx react-native init MyApp --template react-native-template-storybook
54
50
  Run init to setup your project with all the dependencies and configuration files:
55
51
 
56
52
  ```sh
57
- npx sb@latest init --type react_native
53
+ npx storybook@latest init
58
54
  ```
59
55
 
60
- The only thing left to do is return Storybook's UI in your app entry point (such as `App.js`) like this:
56
+ The only thing left to do is return Storybook's UI in your app entry point (such as `App.tsx`) like this:
61
57
 
62
- ```jsx
58
+ ```tsx
63
59
  export { default } from './.storybook';
64
60
  ```
65
61
 
@@ -69,7 +65,7 @@ If you want to add everything yourself check out the the manual guide [here](htt
69
65
 
70
66
  #### Additional steps: Update your metro config
71
67
 
72
- We require the unstable_allowRequireContext transformer option to enable dynamic story imports based on the stories glob in `main.js`. We can also call the storybook generate function from the metro config to automatically generate the `storybook.requires.js` file when metro runs.
68
+ We require the unstable_allowRequireContext transformer option to enable dynamic story imports based on the stories glob in `main.ts`. We can also call the storybook generate function from the metro config to automatically generate the `storybook.requires.ts` file when metro runs.
73
69
 
74
70
  **Expo**
75
71
 
@@ -120,14 +116,19 @@ module.exports = {
120
116
 
121
117
  In storybook we use a syntax called CSF that looks like this:
122
118
 
123
- ```jsx
119
+ ```tsx
120
+ import type { Meta, StoryObj } from '@storybook/react';
124
121
  import { MyButton } from './Button';
125
122
 
126
- export default {
123
+ const meta = {
127
124
  component: MyButton,
128
- };
125
+ } satisfies Meta<typeof MyButton>;
129
126
 
130
- export const Basic = {
127
+ export default meta;
128
+
129
+ type Story = StoryObj<typeof meta>;
130
+
131
+ export const Basic: Story = {
131
132
  args: {
132
133
  text: 'Hello World',
133
134
  color: 'purple',
@@ -135,23 +136,29 @@ export const Basic = {
135
136
  };
136
137
  ```
137
138
 
138
- You should configure the path to your story files in the `main.js` config file from the `.storybook` folder.
139
+ You should configure the path to your story files in the `main.ts` config file from the `.storybook` folder.
139
140
 
140
- ```js
141
- // .storybook/main.js
141
+ ```ts
142
+ // .storybook/main.ts
143
+ import { StorybookConfig } from '@storybook/react-native';
142
144
 
143
- module.exports = {
145
+ const main: StorybookConfig = {
144
146
  stories: ['../components/**/*.stories.?(ts|tsx|js|jsx)'],
145
147
  addons: [],
146
148
  };
149
+
150
+ export default main;
147
151
  ```
148
152
 
149
153
  ### Decorators and Parameters
150
154
 
151
155
  For stories you can add decorators and parameters on the default export or on a specifc story.
152
156
 
153
- ```jsx
154
- export default {
157
+ ```tsx
158
+ import type { Meta } from '@storybook/react';
159
+ import { Button } from './Button';
160
+
161
+ const meta = {
155
162
  title: 'Button',
156
163
  component: Button,
157
164
  decorators: [
@@ -170,32 +177,40 @@ export default {
170
177
  ],
171
178
  },
172
179
  },
173
- };
180
+ } satisfies Meta<typeof Button>;
181
+
182
+ export default meta;
174
183
  ```
175
184
 
176
- For global decorators and parameters, you can add them to `preview.js` inside your `.storybook` folder.
185
+ For global decorators and parameters, you can add them to `preview.tsx` inside your `.storybook` folder.
177
186
 
178
- ```jsx
179
- // .storybook/preview.js
187
+ ```tsx
188
+ // .storybook/preview.tsx
189
+ import type { Preview } from '@storybook/react';
180
190
  import { withBackgrounds } from '@storybook/addon-ondevice-backgrounds';
181
- export const decorators = [
182
- withBackgrounds,
183
- (Story) => (
184
- <View style={{ flex: 1, color: 'blue' }}>
185
- <Story />
186
- </View>
187
- ),
188
- ];
189
- export const parameters = {
190
- backgrounds: {
191
- default: 'plain',
192
- values: [
193
- { name: 'plain', value: 'white' },
194
- { name: 'warm', value: 'hotpink' },
195
- { name: 'cool', value: 'deepskyblue' },
196
- ],
191
+
192
+ const preview: Preview = {
193
+ decorators: [
194
+ withBackgrounds,
195
+ (Story) => (
196
+ <View style={{ flex: 1, color: 'blue' }}>
197
+ <Story />
198
+ </View>
199
+ ),
200
+ ],
201
+ parameters: {
202
+ backgrounds: {
203
+ default: 'plain',
204
+ values: [
205
+ { name: 'plain', value: 'white' },
206
+ { name: 'warm', value: 'hotpink' },
207
+ { name: 'cool', value: 'deepskyblue' },
208
+ ],
209
+ },
197
210
  },
198
211
  };
212
+
213
+ export default preview;
199
214
  ```
200
215
 
201
216
  ## Addons
@@ -210,17 +225,23 @@ Currently the addons available are:
210
225
  - [`@storybook/addon-ondevice-notes`](https://storybook.js.org/addons/@storybook/addon-ondevice-notes): Add some markdown to your stories to help document their usage
211
226
  - [`@storybook/addon-ondevice-backgrounds`](https://storybook.js.org/addons/@storybook/addon-ondevice-backgrounds): change the background of storybook to compare the look of your component against different backgrounds
212
227
 
213
- Install each one you want to use and add them to the `main.js` addons list as follows:
228
+ Install each one you want to use and add them to the `main.ts` addons list as follows:
214
229
 
215
- ```js
216
- // .storybook/main.js
217
-
218
- addons: [
219
- '@storybook/addon-ondevice-notes',
220
- '@storybook/addon-ondevice-controls',
221
- '@storybook/addon-ondevice-backgrounds',
222
- '@storybook/addon-ondevice-actions',
223
- ],
230
+ ```ts
231
+ // .storybook/main.ts
232
+ import { StorybookConfig } from '@storybook/react-native';
233
+
234
+ const main: StorybookConfig = {
235
+ // ... rest of config
236
+ addons: [
237
+ '@storybook/addon-ondevice-notes',
238
+ '@storybook/addon-ondevice-controls',
239
+ '@storybook/addon-ondevice-backgrounds',
240
+ '@storybook/addon-ondevice-actions',
241
+ ],
242
+ };
243
+
244
+ export default main;
224
245
  ```
225
246
 
226
247
  ### Using the addons in your story
@@ -256,11 +277,6 @@ You can pass these parameters to getStorybookUI call in your storybook entry poi
256
277
  -- Disable KeyboardAvoidingView wrapping Storybook's view
257
278
  keyboardAvoidingViewVerticalOffset: Number (0)
258
279
  -- With shouldDisableKeyboardAvoidingView=true, this will set the keyboardverticaloffset (https://facebook.github.io/react-native/docs/keyboardavoidingview#keyboardverticaloffset) value for KeyboardAvoidingView wrapping Storybook's view
259
- storage: Object (undefined)
260
- -- {getItem: (key: string) => Promise<string | null>;setItem: (key: string, value: string) => Promise<void>;}
261
- -- Custom storage to be used instead of AsyncStorage
262
- shouldPersistSelection: Boolean (true)
263
- -- Stores last selected story in your devices storage.
264
280
  }
265
281
  ```
266
282
 
@@ -49,15 +49,13 @@ describe('loader', () => {
49
49
  it('should work for any supported file extension', () => {
50
50
  const main = getMain({ configPath: './scripts/mocks/file-extensions' });
51
51
  expect(main).toEqual({
52
- default: {
53
- stories: ['./FakeStory.stories.tsx'],
54
- addons: [
55
- '@storybook/addon-ondevice-notes',
56
- '@storybook/addon-ondevice-controls',
57
- '@storybook/addon-ondevice-backgrounds',
58
- '@storybook/addon-ondevice-actions',
59
- ],
60
- },
52
+ stories: ['./FakeStory.stories.tsx'],
53
+ addons: [
54
+ '@storybook/addon-ondevice-notes',
55
+ '@storybook/addon-ondevice-controls',
56
+ '@storybook/addon-ondevice-backgrounds',
57
+ '@storybook/addon-ondevice-actions',
58
+ ],
61
59
  });
62
60
  });
63
61
  });
@@ -8,7 +8,7 @@ import '@storybook/addon-ondevice-actions/register';
8
8
  const normalizedStories = [
9
9
  {
10
10
  titlePrefix: '',
11
- directory: './stories',
11
+ directory: './.storybook/stories',
12
12
  files: '**/*.stories.?(ts|tsx|js|jsx)',
13
13
  importPathMatcher:
14
14
  /^\.(?:(?:^|\/|(?:(?:(?!(?:^|\/)\.).)*?)\/)(?!\.)(?=.)[^/]*?\.stories\.(?:ts|tsx|js|jsx)?)$/,