@storybook/react-native 6.5.0-rc.9 → 6.5.0
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/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/preview/View.js +3 -2
- package/dist/preview/components/Shared/theme.d.ts +4 -0
- package/dist/preview/components/Shared/theme.js +141 -2
- package/dist/preview/components/StoryListView/StoryListView.js +3 -3
- package/dist/preview/components/StoryView/StoryView.js +3 -2
- package/dist/preview/start.d.ts +2 -2
- package/dist/preview/start.js +4 -4
- package/package.json +2 -2
package/dist/index.d.ts
CHANGED
|
@@ -18,3 +18,4 @@ export declare const raw: C['raw'];
|
|
|
18
18
|
export declare const storiesOf: (kind: string, _module: NodeModule) => StoryApi<ReactNode>;
|
|
19
19
|
export declare const getStorybookUI: (params?: Partial<import("./preview/View").Params>) => () => JSX.Element;
|
|
20
20
|
export * from './types/types-6.0';
|
|
21
|
+
export { theme, darkTheme } from './preview/components/Shared/theme';
|
package/dist/index.js
CHANGED
package/dist/preview/View.js
CHANGED
|
@@ -15,11 +15,12 @@ import { ThemeProvider } from 'emotion-theming';
|
|
|
15
15
|
import { SafeAreaProvider } from 'react-native-safe-area-context';
|
|
16
16
|
import { useSetStoryContext, syncExternalUI } from '../hooks';
|
|
17
17
|
import OnDeviceUI from './components/OnDeviceUI';
|
|
18
|
-
import { theme } from './components/Shared/theme';
|
|
18
|
+
import { darkTheme, theme } from './components/Shared/theme';
|
|
19
19
|
import StoryView from './components/StoryView';
|
|
20
20
|
import createChannel from '@storybook/channel-websocket';
|
|
21
21
|
import getHost from './rn-host-detect';
|
|
22
22
|
import events from '@storybook/core-events';
|
|
23
|
+
import { Appearance } from 'react-native';
|
|
23
24
|
import deepmerge from 'deepmerge';
|
|
24
25
|
const STORAGE_KEY = 'lastOpenedStory';
|
|
25
26
|
export class View {
|
|
@@ -89,7 +90,7 @@ export class View {
|
|
|
89
90
|
});
|
|
90
91
|
// eslint-disable-next-line consistent-this
|
|
91
92
|
const self = this;
|
|
92
|
-
const appliedTheme = deepmerge(theme, (_a = params.theme) !== null && _a !== void 0 ? _a : {});
|
|
93
|
+
const appliedTheme = deepmerge(Appearance.getColorScheme() === 'dark' ? darkTheme : theme, (_a = params.theme) !== null && _a !== void 0 ? _a : {});
|
|
93
94
|
// Sync the Storybook parameters (external) with app UI state (internal), to initialise them.
|
|
94
95
|
syncExternalUI({
|
|
95
96
|
isUIVisible: params.isUIHidden !== undefined ? !params.isUIHidden : undefined,
|
|
@@ -20,10 +20,13 @@ interface ThemeTokens {
|
|
|
20
20
|
normal: number;
|
|
21
21
|
};
|
|
22
22
|
color: {
|
|
23
|
+
navy: string;
|
|
24
|
+
offBlack: string;
|
|
23
25
|
black: string;
|
|
24
26
|
white: string;
|
|
25
27
|
grey200: string;
|
|
26
28
|
grey700: string;
|
|
29
|
+
grey800: string;
|
|
27
30
|
red500: string;
|
|
28
31
|
blue100: string;
|
|
29
32
|
blue200: string;
|
|
@@ -182,4 +185,5 @@ export interface Theme {
|
|
|
182
185
|
};
|
|
183
186
|
}
|
|
184
187
|
export declare const theme: Theme;
|
|
188
|
+
export declare const darkTheme: Theme;
|
|
185
189
|
export {};
|
|
@@ -11,10 +11,13 @@ const tokens = {
|
|
|
11
11
|
normal: 16,
|
|
12
12
|
},
|
|
13
13
|
color: {
|
|
14
|
-
|
|
14
|
+
navy: '#001a23',
|
|
15
|
+
black: '#000',
|
|
16
|
+
offBlack: '#222',
|
|
15
17
|
white: '#ffffff',
|
|
16
18
|
grey200: '#dee2e3',
|
|
17
19
|
grey700: '#859499',
|
|
20
|
+
grey800: '#575757',
|
|
18
21
|
red500: '#ff4400',
|
|
19
22
|
blue100: '#f6f9fc',
|
|
20
23
|
blue200: '#e0eaf5',
|
|
@@ -42,10 +45,15 @@ const tokens = {
|
|
|
42
45
|
},
|
|
43
46
|
};
|
|
44
47
|
const text = {
|
|
45
|
-
primaryColor: tokens.color.
|
|
48
|
+
primaryColor: tokens.color.navy,
|
|
46
49
|
secondaryColor: tokens.color.grey700,
|
|
47
50
|
linkColor: '#0000ff',
|
|
48
51
|
};
|
|
52
|
+
const textOnDark = {
|
|
53
|
+
primaryColor: tokens.color.white,
|
|
54
|
+
secondaryColor: tokens.color.grey200,
|
|
55
|
+
linkColor: tokens.color.blue600,
|
|
56
|
+
};
|
|
49
57
|
export const theme = {
|
|
50
58
|
tokens,
|
|
51
59
|
text,
|
|
@@ -177,3 +185,134 @@ export const theme = {
|
|
|
177
185
|
},
|
|
178
186
|
},
|
|
179
187
|
};
|
|
188
|
+
export const darkTheme = {
|
|
189
|
+
tokens,
|
|
190
|
+
text: textOnDark,
|
|
191
|
+
backgroundColor: tokens.color.offBlack,
|
|
192
|
+
preview: {
|
|
193
|
+
containerBackgroundColor: tokens.color.black,
|
|
194
|
+
backgroundColor: tokens.color.offBlack,
|
|
195
|
+
},
|
|
196
|
+
navigation: {
|
|
197
|
+
backgroundColor: tokens.color.offBlack,
|
|
198
|
+
borderColor: tokens.color.grey800,
|
|
199
|
+
borderWidth: tokens.borderWidthNormal,
|
|
200
|
+
visibilityBorderRadius: tokens.borderRadius.small,
|
|
201
|
+
visibilityInnerBorderColor: tokens.color.navy,
|
|
202
|
+
visibilityOuterBorderColor: tokens.color.navy,
|
|
203
|
+
},
|
|
204
|
+
panel: {
|
|
205
|
+
backgroundColor: tokens.color.offBlack,
|
|
206
|
+
borderWidth: tokens.borderWidthNormal,
|
|
207
|
+
borderColor: tokens.color.grey800,
|
|
208
|
+
paddingVertical: 0,
|
|
209
|
+
paddingHorizontal: tokens.spacing2,
|
|
210
|
+
},
|
|
211
|
+
storyList: {
|
|
212
|
+
fontSize: tokens.fontSize.normal,
|
|
213
|
+
headerPaddingHorizontal: tokens.spacing2,
|
|
214
|
+
headerPaddingVertical: tokens.spacing2,
|
|
215
|
+
headerTextColor: textOnDark.primaryColor,
|
|
216
|
+
headerFontWeight: '500',
|
|
217
|
+
storyPaddingHorizontal: tokens.spacing2,
|
|
218
|
+
storyPaddingVertical: tokens.spacing1 * 1.5,
|
|
219
|
+
storyIndent: tokens.spacing6,
|
|
220
|
+
storyTextColor: textOnDark.primaryColor,
|
|
221
|
+
storyFontWeight: '400',
|
|
222
|
+
storySelectedBackgroundColor: tokens.color.navy,
|
|
223
|
+
storySelectedTextColor: tokens.color.white,
|
|
224
|
+
storySelectedFontWeight: '700',
|
|
225
|
+
sectionSpacing: tokens.spacing2,
|
|
226
|
+
sectionActiveBackgroundColor: tokens.color.grey800,
|
|
227
|
+
sectionBorderRadius: tokens.borderRadius.medium,
|
|
228
|
+
search: {
|
|
229
|
+
fontSize: tokens.fontSize.normal,
|
|
230
|
+
textColor: textOnDark.primaryColor,
|
|
231
|
+
placeholderTextColor: textOnDark.secondaryColor,
|
|
232
|
+
borderRadius: tokens.borderRadius.round,
|
|
233
|
+
borderColor: tokens.color.grey800,
|
|
234
|
+
borderWidth: tokens.borderWidthNormal,
|
|
235
|
+
backgroundColor: tokens.color.grey800,
|
|
236
|
+
paddingVertical: tokens.spacing2,
|
|
237
|
+
paddingHorizontal: tokens.spacing3,
|
|
238
|
+
},
|
|
239
|
+
},
|
|
240
|
+
button: {
|
|
241
|
+
fontSize: tokens.fontSize.smaller,
|
|
242
|
+
fontWeight: '600',
|
|
243
|
+
paddingVertical: tokens.spacing2,
|
|
244
|
+
paddingHorizontal: tokens.spacing5,
|
|
245
|
+
primary: {
|
|
246
|
+
textColor: textOnDark.primaryColor,
|
|
247
|
+
backgroundColor: tokens.color.black,
|
|
248
|
+
borderColor: tokens.color.blue300,
|
|
249
|
+
borderWidth: tokens.borderWidthNormal,
|
|
250
|
+
borderRadius: tokens.borderRadius.medium,
|
|
251
|
+
},
|
|
252
|
+
secondary: {
|
|
253
|
+
textColor: textOnDark.primaryColor,
|
|
254
|
+
backgroundColor: 'transparent',
|
|
255
|
+
borderColor: tokens.color.blue300,
|
|
256
|
+
borderWidth: tokens.borderWidthNormal,
|
|
257
|
+
borderRadius: tokens.borderRadius.medium,
|
|
258
|
+
},
|
|
259
|
+
},
|
|
260
|
+
tabs: {
|
|
261
|
+
fontSize: tokens.fontSize.small,
|
|
262
|
+
fontWeight: '500',
|
|
263
|
+
paddingVertical: tokens.spacing2,
|
|
264
|
+
paddingHorizontal: tokens.spacing2 * 1.25,
|
|
265
|
+
borderWidth: tokens.borderWidthNormal,
|
|
266
|
+
borderRadius: tokens.borderRadius.round,
|
|
267
|
+
activeBorderColor: tokens.color.blue300,
|
|
268
|
+
activeBackgroundColor: tokens.color.navy,
|
|
269
|
+
activeTextColor: textOnDark.primaryColor,
|
|
270
|
+
inactiveBorderColor: 'transparent',
|
|
271
|
+
inactiveBackgroundColor: 'transparent',
|
|
272
|
+
inactiveTextColor: textOnDark.secondaryColor,
|
|
273
|
+
},
|
|
274
|
+
inputs: {
|
|
275
|
+
errorTextColor: tokens.color.red500,
|
|
276
|
+
labelFontSize: tokens.fontSize.smaller,
|
|
277
|
+
labelTextColor: textOnDark.primaryColor,
|
|
278
|
+
text: {
|
|
279
|
+
fontSize: tokens.fontSize.smaller,
|
|
280
|
+
textColor: textOnDark.primaryColor,
|
|
281
|
+
borderWidth: tokens.borderWidthNormal,
|
|
282
|
+
borderColor: tokens.color.blue400,
|
|
283
|
+
backgroundColor: tokens.color.black,
|
|
284
|
+
borderRadius: tokens.borderRadius.medium,
|
|
285
|
+
paddingVertical: tokens.spacing1 * 1.5,
|
|
286
|
+
paddingHorizontal: tokens.spacing1 * 1.5,
|
|
287
|
+
},
|
|
288
|
+
radio: {
|
|
289
|
+
fontSize: tokens.fontSize.smaller,
|
|
290
|
+
height: 20,
|
|
291
|
+
borderWidth: tokens.borderWidthNormal,
|
|
292
|
+
borderColor: tokens.color.blue400,
|
|
293
|
+
backgroundColor: tokens.color.black,
|
|
294
|
+
paddingVertical: 3,
|
|
295
|
+
paddingHorizontal: 3,
|
|
296
|
+
activeBackgroundColor: tokens.color.green500,
|
|
297
|
+
itemSpacing: tokens.spacing1,
|
|
298
|
+
labelSpacing: tokens.spacing2,
|
|
299
|
+
},
|
|
300
|
+
swatch: {
|
|
301
|
+
fontSize: tokens.fontSize.smaller,
|
|
302
|
+
height: 40,
|
|
303
|
+
borderWidth: tokens.borderWidthNormal,
|
|
304
|
+
borderColor: tokens.color.blue400,
|
|
305
|
+
backgroundColor: tokens.color.navy,
|
|
306
|
+
outerBorderRadius: tokens.borderRadius.medium,
|
|
307
|
+
innerBorderRadius: tokens.borderRadius.small,
|
|
308
|
+
paddingVertical: tokens.spacing1,
|
|
309
|
+
paddingHorizontal: tokens.spacing1,
|
|
310
|
+
nameTextWeight: '600',
|
|
311
|
+
},
|
|
312
|
+
slider: {
|
|
313
|
+
fontSize: tokens.fontSize.smaller,
|
|
314
|
+
labelTextColor: textOnDark.secondaryColor,
|
|
315
|
+
valueTextColor: textOnDark.primaryColor,
|
|
316
|
+
},
|
|
317
|
+
},
|
|
318
|
+
};
|
|
@@ -36,7 +36,7 @@ const SearchContainer = styled.View(({ theme }) => ({
|
|
|
36
36
|
const SearchBar = (props) => {
|
|
37
37
|
const theme = useTheme();
|
|
38
38
|
return (React.createElement(SearchContainer, null,
|
|
39
|
-
React.createElement(Icon, { name: "search", opacity: 0.5 }),
|
|
39
|
+
React.createElement(Icon, { name: "search", opacity: 0.5, color: 'white' }),
|
|
40
40
|
React.createElement(SearchInput, Object.assign({}, props, { autoCapitalize: "none", autoComplete: "off", autoCorrect: false, spellCheck: false, clearButtonMode: "while-editing", disableFullscreenUI: true, placeholderTextColor: theme.storyList.search.placeholderTextColor, returnKeyType: "search" }))));
|
|
41
41
|
};
|
|
42
42
|
const HeaderContainer = styled.TouchableOpacity({
|
|
@@ -53,7 +53,7 @@ const HeaderContainer = styled.TouchableOpacity({
|
|
|
53
53
|
const SectionHeader = React.memo(({ title, onPress }) => {
|
|
54
54
|
const selected = useIsStorySectionSelected(title);
|
|
55
55
|
return (React.createElement(HeaderContainer, { key: title, selected: selected, onPress: onPress, activeOpacity: 0.8 },
|
|
56
|
-
React.createElement(Icon, { name: "grid", width:
|
|
56
|
+
React.createElement(Icon, { name: "grid", width: 12, height: 12, marginRight: 6 }),
|
|
57
57
|
React.createElement(SectionHeaderText, { selected: selected }, title)));
|
|
58
58
|
});
|
|
59
59
|
const ItemTouchable = styled.TouchableOpacity({
|
|
@@ -74,7 +74,7 @@ const ListItem = React.memo(({ storyId, kind, title, isLastItem, onPress }) => {
|
|
|
74
74
|
const selected = useIsStorySelected(storyId);
|
|
75
75
|
const sectionSelected = useIsStorySectionSelected(kind);
|
|
76
76
|
return (React.createElement(ItemTouchable, { key: title, onPress: onPress, activeOpacity: 0.8, testID: `Storybook.ListItem.${kind}.${title}`, accessibilityLabel: `Storybook.ListItem.${title}`, selected: selected, sectionSelected: sectionSelected, isLastItem: isLastItem },
|
|
77
|
-
React.createElement(Icon, { name: selected ? 'story-white' : 'story-blue', marginRight: 6 }),
|
|
77
|
+
React.createElement(Icon, { width: 14, height: 14, name: selected ? 'story-white' : 'story-blue', marginRight: 6 }),
|
|
78
78
|
React.createElement(StoryNameText, { selected: selected }, title)));
|
|
79
79
|
}, (prevProps, nextProps) => prevProps.storyId === nextProps.storyId);
|
|
80
80
|
const getStories = (storyIndex) => {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { Text, Keyboard } from 'react-native';
|
|
3
|
-
import { useStoryContext } from '../../../hooks';
|
|
3
|
+
import { useStoryContext, useTheme } from '../../../hooks';
|
|
4
4
|
import { Box } from '../Shared/layout';
|
|
5
5
|
/**
|
|
6
6
|
* This is a handler for `onStartShouldSetResponder`, which dismisses the
|
|
@@ -20,9 +20,10 @@ function dismissOnStartResponder() {
|
|
|
20
20
|
const StoryView = () => {
|
|
21
21
|
const context = useStoryContext();
|
|
22
22
|
const id = context === null || context === void 0 ? void 0 : context.id;
|
|
23
|
+
const { backgroundColor } = useTheme();
|
|
23
24
|
if (context && context.unboundStoryFn) {
|
|
24
25
|
const { unboundStoryFn: StoryComponent } = context;
|
|
25
|
-
return (React.createElement(Box, { flex: true, key: id, testID: id, onStartShouldSetResponder: dismissOnStartResponder }, StoryComponent && React.createElement(StoryComponent, Object.assign({}, context))));
|
|
26
|
+
return (React.createElement(Box, { flex: true, key: id, testID: id, onStartShouldSetResponder: dismissOnStartResponder, backgroundColor: backgroundColor }, StoryComponent && React.createElement(StoryComponent, Object.assign({}, context))));
|
|
26
27
|
}
|
|
27
28
|
return (React.createElement(Box, { flex: true, padding: 16, alignItems: "center", justifyContent: "center" },
|
|
28
29
|
React.createElement(Text, null, "Please open the sidebar and select a story to preview.")));
|
package/dist/preview/start.d.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
/// <reference types="webpack-env" />
|
|
2
2
|
/// <reference types="node" />
|
|
3
|
+
import { ClientApi } from '@storybook/client-api';
|
|
3
4
|
import { Loadable } from '@storybook/core-client';
|
|
5
|
+
import type { ArgsStoryFn } from '@storybook/csf';
|
|
4
6
|
import { PreviewWeb } from '@storybook/preview-web';
|
|
5
|
-
import { ClientApi } from '@storybook/client-api';
|
|
6
7
|
import type { ReactNativeFramework } from '../types/types-6.0';
|
|
7
8
|
import { View } from './View';
|
|
8
|
-
import type { ArgsStoryFn } from '@storybook/csf';
|
|
9
9
|
export declare const render: ArgsStoryFn<ReactNativeFramework>;
|
|
10
10
|
export declare function start(): {
|
|
11
11
|
view: View;
|
package/dist/preview/start.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import Channel from '@storybook/channels';
|
|
3
1
|
import { addons } from '@storybook/addons';
|
|
2
|
+
import Channel from '@storybook/channels';
|
|
3
|
+
import { ClientApi, setGlobalRender } from '@storybook/client-api';
|
|
4
4
|
import Events from '@storybook/core-events';
|
|
5
5
|
import { PreviewWeb } from '@storybook/preview-web';
|
|
6
|
-
import
|
|
7
|
-
import { View } from './View';
|
|
6
|
+
import React from 'react';
|
|
8
7
|
import { executeLoadableForChanges } from './executeLoadable';
|
|
8
|
+
import { View } from './View';
|
|
9
9
|
export const render = (args, context) => {
|
|
10
10
|
const { id, component: Component } = context;
|
|
11
11
|
if (!Component) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@storybook/react-native",
|
|
3
|
-
"version": "6.5.0
|
|
3
|
+
"version": "6.5.0",
|
|
4
4
|
"description": "A better way to develop React Native Components for your app",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"react",
|
|
@@ -87,5 +87,5 @@
|
|
|
87
87
|
"publishConfig": {
|
|
88
88
|
"access": "public"
|
|
89
89
|
},
|
|
90
|
-
"gitHead": "
|
|
90
|
+
"gitHead": "35d882320519d7130219eb060f3aee86caeacd3a"
|
|
91
91
|
}
|