Chore: add footnote component
This commit is contained in:
+3
-28
@@ -4,7 +4,9 @@ import PropTypes from 'prop-types'
|
|||||||
import moment from 'moment'
|
import moment from 'moment'
|
||||||
|
|
||||||
import AppText from './common/app-text'
|
import AppText from './common/app-text'
|
||||||
|
import Asterisk from './common/Asterisk'
|
||||||
import Button from './common/button'
|
import Button from './common/button'
|
||||||
|
import Footnote from './common/Footnote'
|
||||||
|
|
||||||
import cycleModule from '../lib/cycle'
|
import cycleModule from '../lib/cycle'
|
||||||
import { getFertilityStatusForDay } from '../lib/sympto-adapter'
|
import { getFertilityStatusForDay } from '../lib/sympto-adapter'
|
||||||
@@ -69,26 +71,12 @@ const Home = ({ navigate, setDate }) => {
|
|||||||
<Button isCTA isSmall={false} onPress={navigateToCycleDayView}>
|
<Button isCTA isSmall={false} onPress={navigateToCycleDayView}>
|
||||||
{t('labels.home.addDataForToday')}
|
{t('labels.home.addDataForToday')}
|
||||||
</Button>
|
</Button>
|
||||||
{phase && (
|
{phase && <Footnote>{statusText}</Footnote>}
|
||||||
<View style={styles.asteriskLine}>
|
|
||||||
<Asterisk />
|
|
||||||
<AppText linkStyle={styles.whiteText} style={styles.greyText}>
|
|
||||||
{statusText}
|
|
||||||
</AppText>
|
|
||||||
</View>
|
|
||||||
)}
|
|
||||||
</ScrollView>
|
</ScrollView>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
const Asterisk = () => {
|
|
||||||
return <AppText style={styles.asterisk}>*</AppText>
|
|
||||||
}
|
|
||||||
|
|
||||||
const styles = StyleSheet.create({
|
const styles = StyleSheet.create({
|
||||||
asterisk: {
|
|
||||||
color: Colors.orange,
|
|
||||||
},
|
|
||||||
container: {
|
container: {
|
||||||
backgroundColor: Colors.purple,
|
backgroundColor: Colors.purple,
|
||||||
flex: 1,
|
flex: 1,
|
||||||
@@ -104,12 +92,6 @@ const styles = StyleSheet.create({
|
|||||||
marginBottom: Spacing.tiny,
|
marginBottom: Spacing.tiny,
|
||||||
marginTop: Spacing.small,
|
marginTop: Spacing.small,
|
||||||
},
|
},
|
||||||
asteriskLine: {
|
|
||||||
flexDirection: 'row',
|
|
||||||
alignContent: 'flex-start',
|
|
||||||
marginBottom: Spacing.tiny,
|
|
||||||
marginTop: Spacing.small,
|
|
||||||
},
|
|
||||||
title: {
|
title: {
|
||||||
color: Colors.purpleLight,
|
color: Colors.purpleLight,
|
||||||
fontFamily: Fonts.bold,
|
fontFamily: Fonts.bold,
|
||||||
@@ -124,13 +106,6 @@ const styles = StyleSheet.create({
|
|||||||
color: 'white',
|
color: 'white',
|
||||||
fontSize: Sizes.subtitle,
|
fontSize: Sizes.subtitle,
|
||||||
},
|
},
|
||||||
whiteText: {
|
|
||||||
color: 'white',
|
|
||||||
},
|
|
||||||
greyText: {
|
|
||||||
color: Colors.greyLight,
|
|
||||||
paddingLeft: Spacing.base,
|
|
||||||
},
|
|
||||||
})
|
})
|
||||||
|
|
||||||
Home.propTypes = {
|
Home.propTypes = {
|
||||||
|
|||||||
@@ -0,0 +1,16 @@
|
|||||||
|
import React from 'react'
|
||||||
|
import { StyleSheet } from 'react-native'
|
||||||
|
|
||||||
|
import AppText from './app-text'
|
||||||
|
|
||||||
|
import { Colors } from '../../styles'
|
||||||
|
|
||||||
|
const Asterisk = () => <AppText style={styles.asterisk}>*</AppText>
|
||||||
|
|
||||||
|
const styles = StyleSheet.create({
|
||||||
|
asterisk: {
|
||||||
|
color: Colors.orange,
|
||||||
|
},
|
||||||
|
})
|
||||||
|
|
||||||
|
export default Asterisk
|
||||||
@@ -0,0 +1,43 @@
|
|||||||
|
import React from 'react'
|
||||||
|
import PropTypes from 'prop-types'
|
||||||
|
import { StyleSheet, View } from 'react-native'
|
||||||
|
|
||||||
|
import AppText from '../common/app-text'
|
||||||
|
import Asterisk from '../common/Asterisk'
|
||||||
|
|
||||||
|
import { Colors, Spacing } from '../../styles'
|
||||||
|
|
||||||
|
const Footnote = ({ children }) => {
|
||||||
|
if (!children) return false
|
||||||
|
|
||||||
|
return (
|
||||||
|
<View style={styles.container}>
|
||||||
|
<Asterisk />
|
||||||
|
<AppText linkStyle={styles.link} style={styles.text}>
|
||||||
|
{children}
|
||||||
|
</AppText>
|
||||||
|
</View>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
Footnote.propTypes = {
|
||||||
|
children: PropTypes.node,
|
||||||
|
}
|
||||||
|
|
||||||
|
const styles = StyleSheet.create({
|
||||||
|
container: {
|
||||||
|
flexDirection: 'row',
|
||||||
|
alignContent: 'flex-start',
|
||||||
|
marginBottom: Spacing.tiny,
|
||||||
|
marginTop: Spacing.small,
|
||||||
|
},
|
||||||
|
link: {
|
||||||
|
color: 'white',
|
||||||
|
},
|
||||||
|
text: {
|
||||||
|
color: Colors.greyLight,
|
||||||
|
paddingLeft: Spacing.base,
|
||||||
|
},
|
||||||
|
})
|
||||||
|
|
||||||
|
export default Footnote
|
||||||
@@ -0,0 +1,19 @@
|
|||||||
|
import React from 'react'
|
||||||
|
import { render } from '@testing-library/react-native'
|
||||||
|
|
||||||
|
import Footnote from '../../../components/common/Footnote'
|
||||||
|
|
||||||
|
describe('Footnote component', () => {
|
||||||
|
test('when children are present, renders them', () => {
|
||||||
|
const text = 'Some footnote text'
|
||||||
|
const { toJSON } = render(<Footnote>{text}</Footnote>)
|
||||||
|
|
||||||
|
expect(toJSON()).toMatchSnapshot()
|
||||||
|
})
|
||||||
|
|
||||||
|
test('when no children, renders nothing', () => {
|
||||||
|
const { toJSON } = render(<Footnote></Footnote>)
|
||||||
|
|
||||||
|
expect(toJSON()).toMatchSnapshot()
|
||||||
|
})
|
||||||
|
})
|
||||||
@@ -0,0 +1,55 @@
|
|||||||
|
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
||||||
|
|
||||||
|
exports[`Footnote component when children are present, renders them 1`] = `
|
||||||
|
<View
|
||||||
|
style={
|
||||||
|
Object {
|
||||||
|
"alignContent": "flex-start",
|
||||||
|
"flexDirection": "row",
|
||||||
|
"marginBottom": 8.571428571428571,
|
||||||
|
"marginTop": 21.428571428571427,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
>
|
||||||
|
<Text
|
||||||
|
style={
|
||||||
|
Array [
|
||||||
|
Object {
|
||||||
|
"color": "#555",
|
||||||
|
"fontFamily": "Jost-Book",
|
||||||
|
"fontSize": 34.285714285714285,
|
||||||
|
},
|
||||||
|
Object {
|
||||||
|
"color": "#F38337",
|
||||||
|
},
|
||||||
|
]
|
||||||
|
}
|
||||||
|
>
|
||||||
|
*
|
||||||
|
</Text>
|
||||||
|
<Text
|
||||||
|
linkStyle={
|
||||||
|
Object {
|
||||||
|
"color": "white",
|
||||||
|
}
|
||||||
|
}
|
||||||
|
style={
|
||||||
|
Array [
|
||||||
|
Object {
|
||||||
|
"color": "#555",
|
||||||
|
"fontFamily": "Jost-Book",
|
||||||
|
"fontSize": 34.285714285714285,
|
||||||
|
},
|
||||||
|
Object {
|
||||||
|
"color": "#CCC",
|
||||||
|
"paddingLeft": 34.285714285714285,
|
||||||
|
},
|
||||||
|
]
|
||||||
|
}
|
||||||
|
>
|
||||||
|
Some footnote text
|
||||||
|
</Text>
|
||||||
|
</View>
|
||||||
|
`;
|
||||||
|
|
||||||
|
exports[`Footnote component when no children, renders nothing 1`] = `null`;
|
||||||
Reference in New Issue
Block a user