@storybook/react-native 9.0.0-alpha.0 → 9.0.0-alpha.10
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/babel.config.js +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.js +4 -4
- package/jest.config.js +4 -9
- package/package.json +13 -10
- package/preset.js +2 -0
- package/scripts/generate.test.js +2 -0
- package/template/cli/stories/Button.stories.tsx +53 -0
- package/template/cli/stories/Button.tsx +101 -0
- package/template/cli/stories/Header.stories.tsx +33 -0
- package/template/cli/stories/Header.tsx +76 -0
- package/template/cli/stories/Page.stories.tsx +10 -0
- package/template/cli/stories/Page.tsx +147 -0
- package/template/cli/stories/Button/Button.stories.tsx +0 -33
- package/template/cli/stories/Button/Button.tsx +0 -24
package/babel.config.js
CHANGED
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -1077,7 +1077,7 @@ var View3 = class {
|
|
|
1077
1077
|
return {};
|
|
1078
1078
|
}
|
|
1079
1079
|
return (0, import_react_native_ui.transformStoryIndexToStoriesHash)(this._storyIndex, {
|
|
1080
|
-
docsOptions: { docsMode: false,
|
|
1080
|
+
docsOptions: { docsMode: false, defaultName: "" },
|
|
1081
1081
|
filters: {},
|
|
1082
1082
|
status: {},
|
|
1083
1083
|
provider: {
|
|
@@ -1164,10 +1164,11 @@ function prepareStories({
|
|
|
1164
1164
|
const exportValue = fileExports[key];
|
|
1165
1165
|
if (!exportValue)
|
|
1166
1166
|
return;
|
|
1167
|
-
const name = (0, import_csf2.storyNameFromExport)(key);
|
|
1168
1167
|
const title = makeTitle(filename, specifier, meta.title);
|
|
1169
1168
|
if (title) {
|
|
1170
|
-
const
|
|
1169
|
+
const nameFromExport = (0, import_csf2.storyNameFromExport)(key);
|
|
1170
|
+
const id = (0, import_csf2.toId)(title, nameFromExport);
|
|
1171
|
+
const name = exportValue?.name || exportValue?.storyName || nameFromExport;
|
|
1171
1172
|
index.entries[id] = {
|
|
1172
1173
|
type: "story",
|
|
1173
1174
|
id,
|
|
@@ -1282,7 +1283,6 @@ function start({
|
|
|
1282
1283
|
setQueryParams: () => {
|
|
1283
1284
|
},
|
|
1284
1285
|
setSelection: (selection) => {
|
|
1285
|
-
console.log("setSelection", selection);
|
|
1286
1286
|
preview.selectionStore.selection = selection;
|
|
1287
1287
|
}
|
|
1288
1288
|
};
|
package/jest.config.js
CHANGED
|
@@ -1,13 +1,8 @@
|
|
|
1
1
|
/** @type {import('jest').Config} */
|
|
2
2
|
const config = {
|
|
3
|
-
preset: '
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
setupFilesAfterEnv: ['<rootDir>/../../node_modules/react-native-gesture-handler/jestSetup.js'],
|
|
8
|
-
transform: {
|
|
9
|
-
'^.+\\.(js)$': ['babel-jest', { plugins: ['babel-plugin-syntax-hermes-parser'] }],
|
|
10
|
-
'^.+\\.(ts|tsx)$': 'babel-jest',
|
|
11
|
-
},
|
|
3
|
+
preset: 'jest-expo',
|
|
4
|
+
transformIgnorePatterns: [
|
|
5
|
+
'node_modules/(?!((jest-)?react-native|@react-native(-community)?)|expo(nent)?|@expo(nent)?/.*|@expo-google-fonts/.*|react-navigation|@react-navigation/.*|@sentry/react-native|native-base|react-native-svg|storybook/.*|@storybook/.*|uuid)',
|
|
6
|
+
],
|
|
12
7
|
};
|
|
13
8
|
module.exports = config;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@storybook/react-native",
|
|
3
|
-
"version": "9.0.0-alpha.
|
|
3
|
+
"version": "9.0.0-alpha.10",
|
|
4
4
|
"description": "A better way to develop React Native Components for your app",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"react",
|
|
@@ -25,7 +25,8 @@
|
|
|
25
25
|
".": "./dist/index.js",
|
|
26
26
|
"./metro/withStorybook": "./dist/metro/withStorybook.js",
|
|
27
27
|
"./preview": "./dist/preview.js",
|
|
28
|
-
"./scripts/generate": "./scripts/generate.js"
|
|
28
|
+
"./scripts/generate": "./scripts/generate.js",
|
|
29
|
+
"./preset": "./preset.js"
|
|
29
30
|
},
|
|
30
31
|
"files": [
|
|
31
32
|
"bin/**/*",
|
|
@@ -47,16 +48,15 @@
|
|
|
47
48
|
"dependencies": {
|
|
48
49
|
"@storybook/csf": "^0.1.13",
|
|
49
50
|
"@storybook/global": "^5.0.0",
|
|
50
|
-
"@storybook/react": "9.0.0-alpha.
|
|
51
|
-
"@storybook/react-native-theming": "^9.0.0-alpha.
|
|
52
|
-
"@storybook/react-native-ui": "^9.0.0-alpha.
|
|
51
|
+
"@storybook/react": "9.0.0-alpha.16",
|
|
52
|
+
"@storybook/react-native-theming": "^9.0.0-alpha.10",
|
|
53
|
+
"@storybook/react-native-ui": "^9.0.0-alpha.10",
|
|
53
54
|
"commander": "^8.2.0",
|
|
54
55
|
"dedent": "^1.5.1",
|
|
55
56
|
"deepmerge": "^4.3.0",
|
|
56
57
|
"prettier": "^2.4.1",
|
|
57
58
|
"react-native-url-polyfill": "^2.0.0",
|
|
58
59
|
"setimmediate": "^1.0.5",
|
|
59
|
-
"storybook": "9.0.0-alpha.3",
|
|
60
60
|
"type-fest": "~2.19",
|
|
61
61
|
"util": "^0.12.4",
|
|
62
62
|
"ws": "^8.18.0"
|
|
@@ -65,12 +65,14 @@
|
|
|
65
65
|
"@types/jest": "^29.4.3",
|
|
66
66
|
"@types/react": "~18.3.12",
|
|
67
67
|
"babel-jest": "^29.7.0",
|
|
68
|
-
"babel-
|
|
68
|
+
"babel-preset-expo": "^12.0.9",
|
|
69
69
|
"jest": "^29.7.0",
|
|
70
|
+
"jest-expo": "~52.0.6",
|
|
70
71
|
"jotai": "^2.6.2",
|
|
71
72
|
"react": "18.3.1",
|
|
72
|
-
"react-native": "0.76.
|
|
73
|
+
"react-native": "0.76.9",
|
|
73
74
|
"react-test-renderer": "^18.3.1",
|
|
75
|
+
"storybook": "9.0.0-alpha.16",
|
|
74
76
|
"tsup": "^7.2.0",
|
|
75
77
|
"typescript": "^5.3.3"
|
|
76
78
|
},
|
|
@@ -79,7 +81,8 @@
|
|
|
79
81
|
"react": "*",
|
|
80
82
|
"react-native": ">=0.72.0",
|
|
81
83
|
"react-native-gesture-handler": ">=2",
|
|
82
|
-
"react-native-safe-area-context": "*"
|
|
84
|
+
"react-native-safe-area-context": "*",
|
|
85
|
+
"storybook": "9.0.0-alpha.16"
|
|
83
86
|
},
|
|
84
87
|
"engines": {
|
|
85
88
|
"node": ">=8.0.0"
|
|
@@ -87,5 +90,5 @@
|
|
|
87
90
|
"publishConfig": {
|
|
88
91
|
"access": "public"
|
|
89
92
|
},
|
|
90
|
-
"gitHead": "
|
|
93
|
+
"gitHead": "19e0e4e5908e11d42e00dc508d58a0a4dc9abd3c"
|
|
91
94
|
}
|
package/preset.js
ADDED
package/scripts/generate.test.js
CHANGED
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import type { Meta, StoryObj } from '@storybook/react';
|
|
2
|
+
|
|
3
|
+
import { View } from 'react-native';
|
|
4
|
+
import { fn } from 'storybook/test';
|
|
5
|
+
|
|
6
|
+
import { Button } from './Button';
|
|
7
|
+
|
|
8
|
+
const meta = {
|
|
9
|
+
title: 'Example/Button',
|
|
10
|
+
component: Button,
|
|
11
|
+
decorators: [
|
|
12
|
+
(Story) => (
|
|
13
|
+
<View style={{ flex: 1, alignItems: 'flex-start' }}>
|
|
14
|
+
<Story />
|
|
15
|
+
</View>
|
|
16
|
+
),
|
|
17
|
+
],
|
|
18
|
+
// This component will have an automatically generated Autodocs entry: https://storybook.js.org/docs/writing-docs/autodocs
|
|
19
|
+
tags: ['autodocs'],
|
|
20
|
+
// Use `fn` to spy on the onPress arg, which will appear in the actions panel once invoked: https://storybook.js.org/docs/essentials/actions#action-args
|
|
21
|
+
args: { onPress: fn() },
|
|
22
|
+
} satisfies Meta<typeof Button>;
|
|
23
|
+
|
|
24
|
+
export default meta;
|
|
25
|
+
|
|
26
|
+
type Story = StoryObj<typeof meta>;
|
|
27
|
+
|
|
28
|
+
export const Primary: Story = {
|
|
29
|
+
args: {
|
|
30
|
+
primary: true,
|
|
31
|
+
label: 'Button',
|
|
32
|
+
},
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
export const Secondary: Story = {
|
|
36
|
+
args: {
|
|
37
|
+
label: 'Button',
|
|
38
|
+
},
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
export const Large: Story = {
|
|
42
|
+
args: {
|
|
43
|
+
size: 'large',
|
|
44
|
+
label: 'Button',
|
|
45
|
+
},
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
export const Small: Story = {
|
|
49
|
+
args: {
|
|
50
|
+
size: 'small',
|
|
51
|
+
label: 'Button',
|
|
52
|
+
},
|
|
53
|
+
};
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
import type { StyleProp, ViewStyle } from 'react-native';
|
|
2
|
+
import { StyleSheet, Text, TouchableOpacity, View } from 'react-native';
|
|
3
|
+
|
|
4
|
+
export interface ButtonProps {
|
|
5
|
+
/** Is this the principal call to action on the page? */
|
|
6
|
+
primary?: boolean;
|
|
7
|
+
/** What background color to use */
|
|
8
|
+
backgroundColor?: string;
|
|
9
|
+
/** How large should the button be? */
|
|
10
|
+
size?: 'small' | 'medium' | 'large';
|
|
11
|
+
/** Button contents */
|
|
12
|
+
label: string;
|
|
13
|
+
/** Optional click handler */
|
|
14
|
+
onPress?: () => void;
|
|
15
|
+
style?: StyleProp<ViewStyle>;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
/** Primary UI component for user interaction */
|
|
19
|
+
export const Button = ({
|
|
20
|
+
primary = false,
|
|
21
|
+
size = 'medium',
|
|
22
|
+
backgroundColor,
|
|
23
|
+
label,
|
|
24
|
+
style,
|
|
25
|
+
onPress,
|
|
26
|
+
}: ButtonProps) => {
|
|
27
|
+
const modeStyle = primary ? styles.primary : styles.secondary;
|
|
28
|
+
const textModeStyle = primary ? styles.primaryText : styles.secondaryText;
|
|
29
|
+
|
|
30
|
+
const sizeStyle = styles[size];
|
|
31
|
+
const textSizeStyle = textSizeStyles[size];
|
|
32
|
+
|
|
33
|
+
return (
|
|
34
|
+
<TouchableOpacity accessibilityRole="button" activeOpacity={0.6} onPress={onPress}>
|
|
35
|
+
<View
|
|
36
|
+
style={[
|
|
37
|
+
styles.button,
|
|
38
|
+
modeStyle,
|
|
39
|
+
sizeStyle,
|
|
40
|
+
style,
|
|
41
|
+
!!backgroundColor && { backgroundColor },
|
|
42
|
+
{ borderColor: 'black' },
|
|
43
|
+
]}
|
|
44
|
+
>
|
|
45
|
+
<Text style={[textModeStyle, textSizeStyle]}>{label}</Text>
|
|
46
|
+
</View>
|
|
47
|
+
</TouchableOpacity>
|
|
48
|
+
);
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
const styles = StyleSheet.create({
|
|
52
|
+
button: {
|
|
53
|
+
borderWidth: 0,
|
|
54
|
+
borderRadius: 48,
|
|
55
|
+
},
|
|
56
|
+
buttonText: {
|
|
57
|
+
fontWeight: '700',
|
|
58
|
+
lineHeight: 1,
|
|
59
|
+
},
|
|
60
|
+
primary: {
|
|
61
|
+
backgroundColor: '#1ea7fd',
|
|
62
|
+
},
|
|
63
|
+
primaryText: {
|
|
64
|
+
color: 'white',
|
|
65
|
+
},
|
|
66
|
+
secondary: {
|
|
67
|
+
backgroundColor: 'transparent',
|
|
68
|
+
borderColor: 'rgba(0, 0, 0, 0.15)',
|
|
69
|
+
borderWidth: 1,
|
|
70
|
+
},
|
|
71
|
+
secondaryText: {
|
|
72
|
+
color: '#333',
|
|
73
|
+
},
|
|
74
|
+
small: {
|
|
75
|
+
paddingVertical: 10,
|
|
76
|
+
paddingHorizontal: 16,
|
|
77
|
+
},
|
|
78
|
+
smallText: {
|
|
79
|
+
fontSize: 12,
|
|
80
|
+
},
|
|
81
|
+
medium: {
|
|
82
|
+
paddingVertical: 11,
|
|
83
|
+
paddingHorizontal: 20,
|
|
84
|
+
},
|
|
85
|
+
mediumText: {
|
|
86
|
+
fontSize: 14,
|
|
87
|
+
},
|
|
88
|
+
large: {
|
|
89
|
+
paddingVertical: 12,
|
|
90
|
+
paddingHorizontal: 24,
|
|
91
|
+
},
|
|
92
|
+
largeText: {
|
|
93
|
+
fontSize: 16,
|
|
94
|
+
},
|
|
95
|
+
});
|
|
96
|
+
|
|
97
|
+
const textSizeStyles = {
|
|
98
|
+
small: styles.smallText,
|
|
99
|
+
medium: styles.mediumText,
|
|
100
|
+
large: styles.largeText,
|
|
101
|
+
};
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import type { Meta, StoryObj } from '@storybook/react';
|
|
2
|
+
|
|
3
|
+
import { Header } from './Header';
|
|
4
|
+
|
|
5
|
+
const meta = {
|
|
6
|
+
title: 'Example/Header',
|
|
7
|
+
component: Header,
|
|
8
|
+
// This component will have an automatically generated Autodocs entry: https://storybook.js.org/docs/writing-docs/autodocs
|
|
9
|
+
tags: ['autodocs'],
|
|
10
|
+
} satisfies Meta<typeof Header>;
|
|
11
|
+
|
|
12
|
+
export default meta;
|
|
13
|
+
|
|
14
|
+
type Story = StoryObj<typeof meta>;
|
|
15
|
+
|
|
16
|
+
export const LoggedIn: Story = {
|
|
17
|
+
args: {
|
|
18
|
+
user: {
|
|
19
|
+
name: 'Jane Doe',
|
|
20
|
+
},
|
|
21
|
+
onLogin: () => {},
|
|
22
|
+
onLogout: () => {},
|
|
23
|
+
onCreateAccount: () => {},
|
|
24
|
+
},
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
export const LoggedOut: Story = {
|
|
28
|
+
args: {
|
|
29
|
+
onLogin: () => {},
|
|
30
|
+
onLogout: () => {},
|
|
31
|
+
onCreateAccount: () => {},
|
|
32
|
+
},
|
|
33
|
+
};
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import { StyleSheet, Text, View } from 'react-native';
|
|
2
|
+
|
|
3
|
+
import { Button } from './Button';
|
|
4
|
+
|
|
5
|
+
export type HeaderProps = {
|
|
6
|
+
user?: { name: string };
|
|
7
|
+
onLogin: () => void;
|
|
8
|
+
onLogout: () => void;
|
|
9
|
+
onCreateAccount: () => void;
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
export const Header = ({ user, onLogin, onLogout, onCreateAccount }: HeaderProps) => (
|
|
13
|
+
<View>
|
|
14
|
+
<View style={styles.wrapper}>
|
|
15
|
+
<View style={styles.logoContainer}>
|
|
16
|
+
<Text style={styles.h1}>Acme</Text>
|
|
17
|
+
</View>
|
|
18
|
+
<View style={styles.buttonContainer}>
|
|
19
|
+
{user ? (
|
|
20
|
+
<>
|
|
21
|
+
<Text>Welcome, </Text>
|
|
22
|
+
<Text style={styles.userName}>{user.name}!</Text>
|
|
23
|
+
|
|
24
|
+
<Button style={styles.button} size="small" onPress={onLogout} label="Log out" />
|
|
25
|
+
</>
|
|
26
|
+
) : (
|
|
27
|
+
<>
|
|
28
|
+
<Button style={styles.button} size="small" onPress={onLogin} label="Log in" />
|
|
29
|
+
|
|
30
|
+
<Button
|
|
31
|
+
style={styles.button}
|
|
32
|
+
primary
|
|
33
|
+
size="small"
|
|
34
|
+
onPress={onCreateAccount}
|
|
35
|
+
label="Sign up"
|
|
36
|
+
/>
|
|
37
|
+
</>
|
|
38
|
+
)}
|
|
39
|
+
</View>
|
|
40
|
+
</View>
|
|
41
|
+
</View>
|
|
42
|
+
);
|
|
43
|
+
|
|
44
|
+
const styles = StyleSheet.create({
|
|
45
|
+
wrapper: {
|
|
46
|
+
borderBottomWidth: 1,
|
|
47
|
+
borderBottomColor: 'rgba(0, 0, 0, 0.1)',
|
|
48
|
+
paddingVertical: 15,
|
|
49
|
+
paddingHorizontal: 20,
|
|
50
|
+
flexDirection: 'row',
|
|
51
|
+
justifyContent: 'space-between',
|
|
52
|
+
},
|
|
53
|
+
h1: {
|
|
54
|
+
fontWeight: '900',
|
|
55
|
+
fontSize: 20,
|
|
56
|
+
marginTop: 6,
|
|
57
|
+
marginBottom: 6,
|
|
58
|
+
marginLeft: 10,
|
|
59
|
+
color: 'black',
|
|
60
|
+
alignSelf: 'flex-start',
|
|
61
|
+
},
|
|
62
|
+
logoContainer: {
|
|
63
|
+
flexDirection: 'row',
|
|
64
|
+
alignItems: 'center',
|
|
65
|
+
},
|
|
66
|
+
button: {
|
|
67
|
+
marginLeft: 10,
|
|
68
|
+
},
|
|
69
|
+
buttonContainer: {
|
|
70
|
+
flexDirection: 'row',
|
|
71
|
+
alignItems: 'center',
|
|
72
|
+
},
|
|
73
|
+
userName: {
|
|
74
|
+
fontWeight: '700',
|
|
75
|
+
},
|
|
76
|
+
});
|
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
import { useState } from 'react';
|
|
2
|
+
|
|
3
|
+
import { Linking, StyleSheet, Text, View } from 'react-native';
|
|
4
|
+
|
|
5
|
+
import { Header } from './Header';
|
|
6
|
+
|
|
7
|
+
export const Page = () => {
|
|
8
|
+
const [user, setUser] = useState<{ name: string } | undefined>();
|
|
9
|
+
|
|
10
|
+
return (
|
|
11
|
+
<View>
|
|
12
|
+
<Header
|
|
13
|
+
user={user}
|
|
14
|
+
onLogin={() => setUser({ name: 'Jane Doe' })}
|
|
15
|
+
onLogout={() => setUser(undefined)}
|
|
16
|
+
onCreateAccount={() => setUser({ name: 'Jane Doe' })}
|
|
17
|
+
/>
|
|
18
|
+
|
|
19
|
+
<View style={styles.section}>
|
|
20
|
+
<Text role="heading" style={styles.h2}>
|
|
21
|
+
Pages in Storybook
|
|
22
|
+
</Text>
|
|
23
|
+
<Text style={styles.p}>
|
|
24
|
+
We recommend building UIs with a{' '}
|
|
25
|
+
<Text
|
|
26
|
+
style={[styles.a, { fontWeight: 'bold' }]}
|
|
27
|
+
role="link"
|
|
28
|
+
onPress={() => {
|
|
29
|
+
Linking.openURL('https://componentdriven.org');
|
|
30
|
+
}}
|
|
31
|
+
>
|
|
32
|
+
<Text>component-driven</Text>
|
|
33
|
+
</Text>{' '}
|
|
34
|
+
process starting with atomic components and ending with pages.
|
|
35
|
+
</Text>
|
|
36
|
+
<Text style={styles.p}>
|
|
37
|
+
Render pages with mock data. This makes it easy to build and review page states without
|
|
38
|
+
needing to navigate to them in your app. Here are some handy patterns for managing page
|
|
39
|
+
data in Storybook:
|
|
40
|
+
</Text>
|
|
41
|
+
<View>
|
|
42
|
+
<Text>
|
|
43
|
+
Use a higher-level connected component. Storybook helps you compose such data from the
|
|
44
|
+
"args" of child component stories
|
|
45
|
+
</Text>
|
|
46
|
+
<Text>
|
|
47
|
+
Assemble data in the page component from your services. You can mock these services out
|
|
48
|
+
using Storybook.
|
|
49
|
+
</Text>
|
|
50
|
+
</View>
|
|
51
|
+
<Text style={styles.p}>
|
|
52
|
+
Get a guided tutorial on component-driven development at{' '}
|
|
53
|
+
<Text
|
|
54
|
+
style={styles.a}
|
|
55
|
+
role="link"
|
|
56
|
+
onPress={() => {
|
|
57
|
+
Linking.openURL('https://storybook.js.org/tutorials/');
|
|
58
|
+
}}
|
|
59
|
+
>
|
|
60
|
+
Storybook tutorials
|
|
61
|
+
</Text>
|
|
62
|
+
. Read more in the{' '}
|
|
63
|
+
<Text
|
|
64
|
+
style={styles.a}
|
|
65
|
+
role="link"
|
|
66
|
+
onPress={() => {
|
|
67
|
+
Linking.openURL('https://storybook.js.org/docs');
|
|
68
|
+
}}
|
|
69
|
+
>
|
|
70
|
+
docs
|
|
71
|
+
</Text>
|
|
72
|
+
.
|
|
73
|
+
</Text>
|
|
74
|
+
</View>
|
|
75
|
+
</View>
|
|
76
|
+
);
|
|
77
|
+
};
|
|
78
|
+
|
|
79
|
+
const styles = StyleSheet.create({
|
|
80
|
+
section: {
|
|
81
|
+
fontFamily: "'Nunito Sans', 'Helvetica Neue', Helvetica, Arial, sans-serif",
|
|
82
|
+
fontSize: 14,
|
|
83
|
+
lineHeight: 24,
|
|
84
|
+
paddingVertical: 48,
|
|
85
|
+
paddingHorizontal: 20,
|
|
86
|
+
marginHorizontal: 'auto',
|
|
87
|
+
maxWidth: 600,
|
|
88
|
+
color: '#333',
|
|
89
|
+
},
|
|
90
|
+
|
|
91
|
+
h2: {
|
|
92
|
+
fontWeight: '900',
|
|
93
|
+
fontSize: 32,
|
|
94
|
+
lineHeight: 1,
|
|
95
|
+
marginBottom: 4,
|
|
96
|
+
},
|
|
97
|
+
|
|
98
|
+
p: {
|
|
99
|
+
marginVertical: 16,
|
|
100
|
+
marginHorizontal: 0,
|
|
101
|
+
},
|
|
102
|
+
|
|
103
|
+
a: {
|
|
104
|
+
color: '#1ea7fd',
|
|
105
|
+
},
|
|
106
|
+
|
|
107
|
+
ul: {
|
|
108
|
+
paddingLeft: 30,
|
|
109
|
+
marginVertical: 16,
|
|
110
|
+
},
|
|
111
|
+
|
|
112
|
+
li: {
|
|
113
|
+
marginBottom: 8,
|
|
114
|
+
},
|
|
115
|
+
|
|
116
|
+
tip: {
|
|
117
|
+
alignSelf: 'flex-start',
|
|
118
|
+
borderRadius: 16,
|
|
119
|
+
backgroundColor: '#e7fdd8',
|
|
120
|
+
paddingVertical: 4,
|
|
121
|
+
paddingHorizontal: 12,
|
|
122
|
+
marginRight: 10,
|
|
123
|
+
marginBottom: 4,
|
|
124
|
+
},
|
|
125
|
+
tipText: {
|
|
126
|
+
fontSize: 11,
|
|
127
|
+
lineHeight: 12,
|
|
128
|
+
fontWeight: '700',
|
|
129
|
+
color: '#66bf3c',
|
|
130
|
+
},
|
|
131
|
+
|
|
132
|
+
tipWrapper: {
|
|
133
|
+
fontSize: 13,
|
|
134
|
+
lineHeight: 20,
|
|
135
|
+
marginTop: 40,
|
|
136
|
+
marginBottom: 40,
|
|
137
|
+
flexDirection: 'row',
|
|
138
|
+
flexWrap: 'wrap',
|
|
139
|
+
},
|
|
140
|
+
|
|
141
|
+
tipWrapperSvg: {
|
|
142
|
+
height: 12,
|
|
143
|
+
width: 12,
|
|
144
|
+
marginRight: 4,
|
|
145
|
+
marginTop: 3,
|
|
146
|
+
},
|
|
147
|
+
});
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import { View } from 'react-native';
|
|
2
|
-
import type { Meta, StoryObj } from '@storybook/react';
|
|
3
|
-
import { MyButton } from './Button';
|
|
4
|
-
|
|
5
|
-
const meta = {
|
|
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={{ padding: 16, alignItems: 'flex-start' }}>
|
|
17
|
-
<Story />
|
|
18
|
-
</View>
|
|
19
|
-
),
|
|
20
|
-
],
|
|
21
|
-
} satisfies Meta<typeof MyButton>;
|
|
22
|
-
|
|
23
|
-
export default meta;
|
|
24
|
-
|
|
25
|
-
type Story = StoryObj<typeof meta>;
|
|
26
|
-
|
|
27
|
-
export const Basic: Story = {};
|
|
28
|
-
|
|
29
|
-
export const AnotherExample: Story = {
|
|
30
|
-
args: {
|
|
31
|
-
text: 'Another example',
|
|
32
|
-
},
|
|
33
|
-
};
|
|
@@ -1,24 +0,0 @@
|
|
|
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
|
-
});
|