diff --git a/app/components/UI/InfoRow/InfoRow.stories.tsx b/app/components/UI/InfoRow/InfoRow.stories.tsx new file mode 100644 index 00000000000..ebc368e8fd8 --- /dev/null +++ b/app/components/UI/InfoRow/InfoRow.stories.tsx @@ -0,0 +1,30 @@ +import React from 'react'; +import { storiesOf } from '@storybook/react-native'; +import { StyleProp, Text, TextStyle, View } from 'react-native'; + +import InfoRow from './InfoRow'; +import InfoSection from './InfoSection'; + +const style = { + container: { padding: 8 }, + title: { marginTop: 20, fontSize: 20, fontWeight: '700' }, +}; + +storiesOf('App Components / InfoRow', module) + .addDecorator((getStory) => getStory()) + .add('Default', () => ( + + }>Simple Info Row + + Value-Text + + }>Value wrapped + + + Value-Text Value-Text Value-Text Value-Text Value-Text Value-Text + Value-Text Value-Text Value-Text Value-Text Value-Text Value-Text + Value-Text Value-Text Value-Text Value-Text + + + + )); diff --git a/app/components/UI/InfoRow/InfoRow.test.tsx b/app/components/UI/InfoRow/InfoRow.test.tsx new file mode 100644 index 00000000000..96f1fc93ad2 --- /dev/null +++ b/app/components/UI/InfoRow/InfoRow.test.tsx @@ -0,0 +1,11 @@ +import React from 'react'; +import { render } from '@testing-library/react-native'; + +import InfoRow from './index'; + +describe('InfoRow', () => { + it('should match snapshot for simple text value', async () => { + const container = render(Value-Text); + expect(container).toMatchSnapshot(); + }); +}); diff --git a/app/components/UI/InfoRow/InfoRow.tsx b/app/components/UI/InfoRow/InfoRow.tsx new file mode 100644 index 00000000000..ddeff5c845b --- /dev/null +++ b/app/components/UI/InfoRow/InfoRow.tsx @@ -0,0 +1,30 @@ +import React from 'react'; +import { Text, View } from 'react-native'; + +import { useTheme } from '../../../util/theme'; +import createStyles from './style'; + +interface InfoRowProps { + label: string; + children: React.ReactNode | string; + tooltip?: string; +} + +const InfoRow = ({ label, children }: InfoRowProps) => { + const { colors } = useTheme(); + + const styles = createStyles(colors); + + return ( + + {label} + {typeof children === 'string' ? ( + {children} + ) : ( + children + )} + + ); +}; + +export default InfoRow; diff --git a/app/components/UI/InfoRow/InfoSection/InfoSection.test.tsx b/app/components/UI/InfoRow/InfoSection/InfoSection.test.tsx new file mode 100644 index 00000000000..b46df49d5d0 --- /dev/null +++ b/app/components/UI/InfoRow/InfoSection/InfoSection.test.tsx @@ -0,0 +1,18 @@ +import React from 'react'; +import { Text, View } from 'react-native'; +import { render } from '@testing-library/react-native'; + +import InfoSection from './index'; + +describe('InfoSection', () => { + it('should match snapshot for simple text value', async () => { + const container = render( + + + Test + + , + ); + expect(container).toMatchSnapshot(); + }); +}); diff --git a/app/components/UI/InfoRow/InfoSection/InfoSection.tsx b/app/components/UI/InfoRow/InfoSection/InfoSection.tsx new file mode 100644 index 00000000000..07c9e04c672 --- /dev/null +++ b/app/components/UI/InfoRow/InfoSection/InfoSection.tsx @@ -0,0 +1,18 @@ +import React from 'react'; +import { View } from 'react-native'; + +import { useTheme } from '../../../../util/theme'; +import createStyles from './style'; + +interface InfoSectionProps { + children: React.ReactNode | string; +} + +const InfoSection = ({ children }: InfoSectionProps) => { + const { colors } = useTheme(); + const styles = createStyles(colors); + + return {children}; +}; + +export default InfoSection; diff --git a/app/components/UI/InfoRow/InfoSection/__snapshots__/InfoSection.test.tsx.snap b/app/components/UI/InfoRow/InfoSection/__snapshots__/InfoSection.test.tsx.snap new file mode 100644 index 00000000000..1e393db2e3b --- /dev/null +++ b/app/components/UI/InfoRow/InfoSection/__snapshots__/InfoSection.test.tsx.snap @@ -0,0 +1,21 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`InfoSection should match snapshot for simple text value 1`] = ` + + + + Test + + + +`; diff --git a/app/components/UI/InfoRow/InfoSection/index.ts b/app/components/UI/InfoRow/InfoSection/index.ts new file mode 100644 index 00000000000..4a396fbea52 --- /dev/null +++ b/app/components/UI/InfoRow/InfoSection/index.ts @@ -0,0 +1 @@ +export { default } from './InfoSection'; diff --git a/app/components/UI/InfoRow/InfoSection/style.ts b/app/components/UI/InfoRow/InfoSection/style.ts new file mode 100644 index 00000000000..6c65859d747 --- /dev/null +++ b/app/components/UI/InfoRow/InfoSection/style.ts @@ -0,0 +1,16 @@ +import { StyleSheet } from 'react-native'; + +import { Colors } from '../../../../util/theme/models'; + +const createStyles = (colors: Colors) => + StyleSheet.create({ + container: { + backgroundColor: colors.background.default, + borderColor: colors.border.muted, + borderRadius: 8, + borderWidth: 1, + padding: 8, + }, + }); + +export default createStyles; diff --git a/app/components/UI/InfoRow/__snapshots__/InfoRow.test.tsx.snap b/app/components/UI/InfoRow/__snapshots__/InfoRow.test.tsx.snap new file mode 100644 index 00000000000..9eacf5d1d95 --- /dev/null +++ b/app/components/UI/InfoRow/__snapshots__/InfoRow.test.tsx.snap @@ -0,0 +1,43 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`InfoRow should match snapshot for simple text value 1`] = ` + + + label-Key + + + Value-Text + + +`; diff --git a/app/components/UI/InfoRow/index.ts b/app/components/UI/InfoRow/index.ts new file mode 100644 index 00000000000..7e89d7763fe --- /dev/null +++ b/app/components/UI/InfoRow/index.ts @@ -0,0 +1 @@ +export { default } from './InfoRow'; diff --git a/app/components/UI/InfoRow/style.ts b/app/components/UI/InfoRow/style.ts new file mode 100644 index 00000000000..e7990c6c7ae --- /dev/null +++ b/app/components/UI/InfoRow/style.ts @@ -0,0 +1,31 @@ +import { StyleSheet } from 'react-native'; + +import { Colors } from '../../../util/theme/models'; +import { fontStyles } from '../../../styles/common'; + +const createStyles = (colors: Colors) => + StyleSheet.create({ + container: { + display: 'flex', + flexDirection: 'row', + justifyContent: 'space-between', + flexWrap: 'wrap', + paddingBottom: 8, + paddingHorizontal: 8, + }, + label: { + color: colors.text.default, + ...fontStyles.bold, + fontSize: 14, + fontWeight: '500', + marginTop: 8, + }, + value: { + color: colors.text.default, + ...fontStyles.normal, + fontSize: 14, + marginTop: 8, + } + }); + +export default createStyles;