Prettify chart files
This commit is contained in:
@@ -18,21 +18,21 @@ const ChartLegend = ({ height }) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
ChartLegend.propTypes = {
|
ChartLegend.propTypes = {
|
||||||
height: PropTypes.number.isRequired
|
height: PropTypes.number.isRequired,
|
||||||
}
|
}
|
||||||
|
|
||||||
const styles = StyleSheet.create({
|
const styles = StyleSheet.create({
|
||||||
container: {
|
container: {
|
||||||
alignItems: 'center',
|
alignItems: 'center',
|
||||||
justifyContent: 'flex-end',
|
justifyContent: 'flex-end',
|
||||||
width: CHART_YAXIS_WIDTH
|
width: CHART_YAXIS_WIDTH,
|
||||||
},
|
},
|
||||||
text: {
|
text: {
|
||||||
...Typography.label,
|
...Typography.label,
|
||||||
},
|
},
|
||||||
textBold: {
|
textBold: {
|
||||||
...Typography.labelBold
|
...Typography.labelBold,
|
||||||
}
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
export default ChartLegend
|
export default ChartLegend
|
||||||
|
|||||||
@@ -5,18 +5,19 @@ import { StyleSheet, View } from 'react-native'
|
|||||||
import { getTickPositions } from '../helpers/chart'
|
import { getTickPositions } from '../helpers/chart'
|
||||||
|
|
||||||
import { Colors } from '../../styles'
|
import { Colors } from '../../styles'
|
||||||
import { CHART_GRID_LINE_HORIZONTAL_WIDTH, CHART_YAXIS_WIDTH } from '../../config'
|
import {
|
||||||
|
CHART_GRID_LINE_HORIZONTAL_WIDTH,
|
||||||
|
CHART_YAXIS_WIDTH,
|
||||||
|
} from '../../config'
|
||||||
|
|
||||||
const HorizontalGrid = ({ height }) => {
|
const HorizontalGrid = ({ height }) => {
|
||||||
return getTickPositions(height).map(tick => {
|
return getTickPositions(height).map((tick) => {
|
||||||
return (
|
return <View key={tick} top={tick} {...styles.line} />
|
||||||
<View key={tick} top={tick} {...styles.line}/>
|
|
||||||
)
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
HorizontalGrid.propTypes = {
|
HorizontalGrid.propTypes = {
|
||||||
height: PropTypes.number
|
height: PropTypes.number,
|
||||||
}
|
}
|
||||||
|
|
||||||
const styles = StyleSheet.create({
|
const styles = StyleSheet.create({
|
||||||
@@ -26,8 +27,8 @@ const styles = StyleSheet.create({
|
|||||||
borderBottomWidth: CHART_GRID_LINE_HORIZONTAL_WIDTH,
|
borderBottomWidth: CHART_GRID_LINE_HORIZONTAL_WIDTH,
|
||||||
left: CHART_YAXIS_WIDTH,
|
left: CHART_YAXIS_WIDTH,
|
||||||
position: 'absolute',
|
position: 'absolute',
|
||||||
right: 0
|
right: 0,
|
||||||
}
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
export default HorizontalGrid
|
export default HorizontalGrid
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ import { Colors, Containers } from '../../styles'
|
|||||||
import {
|
import {
|
||||||
CHART_COLUMN_WIDTH,
|
CHART_COLUMN_WIDTH,
|
||||||
CHART_DOT_RADIUS,
|
CHART_DOT_RADIUS,
|
||||||
CHART_GRID_LINE_HORIZONTAL_WIDTH
|
CHART_GRID_LINE_HORIZONTAL_WIDTH,
|
||||||
} from '../../config'
|
} from '../../config'
|
||||||
|
|
||||||
const SymptomCell = ({
|
const SymptomCell = ({
|
||||||
@@ -14,11 +14,11 @@ const SymptomCell = ({
|
|||||||
index,
|
index,
|
||||||
symptom,
|
symptom,
|
||||||
symptomValue,
|
symptomValue,
|
||||||
isSymptomDataComplete
|
isSymptomDataComplete,
|
||||||
}) => {
|
}) => {
|
||||||
|
|
||||||
const shouldDrawDot = symptomValue !== false
|
const shouldDrawDot = symptomValue !== false
|
||||||
const styleCell = index !== 0
|
const styleCell =
|
||||||
|
index !== 0
|
||||||
? [styles.cell, { height, width: CHART_COLUMN_WIDTH }]
|
? [styles.cell, { height, width: CHART_COLUMN_WIDTH }]
|
||||||
: [styles.cell, { height, width: CHART_COLUMN_WIDTH }, styles.topBorder]
|
: [styles.cell, { height, width: CHART_COLUMN_WIDTH }, styles.topBorder]
|
||||||
let styleDot
|
let styleDot
|
||||||
@@ -26,10 +26,10 @@ const SymptomCell = ({
|
|||||||
if (shouldDrawDot) {
|
if (shouldDrawDot) {
|
||||||
const styleSymptom = Colors.iconColors[symptom]
|
const styleSymptom = Colors.iconColors[symptom]
|
||||||
const symptomColor = styleSymptom.shades[symptomValue]
|
const symptomColor = styleSymptom.shades[symptomValue]
|
||||||
const isMucusOrCervix = (symptom === 'mucus') || (symptom === 'cervix')
|
const isMucusOrCervix = symptom === 'mucus' || symptom === 'cervix'
|
||||||
const backgroundColor = (isMucusOrCervix && !isSymptomDataComplete) ?
|
const backgroundColor =
|
||||||
'white' : symptomColor
|
isMucusOrCervix && !isSymptomDataComplete ? 'white' : symptomColor
|
||||||
const borderWidth = (isMucusOrCervix && !isSymptomDataComplete) ? 2 : 0
|
const borderWidth = isMucusOrCervix && !isSymptomDataComplete ? 2 : 0
|
||||||
const borderColor = symptomColor
|
const borderColor = symptomColor
|
||||||
styleDot = [styles.dot, { backgroundColor, borderColor, borderWidth }]
|
styleDot = [styles.dot, { backgroundColor, borderColor, borderWidth }]
|
||||||
}
|
}
|
||||||
@@ -45,10 +45,7 @@ SymptomCell.propTypes = {
|
|||||||
height: PropTypes.number,
|
height: PropTypes.number,
|
||||||
index: PropTypes.number.isRequired,
|
index: PropTypes.number.isRequired,
|
||||||
symptom: PropTypes.string,
|
symptom: PropTypes.string,
|
||||||
symptomValue: PropTypes.oneOfType([
|
symptomValue: PropTypes.oneOfType([PropTypes.bool, PropTypes.number]),
|
||||||
PropTypes.bool,
|
|
||||||
PropTypes.number,
|
|
||||||
]),
|
|
||||||
isSymptomDataComplete: PropTypes.bool,
|
isSymptomDataComplete: PropTypes.bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -59,7 +56,7 @@ const styles = StyleSheet.create({
|
|||||||
borderBottomWidth: CHART_GRID_LINE_HORIZONTAL_WIDTH,
|
borderBottomWidth: CHART_GRID_LINE_HORIZONTAL_WIDTH,
|
||||||
borderLeftColor: Colors.grey,
|
borderLeftColor: Colors.grey,
|
||||||
borderLeftWidth: CHART_GRID_LINE_HORIZONTAL_WIDTH,
|
borderLeftWidth: CHART_GRID_LINE_HORIZONTAL_WIDTH,
|
||||||
...Containers.centerItems
|
...Containers.centerItems,
|
||||||
},
|
},
|
||||||
topBorder: {
|
topBorder: {
|
||||||
borderTopColor: Colors.grey,
|
borderTopColor: Colors.grey,
|
||||||
@@ -68,7 +65,7 @@ const styles = StyleSheet.create({
|
|||||||
dot: {
|
dot: {
|
||||||
width: CHART_DOT_RADIUS * 2,
|
width: CHART_DOT_RADIUS * 2,
|
||||||
height: CHART_DOT_RADIUS * 2,
|
height: CHART_DOT_RADIUS * 2,
|
||||||
borderRadius: 50
|
borderRadius: 50,
|
||||||
}
|
},
|
||||||
})
|
})
|
||||||
export default SymptomCell
|
export default SymptomCell
|
||||||
|
|||||||
@@ -26,8 +26,8 @@ SymptomIcon.propTypes = {
|
|||||||
|
|
||||||
const styles = StyleSheet.create({
|
const styles = StyleSheet.create({
|
||||||
container: {
|
container: {
|
||||||
...Containers.centerItems
|
...Containers.centerItems,
|
||||||
}
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
export default SymptomIcon
|
export default SymptomIcon
|
||||||
|
|||||||
@@ -7,12 +7,10 @@ import Tick from './tick'
|
|||||||
import { getTickList } from '../helpers/chart'
|
import { getTickList } from '../helpers/chart'
|
||||||
|
|
||||||
const TickList = ({ height }) => {
|
const TickList = ({ height }) => {
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<View style={[styles.container, height]}>
|
<View style={[styles.container, height]}>
|
||||||
{
|
{getTickList(height).map(
|
||||||
getTickList(height)
|
({ isBold, label, position, shouldShowLabel, tickHeight }) => {
|
||||||
.map(({ isBold, label, position, shouldShowLabel, tickHeight}) => {
|
|
||||||
return (
|
return (
|
||||||
<Tick
|
<Tick
|
||||||
height={tickHeight}
|
height={tickHeight}
|
||||||
@@ -23,8 +21,8 @@ const TickList = ({ height }) => {
|
|||||||
yPosition={position}
|
yPosition={position}
|
||||||
/>
|
/>
|
||||||
)
|
)
|
||||||
})
|
|
||||||
}
|
}
|
||||||
|
)}
|
||||||
</View>
|
</View>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
@@ -35,8 +33,8 @@ TickList.propTypes = {
|
|||||||
|
|
||||||
const styles = StyleSheet.create({
|
const styles = StyleSheet.create({
|
||||||
container: {
|
container: {
|
||||||
flex: 1
|
flex: 1,
|
||||||
}
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
export default TickList
|
export default TickList
|
||||||
|
|||||||
@@ -27,7 +27,6 @@ Tick.propTypes = {
|
|||||||
label: PropTypes.string,
|
label: PropTypes.string,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
const text = {
|
const text = {
|
||||||
textAlign: 'right',
|
textAlign: 'right',
|
||||||
}
|
}
|
||||||
@@ -36,17 +35,17 @@ const styles = StyleSheet.create({
|
|||||||
justifyContent: 'center',
|
justifyContent: 'center',
|
||||||
position: 'absolute',
|
position: 'absolute',
|
||||||
right: 0,
|
right: 0,
|
||||||
width: CHART_TICK_WIDTH
|
width: CHART_TICK_WIDTH,
|
||||||
},
|
},
|
||||||
textBold: {
|
textBold: {
|
||||||
fontSize: Sizes.base,
|
fontSize: Sizes.base,
|
||||||
fontWeight: 'bold',
|
fontWeight: 'bold',
|
||||||
...text
|
...text,
|
||||||
},
|
},
|
||||||
textNormal: {
|
textNormal: {
|
||||||
fontSize: Sizes.small,
|
fontSize: Sizes.small,
|
||||||
...text
|
...text,
|
||||||
}
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
export default Tick
|
export default Tick
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ const image = require('../../assets/swipe.png')
|
|||||||
const Tutorial = ({ onClose }) => {
|
const Tutorial = ({ onClose }) => {
|
||||||
return (
|
return (
|
||||||
<View style={styles.container}>
|
<View style={styles.container}>
|
||||||
<Image resizeMode='contain' source={image} style={styles.image} />
|
<Image resizeMode="contain" source={image} style={styles.image} />
|
||||||
<View style={styles.textContainer}>
|
<View style={styles.textContainer}>
|
||||||
<AppText>{chart.tutorial}</AppText>
|
<AppText>{chart.tutorial}</AppText>
|
||||||
</View>
|
</View>
|
||||||
@@ -23,20 +23,20 @@ const Tutorial = ({ onClose }) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Tutorial.propTypes = {
|
Tutorial.propTypes = {
|
||||||
onClose: PropTypes.func.isRequired
|
onClose: PropTypes.func.isRequired,
|
||||||
}
|
}
|
||||||
|
|
||||||
const styles = StyleSheet.create({
|
const styles = StyleSheet.create({
|
||||||
container: {
|
container: {
|
||||||
...Containers.rowContainer,
|
...Containers.rowContainer,
|
||||||
padding: Spacing.large
|
padding: Spacing.large,
|
||||||
},
|
},
|
||||||
image: {
|
image: {
|
||||||
height: 40
|
height: 40,
|
||||||
},
|
},
|
||||||
textContainer: {
|
textContainer: {
|
||||||
width: '70%'
|
width: '70%',
|
||||||
}
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
export default Tutorial
|
export default Tutorial
|
||||||
@@ -13,7 +13,7 @@ const YAxis = ({
|
|||||||
symptomsToDisplay,
|
symptomsToDisplay,
|
||||||
symptomsSectionHeight,
|
symptomsSectionHeight,
|
||||||
shouldShowTemperatureColumn,
|
shouldShowTemperatureColumn,
|
||||||
xAxisHeight
|
xAxisHeight,
|
||||||
}) => {
|
}) => {
|
||||||
const symptomIconHeight = symptomsSectionHeight / symptomsToDisplay.length
|
const symptomIconHeight = symptomsSectionHeight / symptomsToDisplay.length
|
||||||
|
|
||||||
@@ -22,14 +22,13 @@ const YAxis = ({
|
|||||||
{shouldShowTemperatureColumn && <TickList height={height} />}
|
{shouldShowTemperatureColumn && <TickList height={height} />}
|
||||||
<ChartLegend height={xAxisHeight} />
|
<ChartLegend height={xAxisHeight} />
|
||||||
<View style={[styles.yAxis, { height: symptomsSectionHeight }]}>
|
<View style={[styles.yAxis, { height: symptomsSectionHeight }]}>
|
||||||
{symptomsToDisplay.map(symptom => (
|
{symptomsToDisplay.map((symptom) => (
|
||||||
<SymptomIcon
|
<SymptomIcon
|
||||||
key={symptom}
|
key={symptom}
|
||||||
symptom={symptom}
|
symptom={symptom}
|
||||||
height={symptomIconHeight}
|
height={symptomIconHeight}
|
||||||
/>
|
/>
|
||||||
)
|
))}
|
||||||
)}
|
|
||||||
</View>
|
</View>
|
||||||
</View>
|
</View>
|
||||||
)
|
)
|
||||||
@@ -40,13 +39,13 @@ YAxis.propTypes = {
|
|||||||
symptomsToDisplay: PropTypes.array,
|
symptomsToDisplay: PropTypes.array,
|
||||||
symptomsSectionHeight: PropTypes.number,
|
symptomsSectionHeight: PropTypes.number,
|
||||||
shouldShowTemperatureColumn: PropTypes.bool,
|
shouldShowTemperatureColumn: PropTypes.bool,
|
||||||
xAxisHeight: PropTypes.number.isRequired
|
xAxisHeight: PropTypes.number.isRequired,
|
||||||
}
|
}
|
||||||
|
|
||||||
const styles = StyleSheet.create({
|
const styles = StyleSheet.create({
|
||||||
yAxis: {
|
yAxis: {
|
||||||
width: CHART_YAXIS_WIDTH
|
width: CHART_YAXIS_WIDTH,
|
||||||
}
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
export default YAxis
|
export default YAxis
|
||||||
|
|||||||
Reference in New Issue
Block a user