Calendar redesign

This commit is contained in:
Maria Zadnepryanets
2020-08-22 10:57:44 +00:00
committed by Sofiya Tepikin
parent 885da5c293
commit 5a555f5965
61 changed files with 213 additions and 682 deletions
+67
View File
@@ -0,0 +1,67 @@
import { LocalDate } from 'js-joda'
import { Colors, Fonts } from '../../styles'
const { shades } = Colors.iconColors.bleeding
export const toCalFormat = (bleedingDaysSortedByDate) => {
const todayDateString = LocalDate.now().toString()
return bleedingDaysSortedByDate.reduce((acc, day) => {
acc[day.date] = {
customStyles: {
container: {
backgroundColor: shades[day.bleeding.value],
}
}
}
if (day.date === todayDateString) {
acc[day.date].customStyles.text = styles.calendarToday
}
return acc
}, {})
}
export const predictionToCalFormat = (predictedDays) => {
if (!predictedDays.length) return {}
const todayDateString = LocalDate.now().toString()
const middleIndex = (predictedDays[0].length - 1) / 2
return predictedDays.reduce((acc, setOfDays) => {
setOfDays.reduce((accSet, day, i) => {
accSet[day] = {
customStyles: {
container: {
borderColor: (i === middleIndex) ? shades[3] : shades[0],
borderStyle: (i === middleIndex) ? 'solid' : 'dashed',
borderWidth: 1,
},
}
}
if (day === todayDateString) {
accSet[day].customStyles.text = styles.calendarToday
}
return accSet
}, acc)
return acc
}, {})
}
export const todayToCalFormat = () => {
const todayDateString = LocalDate.now().toString()
const todayFormated = {}
todayFormated[todayDateString] = {
customStyles: {
text: styles.calendarToday
}
}
return todayFormated
}
const styles = {
calendarToday: {
fontFamily: Fonts.bold,
color: Colors.purple
},
}