serve: colorize sat+sun

This commit is contained in:
Astro 2020-10-26 20:14:04 +01:00
parent b471b76bec
commit 72d4a34015
2 changed files with 55 additions and 41 deletions

View File

@ -1,3 +1,4 @@
use std::convert::TryInto;
use gotham::{
helpers::http::response::create_response,
hyper::{Body, Response},
@ -6,7 +7,7 @@ use gotham::{
use http::status::StatusCode;
use mime::TEXT_HTML;
use typed_html::{html, text, dom::DOMTree};
use typed_html::{html, text, dom::DOMTree, types::{Class, SpacedSet}};
use diesel::prelude::*;
use chrono::{offset::Local, Datelike, NaiveDate};
@ -73,9 +74,13 @@ fn render_index(app_state: &AppState) -> String {
<link rel="stylesheet" title="Style" type="text/css" href="static/style.css"/>
</head>
<body>
{ days.iter().map(|day| html!(<div>
{ days.iter().map(|day| {
let mut day_class: SpacedSet<Class> = ["date"].try_into().unwrap();
day_class.add(&format!("wd{}", day.date.weekday().num_days_from_monday())[..]);
html!(
<div>
<h2>
<span class="date">
<span class={ day_class }>
<span class="day">
{ text!("{}", day.date.day()) }
</span>
@ -113,7 +118,8 @@ fn render_index(app_state: &AppState) -> String {
)) }
</article>
)) }
</div>)) }
</div>)
}) }
</body>
</html>
);

View File

@ -23,6 +23,14 @@ h2 {
text-align: center;
width: 4rem;
}
/* saturday */
.date.wd5 {
color: #999;
}
/* sunday */
.date.wd6 {
color: #d33;
}
.date .day {
align-self: center;
font-size: 140%;
@ -40,7 +48,7 @@ article {
background-color: #f7f7f7;
color: #222;
margin: 0;
padding: 0.5rem 0 0.5rem 1rem;
padding: 0.8rem 0 0.8rem 1rem;
clear: both;
line-height: 1.3rem;
/*box-shadow: 0 -0.3rem 0.5rem 0.5rem #373737;*/