Skip to content

Commit e2a8a47

Browse files
authored
Merge pull request #224 from flexbox/bump/sptorybook-7
fix: 🐛 migrate from storybook-6.5 to 7
2 parents 6bef9b7 + 8e62a0c commit e2a8a47

File tree

8 files changed

+547
-121
lines changed

8 files changed

+547
-121
lines changed
Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,12 @@
1-
import { getStorybookUI } from '@storybook/react-native';
2-
import './storybook.requires';
1+
// .storybook/index.tsx
2+
import { view } from './storybook.requires';
3+
import AsyncStorage from '@react-native-async-storage/async-storage';
34

4-
const StorybookUIRoot = getStorybookUI({
5-
// options go here
5+
const StorybookUIRoot = view.getStorybookUI({
6+
storage: {
7+
getItem: AsyncStorage.getItem,
8+
setItem: AsyncStorage.setItem,
9+
},
610
});
711

8-
export default StorybookUIRoot
12+
export default StorybookUIRoot;

hackathon/spacecraft/.storybook/main.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,10 @@ module.exports = {
33
"../src/components/**/*.stories.?(ts|tsx|js|jsx)",
44
"../src/screens/**/*.stories.?(ts|tsx|js|jsx)",
55
],
6-
addons: ["@storybook/addon-ondevice-controls"],
6+
addons: [
7+
'@storybook/addon-ondevice-notes',
8+
'@storybook/addon-ondevice-controls',
9+
'@storybook/addon-ondevice-backgrounds',
10+
'@storybook/addon-ondevice-actions',
11+
],
712
};

hackathon/spacecraft/.storybook/storybook.requires.js

Lines changed: 0 additions & 58 deletions
This file was deleted.
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
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-notes/register";
6+
import "@storybook/addon-ondevice-controls/register";
7+
import "@storybook/addon-ondevice-backgrounds/register";
8+
import "@storybook/addon-ondevice-actions/register";
9+
10+
const normalizedStories = [
11+
{
12+
titlePrefix: "",
13+
directory: "./src/components",
14+
files: "**/*.stories.?(ts|tsx|js|jsx)",
15+
importPathMatcher:
16+
/^\.(?:(?:^|\/|(?:(?:(?!(?:^|\/)\.).)*?)\/)(?!\.)(?=.)[^/]*?\.stories\.(?:ts|tsx|js|jsx)?)$/,
17+
// @ts-ignore
18+
req: require.context(
19+
"../src/components",
20+
true,
21+
/^\.(?:(?:^|\/|(?:(?:(?!(?:^|\/)\.).)*?)\/)(?!\.)(?=.)[^/]*?\.stories\.(?:ts|tsx|js|jsx)?)$/
22+
),
23+
},
24+
{
25+
titlePrefix: "",
26+
directory: "./src/screens",
27+
files: "**/*.stories.?(ts|tsx|js|jsx)",
28+
importPathMatcher:
29+
/^\.(?:(?:^|\/|(?:(?:(?!(?:^|\/)\.).)*?)\/)(?!\.)(?=.)[^/]*?\.stories\.(?:ts|tsx|js|jsx)?)$/,
30+
// @ts-ignore
31+
req: require.context(
32+
"../src/screens",
33+
true,
34+
/^\.(?:(?:^|\/|(?:(?:(?!(?:^|\/)\.).)*?)\/)(?!\.)(?=.)[^/]*?\.stories\.(?:ts|tsx|js|jsx)?)$/
35+
),
36+
},
37+
];
38+
39+
// @ts-ignore
40+
global.STORIES = normalizedStories;
41+
42+
export const view = start({
43+
annotations: [
44+
require("./preview"),
45+
require("@storybook/react-native/dist/preview"),
46+
require("@storybook/addon-actions/preview"),
47+
],
48+
storyEntries: normalizedStories,
49+
});

hackathon/spacecraft/metro.config.js

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,18 @@
1-
// Learn more https://docs.expo.io/guides/customizing-metro
2-
const { getDefaultConfig } = require("expo/metro-config");
1+
// metro.config.js
2+
const path = require('path');
3+
const { getDefaultConfig } = require('expo/metro-config');
34

4-
const defaultConfig = getDefaultConfig(__dirname);
5+
const { generate } = require('@storybook/react-native/scripts/generate');
56

6-
defaultConfig.resolver.resolverMainFields.unshift("sbmodern");
7+
generate({
8+
configPath: path.resolve(__dirname, './.storybook'),
9+
});
710

8-
module.exports = defaultConfig;
11+
/** @type {import('expo/metro-config').MetroConfig} */
12+
const config = getDefaultConfig(__dirname);
13+
14+
config.transformer.unstable_allowRequireContext = true;
15+
16+
config.resolver.sourceExts.push('mjs');
17+
18+
module.exports = config;

hackathon/spacecraft/package.json

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,10 +64,13 @@
6464
"@react-native-community/datetimepicker": "7.6.2",
6565
"@react-native-community/slider": "4.5.0",
6666
"@storybook/addon-controls": "^7.6.10",
67-
"@storybook/addon-ondevice-controls": "^6.5.1",
67+
"@storybook/addon-ondevice-actions": "^7.6.15",
68+
"@storybook/addon-ondevice-backgrounds": "^7.6.15",
69+
"@storybook/addon-ondevice-controls": "^7.6.15",
70+
"@storybook/addon-ondevice-notes": "^7.6.15",
6871
"@storybook/addons": "^7.6.10",
6972
"@storybook/core-common": "^7.6.10",
70-
"@storybook/react-native": "^6.5.1",
73+
"@storybook/react-native": "^7.6.15",
7174
"@storybook/react-native-server": "^6.5.8",
7275
"@tanstack/eslint-plugin-query": "^5.17.20",
7376
"@testing-library/jest-native": "^5.4.3",

hackathon/spacecraft/src/components/Card.stories.tsx

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,4 @@ export const NotForSale = () => (
3030
</NavigationContainer>
3131
);
3232

33-
NotForSale.story = {
34-
name: "Not for sale",
35-
};
33+
NotForSale.storyName = "Not for sale";

0 commit comments

Comments
 (0)