diff --git a/configs/all-devices.json b/configs/all-devices.json index 194c9824..15dc86bd 100644 --- a/configs/all-devices.json +++ b/configs/all-devices.json @@ -1,5 +1,5 @@ { - "exclude": ["ManyStories"], + "include": ["TestInfo"], "devices": [ { "id": "pixel.7.pro", diff --git a/testing/expo-storybook-8/src/components/TestInfo/ExpoUpdateInfo.stories.tsx b/testing/expo-storybook-8/src/components/TestInfo/ExpoUpdateInfo.stories.tsx new file mode 100644 index 00000000..51c43deb --- /dev/null +++ b/testing/expo-storybook-8/src/components/TestInfo/ExpoUpdateInfo.stories.tsx @@ -0,0 +1,13 @@ +import { ExpoUpdateInfo, StoryDecorator } from '@sherlo/testing-components'; +import type { Meta } from '@storybook/react'; + +/** + * This is a test screen that we add to our tests + * to display information about device and app configuration + */ +export default { + component: ExpoUpdateInfo, + decorators: [StoryDecorator({ placement: 'center' })], +} as Meta; + +export const Basic = {}; diff --git a/testing/testing-components/src/components/ExpoUpdateInfo.tsx b/testing/testing-components/src/components/ExpoUpdateInfo.tsx new file mode 100644 index 00000000..2bd86b6b --- /dev/null +++ b/testing/testing-components/src/components/ExpoUpdateInfo.tsx @@ -0,0 +1,47 @@ +import React from 'react'; +import { View, StyleSheet } from 'react-native'; +import * as Updates from 'expo-updates'; +import InfoItem from './InfoItem'; + +const ExpoUpdateInfo = () => { + return ( + + {Updates.updateId ? ( + <> + + + + + ) : ( + + )} + + ); +}; + +const styles = StyleSheet.create({ + container: { + flex: 1, + width: '100%', + justifyContent: 'center', + alignItems: 'center', + padding: 20, + paddingHorizontal: 20, + }, +}); + +export default ExpoUpdateInfo; diff --git a/testing/testing-components/src/components/InfoItem.tsx b/testing/testing-components/src/components/InfoItem.tsx new file mode 100644 index 00000000..2d185af3 --- /dev/null +++ b/testing/testing-components/src/components/InfoItem.tsx @@ -0,0 +1,31 @@ +import React from 'react'; +import { Text, View, StyleSheet, useColorScheme } from 'react-native'; +import { MaterialIcons } from '@expo/vector-icons'; + +export const InfoItem: React.FC<{ + iconName?: React.ComponentProps['name']; + text?: string; +}> = ({ iconName, text }) => { + const theme = useColorScheme(); + const textColor = theme === 'dark' ? '#FFF' : '#333'; + return ( + + {iconName ? : null} + {text} + + ); +}; + +const styles = StyleSheet.create({ + infoContainer: { + flexDirection: 'row', + alignItems: 'center', + marginBottom: 20, + }, + text: { + fontSize: 12, + marginLeft: 10, + }, +}); + +export default InfoItem; diff --git a/testing/testing-components/src/components/TestInfo.tsx b/testing/testing-components/src/components/TestInfo.tsx index 68986281..c3026ad6 100644 --- a/testing/testing-components/src/components/TestInfo.tsx +++ b/testing/testing-components/src/components/TestInfo.tsx @@ -1,23 +1,8 @@ import React from 'react'; -import { Text, View, StyleSheet, StatusBar } from 'react-native'; -import { MaterialIcons } from '@expo/vector-icons'; -import * as Updates from 'expo-updates'; +import { View, StyleSheet } from 'react-native'; import * as Localization from 'expo-localization'; import { useColorScheme } from 'react-native'; - -const InfoItem: React.FC<{ - iconName?: React.ComponentProps['name']; - text?: string; -}> = ({ iconName, text }) => { - const theme = useColorScheme(); - const textColor = theme === 'dark' ? '#FFF' : '#333'; - return ( - - {iconName ? : null} - {text} - - ); -}; +import { InfoItem } from './InfoItem'; const TestScreen = () => { const theme = useColorScheme(); @@ -30,28 +15,6 @@ const TestScreen = () => { - - {Updates.updateId ? ( - <> - - - - - ) : null} ); }; @@ -71,7 +34,7 @@ const styles = StyleSheet.create({ marginBottom: 20, }, text: { - fontSize: 16, + fontSize: 12, marginLeft: 10, }, }); diff --git a/testing/testing-components/src/components/index.ts b/testing/testing-components/src/components/index.ts index 34f74844..7cb918ac 100644 --- a/testing/testing-components/src/components/index.ts +++ b/testing/testing-components/src/components/index.ts @@ -1 +1,2 @@ export { default as TestInfo } from './TestInfo'; +export { default as ExpoUpdateInfo } from './ExpoUpdateInfo';