@storybook/react-native 6.5.0-rc.7 → 6.5.0-rc.9
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/constants.d.ts +1 -1
- package/dist/constants.js +1 -1
- package/dist/preview/components/OnDeviceUI/OnDeviceUI.js +7 -7
- package/dist/preview/components/OnDeviceUI/addons/Addons.js +11 -2
- package/dist/preview/components/OnDeviceUI/animation.d.ts +3 -3
- package/dist/preview/components/OnDeviceUI/animation.js +11 -11
- package/dist/preview/components/OnDeviceUI/navigation/NavigationBar.js +3 -3
- package/dist/preview/components/OnDeviceUI/navigation/constants.d.ts +2 -2
- package/dist/preview/components/OnDeviceUI/navigation/constants.js +2 -2
- package/dist/preview/components/StoryView/StoryView.js +1 -1
- package/package.json +2 -2
- package/readme.md +1 -1
package/dist/constants.d.ts
CHANGED
package/dist/constants.js
CHANGED
|
@@ -8,9 +8,9 @@ import StoryView from '../StoryView';
|
|
|
8
8
|
import AbsolutePositionedKeyboardAwareView from './absolute-positioned-keyboard-aware-view';
|
|
9
9
|
import Addons from './addons/Addons';
|
|
10
10
|
import { AddonsSkeleton } from './addons/AddonsSkeleton';
|
|
11
|
-
import { getAddonPanelPosition,
|
|
11
|
+
import { getAddonPanelPosition, getSidebarPanelPosition, getPreviewShadowStyle, getPreviewStyle, } from './animation';
|
|
12
12
|
import Navigation from './navigation';
|
|
13
|
-
import {
|
|
13
|
+
import { CANVAS, ADDONS } from './navigation/constants';
|
|
14
14
|
import Panel from './Panel';
|
|
15
15
|
import { useWindowDimensions } from 'react-native';
|
|
16
16
|
import { useSafeAreaInsets } from 'react-native-safe-area-context';
|
|
@@ -35,7 +35,7 @@ const styles = StyleSheet.create({
|
|
|
35
35
|
});
|
|
36
36
|
const Container = styled.View(({ theme }) => (Object.assign(Object.assign({ flex: 1, backgroundColor: theme.preview.containerBackgroundColor }, (IS_ANDROID && IS_EXPO ? styles.expoAndroidContainer : undefined)), Platform.select({ web: { overflow: 'hidden' } }))));
|
|
37
37
|
const OnDeviceUI = ({ storyIndex, shouldDisableKeyboardAvoidingView, keyboardAvoidingViewVerticalOffset, tabOpen: initialTabOpen, }) => {
|
|
38
|
-
const [tabOpen, setTabOpen] = useState(initialTabOpen ||
|
|
38
|
+
const [tabOpen, setTabOpen] = useState(initialTabOpen || CANVAS);
|
|
39
39
|
const lastTabOpen = React.useRef(tabOpen);
|
|
40
40
|
const [previewDimensions, setPreviewDimensions] = useState(() => ({
|
|
41
41
|
width: Dimensions.get('window').width,
|
|
@@ -57,7 +57,7 @@ const OnDeviceUI = ({ storyIndex, shouldDisableKeyboardAvoidingView, keyboardAvo
|
|
|
57
57
|
}).start();
|
|
58
58
|
setTabOpen(newTabOpen);
|
|
59
59
|
// close the keyboard opened from a TextInput from story list or knobs
|
|
60
|
-
if (newTabOpen ===
|
|
60
|
+
if (newTabOpen === CANVAS) {
|
|
61
61
|
Keyboard.dismiss();
|
|
62
62
|
}
|
|
63
63
|
}, [tabOpen]);
|
|
@@ -105,7 +105,7 @@ const OnDeviceUI = ({ storyIndex, shouldDisableKeyboardAvoidingView, keyboardAvo
|
|
|
105
105
|
// for the safe area and navigation bar.
|
|
106
106
|
const keyboardVerticalOffset = -panelSafeAreaMargins.paddingBottom + (keyboardAvoidingViewVerticalOffset !== null && keyboardAvoidingViewVerticalOffset !== void 0 ? keyboardAvoidingViewVerticalOffset : 0);
|
|
107
107
|
const [isSplitPanelVisible] = useIsSplitPanelVisible();
|
|
108
|
-
const isPreviewInactive = tabOpen !==
|
|
108
|
+
const isPreviewInactive = tabOpen !== CANVAS;
|
|
109
109
|
return (React.createElement(React.Fragment, null,
|
|
110
110
|
React.createElement(Container, null,
|
|
111
111
|
React.createElement(KeyboardAvoidingView, { enabled: !shouldDisableKeyboardAvoidingView || isPreviewInactive, behavior: IS_IOS ? 'padding' : null, keyboardVerticalOffset: keyboardVerticalOffset, style: flex },
|
|
@@ -116,9 +116,9 @@ const OnDeviceUI = ({ storyIndex, shouldDisableKeyboardAvoidingView, keyboardAvo
|
|
|
116
116
|
isSplitPanelVisible ? (React.createElement(Panel, { edge: "top", style: { flex: 1 } },
|
|
117
117
|
React.createElement(Addons, { active: true }),
|
|
118
118
|
React.createElement(AddonsSkeleton, { visible: isPreviewInactive }))) : null),
|
|
119
|
-
isPreviewInactive ? (React.createElement(TouchableOpacity, { style: StyleSheet.absoluteFillObject, onPress: () => handleToggleTab(
|
|
119
|
+
isPreviewInactive ? (React.createElement(TouchableOpacity, { style: StyleSheet.absoluteFillObject, onPress: () => handleToggleTab(CANVAS) })) : null),
|
|
120
120
|
React.createElement(Panel, { edge: "right", style: [
|
|
121
|
-
|
|
121
|
+
getSidebarPanelPosition(animatedValue.current, previewDimensions.width, wide),
|
|
122
122
|
panelSafeAreaMargins,
|
|
123
123
|
] },
|
|
124
124
|
React.createElement(StoryListView, { storyIndex: storyIndex })),
|
|
@@ -1,13 +1,22 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import { Text } from 'react-native';
|
|
3
2
|
import { addons } from '@storybook/addons';
|
|
4
|
-
import { useSelectedAddon } from '../../../../hooks';
|
|
3
|
+
import { useSelectedAddon, useStoryContext } from '../../../../hooks';
|
|
5
4
|
import AddonsList from './List';
|
|
6
5
|
import AddonWrapper from './Wrapper';
|
|
7
6
|
import { Box } from '../../Shared/layout';
|
|
7
|
+
import styled from '@emotion/native';
|
|
8
|
+
const Text = styled.Text(({ theme }) => ({
|
|
9
|
+
marginTop: theme.tokens.spacing4,
|
|
10
|
+
}));
|
|
8
11
|
const Addons = ({ active }) => {
|
|
9
12
|
const panels = addons.getElements('panel');
|
|
10
13
|
const [addonSelected, setAddonSelected] = useSelectedAddon(Object.keys(panels)[0]);
|
|
14
|
+
const context = useStoryContext();
|
|
15
|
+
const id = context === null || context === void 0 ? void 0 : context.id;
|
|
16
|
+
if (!id) {
|
|
17
|
+
return (React.createElement(Box, { alignItems: "center", justifyContent: "center" },
|
|
18
|
+
React.createElement(Text, null, "No Story Selected")));
|
|
19
|
+
}
|
|
11
20
|
if (Object.keys(panels).length === 0) {
|
|
12
21
|
return (React.createElement(Box, { alignItems: "center", justifyContent: "center" },
|
|
13
22
|
React.createElement(Text, null, "No addons loaded.")));
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Animated, Insets } from 'react-native';
|
|
2
2
|
import { PreviewDimens } from './absolute-positioned-keyboard-aware-view';
|
|
3
|
-
export declare const
|
|
3
|
+
export declare const getSidebarPanelPosition: (animatedValue: Animated.Value, previewWidth: number, wide: boolean) => {
|
|
4
4
|
transform: {
|
|
5
5
|
translateX: Animated.AnimatedInterpolation<string | number>;
|
|
6
6
|
}[];
|
|
@@ -23,7 +23,7 @@ type PreviewPositionArgs = {
|
|
|
23
23
|
/**
|
|
24
24
|
* Build the animated style for the preview container view.
|
|
25
25
|
*
|
|
26
|
-
* When the
|
|
26
|
+
* When the sidebar or addons panel is focused, the preview container is
|
|
27
27
|
* scaled down and translated to the left (or right) of the panel.
|
|
28
28
|
*/
|
|
29
29
|
export declare const getPreviewStyle: ({ animatedValue, previewDimensions: { width: previewWidth, height: previewHeight }, wide, insets, tabOpen, lastTabOpen, }: PreviewPositionArgs) => {
|
|
@@ -44,7 +44,7 @@ export declare const getPreviewStyle: ({ animatedValue, previewDimensions: { wid
|
|
|
44
44
|
/**
|
|
45
45
|
* Build the animated shadow style for the preview.
|
|
46
46
|
*
|
|
47
|
-
* When the
|
|
47
|
+
* When the sidebar or addons panel are visible the scaled preview will have
|
|
48
48
|
* a shadow, and when going to the preview tab the shadow will be invisible.
|
|
49
49
|
*/
|
|
50
50
|
export declare const getPreviewShadowStyle: (animatedValue: Animated.Value) => {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { I18nManager } from 'react-native';
|
|
2
|
-
import {
|
|
2
|
+
import { SIDEBAR, CANVAS, ADDONS } from './navigation/constants';
|
|
3
3
|
// Factor that will flip the animation orientation in RTL locales.
|
|
4
4
|
const RTL_SCALE = I18nManager.isRTL ? -1 : 1;
|
|
5
5
|
// Percentage to scale the preview area by when opening a panel.
|
|
@@ -14,13 +14,13 @@ const panelWidth = (width, wide) => {
|
|
|
14
14
|
const scale = wide ? PREVIEW_SCALE_WIDE : PREVIEW_SCALE;
|
|
15
15
|
return width * (1 - scale - SCALE_OFFSET);
|
|
16
16
|
};
|
|
17
|
-
export const
|
|
17
|
+
export const getSidebarPanelPosition = (animatedValue, previewWidth, wide) => {
|
|
18
18
|
return [
|
|
19
19
|
{
|
|
20
20
|
transform: [
|
|
21
21
|
{
|
|
22
22
|
translateX: animatedValue.interpolate({
|
|
23
|
-
inputRange: [
|
|
23
|
+
inputRange: [SIDEBAR, CANVAS],
|
|
24
24
|
outputRange: [0, (-panelWidth(previewWidth, wide) - 1) * RTL_SCALE],
|
|
25
25
|
}),
|
|
26
26
|
},
|
|
@@ -35,7 +35,7 @@ export const getAddonPanelPosition = (animatedValue, previewWidth, wide) => {
|
|
|
35
35
|
transform: [
|
|
36
36
|
{
|
|
37
37
|
translateX: animatedValue.interpolate({
|
|
38
|
-
inputRange: [
|
|
38
|
+
inputRange: [CANVAS, ADDONS],
|
|
39
39
|
outputRange: [
|
|
40
40
|
previewWidth * RTL_SCALE,
|
|
41
41
|
(previewWidth - panelWidth(previewWidth, wide)) * RTL_SCALE,
|
|
@@ -50,7 +50,7 @@ export const getAddonPanelPosition = (animatedValue, previewWidth, wide) => {
|
|
|
50
50
|
/**
|
|
51
51
|
* Build the animated style for the preview container view.
|
|
52
52
|
*
|
|
53
|
-
* When the
|
|
53
|
+
* When the sidebar or addons panel is focused, the preview container is
|
|
54
54
|
* scaled down and translated to the left (or right) of the panel.
|
|
55
55
|
*/
|
|
56
56
|
export const getPreviewStyle = ({ animatedValue, previewDimensions: { width: previewWidth, height: previewHeight }, wide, insets, tabOpen, lastTabOpen, }) => {
|
|
@@ -65,24 +65,24 @@ export const getPreviewStyle = ({ animatedValue, previewDimensions: { width: pre
|
|
|
65
65
|
// safe area inset, then by the preview Y offset.
|
|
66
66
|
const translateY = -(previewHeight / 2 - scaledPreviewHeight / 2) + insets.top + TRANSLATE_Y_OFFSET;
|
|
67
67
|
// Is navigation moving from one panel to another, skipping preview?
|
|
68
|
-
const skipPreview = lastTabOpen !==
|
|
68
|
+
const skipPreview = lastTabOpen !== CANVAS && tabOpen !== CANVAS;
|
|
69
69
|
return {
|
|
70
70
|
transform: [
|
|
71
71
|
{
|
|
72
72
|
translateX: animatedValue.interpolate({
|
|
73
|
-
inputRange: [
|
|
73
|
+
inputRange: [SIDEBAR, CANVAS, ADDONS],
|
|
74
74
|
outputRange: [translateX, 0, -translateX],
|
|
75
75
|
}),
|
|
76
76
|
},
|
|
77
77
|
{
|
|
78
78
|
translateY: animatedValue.interpolate({
|
|
79
|
-
inputRange: [
|
|
79
|
+
inputRange: [SIDEBAR, CANVAS, ADDONS],
|
|
80
80
|
outputRange: [translateY, skipPreview ? translateY : 0, translateY],
|
|
81
81
|
}),
|
|
82
82
|
},
|
|
83
83
|
{
|
|
84
84
|
scale: animatedValue.interpolate({
|
|
85
|
-
inputRange: [
|
|
85
|
+
inputRange: [SIDEBAR, CANVAS, ADDONS],
|
|
86
86
|
outputRange: [scale, skipPreview ? scale : 1, scale],
|
|
87
87
|
}),
|
|
88
88
|
},
|
|
@@ -92,14 +92,14 @@ export const getPreviewStyle = ({ animatedValue, previewDimensions: { width: pre
|
|
|
92
92
|
/**
|
|
93
93
|
* Build the animated shadow style for the preview.
|
|
94
94
|
*
|
|
95
|
-
* When the
|
|
95
|
+
* When the sidebar or addons panel are visible the scaled preview will have
|
|
96
96
|
* a shadow, and when going to the preview tab the shadow will be invisible.
|
|
97
97
|
*/
|
|
98
98
|
export const getPreviewShadowStyle = (animatedValue) => ({
|
|
99
99
|
elevation: 8,
|
|
100
100
|
shadowColor: '#000',
|
|
101
101
|
shadowOpacity: animatedValue.interpolate({
|
|
102
|
-
inputRange: [
|
|
102
|
+
inputRange: [SIDEBAR, CANVAS, ADDONS],
|
|
103
103
|
outputRange: [0.25, 0, 0.25],
|
|
104
104
|
}),
|
|
105
105
|
shadowRadius: 8,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import styled from '@emotion/native';
|
|
3
|
-
import {
|
|
3
|
+
import { SIDEBAR, CANVAS, ADDONS } from './constants';
|
|
4
4
|
import { TabBar, TabButton } from '../../Shared/tabs';
|
|
5
5
|
const NavigationTabBar = styled(TabBar)(({ theme }) => ({
|
|
6
6
|
paddingHorizontal: theme.tokens.spacing2,
|
|
@@ -9,6 +9,6 @@ const NavigationTabBar = styled(TabBar)(({ theme }) => ({
|
|
|
9
9
|
borderTopWidth: theme.navigation.borderWidth,
|
|
10
10
|
}));
|
|
11
11
|
export const NavigationBar = React.memo(({ index, onPress, style }) => (React.createElement(NavigationTabBar, { style: style },
|
|
12
|
-
React.createElement(TabButton, { onPress: onPress, testID: "BottomMenu.
|
|
13
|
-
React.createElement(TabButton, { onPress: onPress, testID: "BottomMenu.
|
|
12
|
+
React.createElement(TabButton, { onPress: onPress, testID: "BottomMenu.Sidebar", id: SIDEBAR, active: index === SIDEBAR }, "SIDEBAR"),
|
|
13
|
+
React.createElement(TabButton, { onPress: onPress, testID: "BottomMenu.Canvas", id: CANVAS, active: index === CANVAS }, "CANVAS"),
|
|
14
14
|
React.createElement(TabButton, { onPress: onPress, testID: "BottomMenu.Addons", id: ADDONS, active: index === ADDONS }, "ADDONS"))));
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export declare const
|
|
2
|
-
export declare const
|
|
1
|
+
export declare const SIDEBAR = -1;
|
|
2
|
+
export declare const CANVAS = 0;
|
|
3
3
|
export declare const ADDONS = 1;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export const
|
|
2
|
-
export const
|
|
1
|
+
export const SIDEBAR = -1;
|
|
2
|
+
export const CANVAS = 0;
|
|
3
3
|
export const ADDONS = 1;
|
|
@@ -25,6 +25,6 @@ const StoryView = () => {
|
|
|
25
25
|
return (React.createElement(Box, { flex: true, key: id, testID: id, onStartShouldSetResponder: dismissOnStartResponder }, StoryComponent && React.createElement(StoryComponent, Object.assign({}, context))));
|
|
26
26
|
}
|
|
27
27
|
return (React.createElement(Box, { flex: true, padding: 16, alignItems: "center", justifyContent: "center" },
|
|
28
|
-
React.createElement(Text, null, "Please open
|
|
28
|
+
React.createElement(Text, null, "Please open the sidebar and select a story to preview.")));
|
|
29
29
|
};
|
|
30
30
|
export default React.memo(StoryView);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@storybook/react-native",
|
|
3
|
-
"version": "6.5.0-rc.
|
|
3
|
+
"version": "6.5.0-rc.9",
|
|
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": "17d380c54711d3b2f2a27853aa4bc1f731b6d6ff"
|
|
91
91
|
}
|
package/readme.md
CHANGED
|
@@ -199,7 +199,7 @@ You can pass these parameters to getStorybookUI call in your storybook entry poi
|
|
|
199
199
|
```
|
|
200
200
|
{
|
|
201
201
|
tabOpen: Number (0)
|
|
202
|
-
-- which tab should be open. -1
|
|
202
|
+
-- which tab should be open. -1 SideBar, 0 Canvas, 1 Addons
|
|
203
203
|
initialSelection: string | Object (undefined)
|
|
204
204
|
-- initialize storybook with a specific story. eg: `mybutton--largebutton` or `{ kind: 'MyButton', name: 'LargeButton' }`
|
|
205
205
|
shouldDisableKeyboardAvoidingView: Boolean (false)
|