@storybook/react-native 6.0.1-alpha.6 → 6.0.1-alpha.7

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.
@@ -11,12 +11,14 @@ import { getAddonPanelPosition, getNavigatorPanelPosition, getPreviewPosition, g
11
11
  import Navigation from './navigation';
12
12
  import { PREVIEW, ADDONS } from './navigation/constants';
13
13
  import Panel from './Panel';
14
+ import { useWindowDimensions } from 'react-native';
14
15
  const ANIMATION_DURATION = 300;
15
16
  const IS_IOS = Platform.OS === 'ios';
16
17
  // @ts-ignore: Property 'Expo' does not exist on type 'Global'
17
18
  const getExpoRoot = () => global.Expo || global.__expo || global.__exponent;
18
19
  export const IS_EXPO = getExpoRoot() !== undefined;
19
20
  const IS_ANDROID = Platform.OS === 'android';
21
+ const BREAKPOINT = 1024;
20
22
  const flex = { flex: 1 };
21
23
  const Preview = styled.View(flex, ({ disabled, theme }) => ({
22
24
  borderLeftWidth: disabled ? 0 : 1,
@@ -62,6 +64,7 @@ const OnDeviceUI = ({ storyStore, isUIHidden, shouldDisableKeyboardAvoidingView,
62
64
  });
63
65
  const story = useSelectedStory(storyStore);
64
66
  const animatedValue = useRef(new Animated.Value(tabOpen));
67
+ const wide = useWindowDimensions().width >= BREAKPOINT;
65
68
  const handleToggleTab = (newTabOpen) => {
66
69
  if (newTabOpen === tabOpen) {
67
70
  return;
@@ -81,9 +84,9 @@ const OnDeviceUI = ({ storyStore, isUIHidden, shouldDisableKeyboardAvoidingView,
81
84
  };
82
85
  const previewWrapperStyles = [
83
86
  flex,
84
- getPreviewPosition(animatedValue.current, previewDimensions, slideBetweenAnimation),
87
+ getPreviewPosition(animatedValue.current, previewDimensions, slideBetweenAnimation, wide),
85
88
  ];
86
- const previewStyles = [flex, getPreviewScale(animatedValue.current, slideBetweenAnimation)];
89
+ const previewStyles = [flex, getPreviewScale(animatedValue.current, slideBetweenAnimation, wide)];
87
90
  return (React.createElement(SafeAreaView, { style: [flex, IS_ANDROID && IS_EXPO && styles.expoAndroidContainer] },
88
91
  React.createElement(KeyboardAvoidingView, { enabled: !shouldDisableKeyboardAvoidingView || tabOpen !== PREVIEW, behavior: IS_IOS ? 'padding' : null, keyboardVerticalOffset: keyboardAvoidingViewVerticalOffset, style: flex },
89
92
  React.createElement(AbsolutePositionedKeyboardAwareView, { onLayout: setPreviewDimensions, previewDimensions: previewDimensions },
@@ -92,9 +95,9 @@ const OnDeviceUI = ({ storyStore, isUIHidden, shouldDisableKeyboardAvoidingView,
92
95
  React.createElement(Preview, { disabled: tabOpen === PREVIEW },
93
96
  React.createElement(StoryView, { story: story })),
94
97
  tabOpen !== PREVIEW ? (React.createElement(TouchableOpacity, { style: absolutePosition, onPress: () => handleToggleTab(PREVIEW) })) : null)),
95
- React.createElement(Panel, { style: getNavigatorPanelPosition(animatedValue.current, previewDimensions.width) },
98
+ React.createElement(Panel, { style: getNavigatorPanelPosition(animatedValue.current, previewDimensions.width, wide) },
96
99
  React.createElement(StoryListView, { storyStore: storyStore, selectedStory: story })),
97
- React.createElement(Panel, { style: getAddonPanelPosition(animatedValue.current, previewDimensions.width) },
100
+ React.createElement(Panel, { style: getAddonPanelPosition(animatedValue.current, previewDimensions.width, wide) },
98
101
  React.createElement(Addons, { active: tabOpen === ADDONS }))),
99
102
  React.createElement(Navigation, { tabOpen: tabOpen, onChangeTab: handleToggleTab, initialUiVisible: !isUIHidden }))));
100
103
  };
@@ -1,18 +1,18 @@
1
1
  import { Animated } from 'react-native';
2
2
  import { PreviewDimens } from './absolute-positioned-keyboard-aware-view';
3
- export declare const getNavigatorPanelPosition: (animatedValue: Animated.Value, previewWidth: number) => {
3
+ export declare const getNavigatorPanelPosition: (animatedValue: Animated.Value, previewWidth: number, wide: boolean) => {
4
4
  transform: {
5
5
  translateX: Animated.AnimatedInterpolation;
6
6
  }[];
7
7
  width: number;
8
8
  }[];
9
- export declare const getAddonPanelPosition: (animatedValue: Animated.Value, previewWidth: number) => {
9
+ export declare const getAddonPanelPosition: (animatedValue: Animated.Value, previewWidth: number, wide: boolean) => {
10
10
  transform: {
11
11
  translateX: Animated.AnimatedInterpolation;
12
12
  }[];
13
13
  width: number;
14
14
  }[];
15
- export declare const getPreviewPosition: (animatedValue: Animated.Value, { width: previewWidth, height: previewHeight }: PreviewDimens, slideBetweenAnimation: boolean) => {
15
+ export declare const getPreviewPosition: (animatedValue: Animated.Value, { width: previewWidth, height: previewHeight }: PreviewDimens, slideBetweenAnimation: boolean, wide: boolean) => {
16
16
  transform: ({
17
17
  translateX: Animated.AnimatedInterpolation;
18
18
  translateY?: undefined;
@@ -21,7 +21,7 @@ export declare const getPreviewPosition: (animatedValue: Animated.Value, { width
21
21
  translateX?: undefined;
22
22
  })[];
23
23
  };
24
- export declare const getPreviewScale: (animatedValue: Animated.Value, slideBetweenAnimation: boolean) => {
24
+ export declare const getPreviewScale: (animatedValue: Animated.Value, slideBetweenAnimation: boolean, wide: boolean) => {
25
25
  transform: {
26
26
  scale: Animated.AnimatedInterpolation;
27
27
  }[];
@@ -1,39 +1,47 @@
1
1
  import { NAVIGATOR, PREVIEW, ADDONS } from './navigation/constants';
2
2
  const PREVIEW_SCALE = 0.3;
3
- const panelWidth = (width) => width * (1 - PREVIEW_SCALE - 0.05);
4
- export const getNavigatorPanelPosition = (animatedValue, previewWidth) => {
3
+ const PREVIEW_WIDE_SCREEN = 0.7;
4
+ const SCALE_OFFSET = 0.025;
5
+ const TRANSLATE_X_OFFSET = 6;
6
+ const TRANSLATE_Y_OFFSET = 12;
7
+ const panelWidth = (width, wide) => {
8
+ const scale = wide ? PREVIEW_WIDE_SCREEN : PREVIEW_SCALE;
9
+ return width * (1 - scale - SCALE_OFFSET);
10
+ };
11
+ export const getNavigatorPanelPosition = (animatedValue, previewWidth, wide) => {
5
12
  return [
6
13
  {
7
14
  transform: [
8
15
  {
9
16
  translateX: animatedValue.interpolate({
10
17
  inputRange: [NAVIGATOR, PREVIEW],
11
- outputRange: [0, -panelWidth(previewWidth) - 1],
18
+ outputRange: [0, -panelWidth(previewWidth, wide) - 1],
12
19
  }),
13
20
  },
14
21
  ],
15
- width: panelWidth(previewWidth),
22
+ width: panelWidth(previewWidth, wide),
16
23
  },
17
24
  ];
18
25
  };
19
- export const getAddonPanelPosition = (animatedValue, previewWidth) => {
26
+ export const getAddonPanelPosition = (animatedValue, previewWidth, wide) => {
20
27
  return [
21
28
  {
22
29
  transform: [
23
30
  {
24
31
  translateX: animatedValue.interpolate({
25
32
  inputRange: [PREVIEW, ADDONS],
26
- outputRange: [previewWidth, previewWidth - panelWidth(previewWidth)],
33
+ outputRange: [previewWidth, previewWidth - panelWidth(previewWidth, wide)],
27
34
  }),
28
35
  },
29
36
  ],
30
- width: panelWidth(previewWidth),
37
+ width: panelWidth(previewWidth, wide),
31
38
  },
32
39
  ];
33
40
  };
34
- export const getPreviewPosition = (animatedValue, { width: previewWidth, height: previewHeight }, slideBetweenAnimation) => {
35
- const translateX = previewWidth / 2 - (previewWidth * PREVIEW_SCALE) / 2 - 6;
36
- const translateY = -(previewHeight / 2 - (previewHeight * PREVIEW_SCALE) / 2 - 12);
41
+ export const getPreviewPosition = (animatedValue, { width: previewWidth, height: previewHeight }, slideBetweenAnimation, wide) => {
42
+ const scale = wide ? PREVIEW_WIDE_SCREEN : PREVIEW_SCALE;
43
+ const translateX = previewWidth / 2 - (previewWidth * scale) / 2 - TRANSLATE_X_OFFSET;
44
+ const translateY = -(previewHeight / 2 - (previewHeight * scale) / 2 - TRANSLATE_Y_OFFSET);
37
45
  return {
38
46
  transform: [
39
47
  {
@@ -51,13 +59,14 @@ export const getPreviewPosition = (animatedValue, { width: previewWidth, height:
51
59
  ],
52
60
  };
53
61
  };
54
- export const getPreviewScale = (animatedValue, slideBetweenAnimation) => {
62
+ export const getPreviewScale = (animatedValue, slideBetweenAnimation, wide) => {
63
+ const scale = wide ? PREVIEW_WIDE_SCREEN : PREVIEW_SCALE;
55
64
  return {
56
65
  transform: [
57
66
  {
58
67
  scale: animatedValue.interpolate({
59
68
  inputRange: [NAVIGATOR, PREVIEW, ADDONS],
60
- outputRange: [PREVIEW_SCALE, slideBetweenAnimation ? PREVIEW_SCALE : 1, PREVIEW_SCALE],
69
+ outputRange: [scale, slideBetweenAnimation ? scale : 1, scale],
61
70
  }),
62
71
  },
63
72
  ],
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@storybook/react-native",
3
- "version": "6.0.1-alpha.6",
3
+ "version": "6.0.1-alpha.7",
4
4
  "description": "A better way to develop React Native Components for your app",
5
5
  "keywords": [
6
6
  "react",
@@ -49,13 +49,13 @@
49
49
  "dependencies": {
50
50
  "@emotion/core": "^10.0.20",
51
51
  "@emotion/native": "^10.0.14",
52
- "@storybook/addons": "^6",
53
- "@storybook/channel-websocket": "^6",
54
- "@storybook/channels": "^6",
55
- "@storybook/client-api": "^6",
56
- "@storybook/client-logger": "^6",
57
- "@storybook/core-client": "^6",
58
- "@storybook/core-events": "^6",
52
+ "@storybook/addons": "~6.3",
53
+ "@storybook/channel-websocket": "~6.3",
54
+ "@storybook/channels": "~6.3",
55
+ "@storybook/client-api": "~6.3",
56
+ "@storybook/client-logger": "~6.3",
57
+ "@storybook/core-client": "~6.3",
58
+ "@storybook/core-events": "~6.3",
59
59
  "@storybook/csf": "0.0.1",
60
60
  "chokidar": "^3.5.1",
61
61
  "commander": "^8.2.0",
@@ -82,5 +82,5 @@
82
82
  "publishConfig": {
83
83
  "access": "public"
84
84
  },
85
- "gitHead": "b6ba9b0447f286acc87d254538b7e5059ebbee96"
85
+ "gitHead": "3fdd3ec63a08afe4a067d4298c9b39fd3d74fd04"
86
86
  }