Make bump session button pretty
This commit is contained in:
@ -300,7 +300,7 @@ struct CalendarDayCtx {
|
||||
|
||||
#[derive(Debug, Serialize, Deserialize)]
|
||||
struct CalendarCtx {
|
||||
days: Vec<Vec<Option<CalendarDayCtx>>>,
|
||||
weeks: Vec<Vec<Option<CalendarDayCtx>>>,
|
||||
}
|
||||
|
||||
fn compute_calendar_stats<'a, I>(sessions: I) -> CalendarCtx
|
||||
@ -339,54 +339,57 @@ where
|
||||
.num_seconds() as f32;
|
||||
|
||||
let weeks = days.iter().group_by(|(day, _)| day.iso_week());
|
||||
let mut weeks: Vec<_> = weeks
|
||||
.into_iter()
|
||||
.map(|(week, weekdays)| {
|
||||
weekdays
|
||||
.map(|(&day, duration)| {
|
||||
let duration = if duration.is_zero() {
|
||||
None
|
||||
} else {
|
||||
Some(duration.num_seconds() as u64)
|
||||
};
|
||||
|
||||
CalendarCtx {
|
||||
days: weeks
|
||||
.into_iter()
|
||||
.map(|(week, weekdays)| {
|
||||
weekdays
|
||||
.map(|(&day, duration)| {
|
||||
let duration = if duration.is_zero() {
|
||||
None
|
||||
} else {
|
||||
Some(duration.num_seconds() as u64)
|
||||
};
|
||||
let month = day.month();
|
||||
|
||||
let month = day.month();
|
||||
let month_border = |other_day| match days.get(&other_day) {
|
||||
Some(_) => other_day.month() != month,
|
||||
None => true,
|
||||
};
|
||||
|
||||
let month_border = |other_day| match days.get(&other_day) {
|
||||
Some(_) => other_day.month() != month,
|
||||
None => true,
|
||||
};
|
||||
let month_or_week_border = |other_day| match days.get(&other_day) {
|
||||
Some(_) => other_day.iso_week() != week || month_border(other_day),
|
||||
None => true,
|
||||
};
|
||||
|
||||
let month_or_week_border = |other_day| match days.get(&other_day) {
|
||||
Some(_) => other_day.iso_week() != week || month_border(other_day),
|
||||
None => true,
|
||||
};
|
||||
const MIN_WEIGHT: f32 = 0.5;
|
||||
|
||||
const MIN_WEIGHT: f32 = 0.5;
|
||||
let ctx = CalendarDayCtx {
|
||||
border_left: month_border(day - Duration::weeks(1)),
|
||||
border_right: month_border(day + Duration::weeks(1)),
|
||||
border_top: month_or_week_border(day - Duration::days(1)),
|
||||
border_bottom: month_or_week_border(day + Duration::days(1)),
|
||||
|
||||
let ctx = CalendarDayCtx {
|
||||
border_left: month_border(day - Duration::weeks(1)),
|
||||
border_right: month_border(day + Duration::weeks(1)),
|
||||
border_top: month_or_week_border(day - Duration::days(1)),
|
||||
border_bottom: month_or_week_border(day + Duration::days(1)),
|
||||
weight: duration
|
||||
.map(|d| d as f32 / biggest_day_duration)
|
||||
.map(|w| (MIN_WEIGHT + w * (1.0 - MIN_WEIGHT)).clamp(0.0, 1.0))
|
||||
.unwrap_or(1.0),
|
||||
|
||||
weight: duration
|
||||
.map(|d| d as f32 / biggest_day_duration)
|
||||
.map(|w| (MIN_WEIGHT + w * (1.0 - MIN_WEIGHT)).clamp(0.0, 1.0))
|
||||
.unwrap_or(1.0),
|
||||
duration,
|
||||
};
|
||||
|
||||
duration,
|
||||
};
|
||||
//(day.weekday(), Some(ctx))
|
||||
Some(ctx)
|
||||
})
|
||||
.collect()
|
||||
})
|
||||
.collect();
|
||||
|
||||
//(day.weekday(), Some(ctx))
|
||||
Some(ctx)
|
||||
})
|
||||
.collect()
|
||||
})
|
||||
.collect(),
|
||||
}
|
||||
// calendar is shown as flex-direction: row-reverse
|
||||
// because it should be scrolled from the right
|
||||
weeks.reverse();
|
||||
|
||||
CalendarCtx { weeks }
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
|
||||
Reference in New Issue
Block a user