add some basic styling
This commit is contained in:
parent
cac77accd1
commit
c5a3ae279c
3 changed files with 32 additions and 18 deletions
|
@ -27,9 +27,15 @@ pub fn to_earth_time(ez_time: DateTime<Utc>) -> DateTime<Utc> {
|
||||||
|
|
||||||
/// Sets hours and minutes for a date, based on a f32.
|
/// Sets hours and minutes for a date, based on a f32.
|
||||||
pub fn set_hm_from_float(date: &DateTime<Utc>, hm: f32) -> DateTime<Utc> {
|
pub fn set_hm_from_float(date: &DateTime<Utc>, hm: f32) -> DateTime<Utc> {
|
||||||
let minutes = ((hm % 1.) * 100.) as u32;
|
let minutes_only = hm - (hm as u32 as f32); // Remove decimal points so we can subtract the whole number
|
||||||
|
let minutes = (minutes_only * 60.) as u32;
|
||||||
|
let hm = if hm as u32 == 24 { 0. } else { hm };
|
||||||
date.date_naive()
|
date.date_naive()
|
||||||
.and_hms_opt(hm as u32, minutes, date.second())
|
.and_hms_opt(hm as u32, minutes, date.second())
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.and_utc()
|
.and_utc()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn display_eorzea_time(date: &DateTime<Utc>) -> String {
|
||||||
|
date.format("%H:%M").to_string()
|
||||||
|
}
|
||||||
|
|
|
@ -29,24 +29,19 @@ pub fn main_page(state: State<Arc<AppState>>) -> Markup {
|
||||||
let mut values: Vec<&CombinedFish> = meta.values().filter(|f| f.entry.big_fish).collect();
|
let mut values: Vec<&CombinedFish> = meta.values().filter(|f| f.entry.big_fish).collect();
|
||||||
values.sort_by(|afish, bfish| bfish.is_up.cmp(&afish.is_up));
|
values.sort_by(|afish, bfish| bfish.is_up.cmp(&afish.is_up));
|
||||||
layout(html! {
|
layout(html! {
|
||||||
h1 { "Hello! Current ET " (clock::get_current_eorzea_date().format("%H:%M")) }
|
h1 { "Hello! Current ET: " (clock::get_current_eorzea_date().format("%H:%M")) }
|
||||||
@for fish in values {
|
@for fish in values {
|
||||||
li {
|
section.up[fish.is_up] {
|
||||||
@if fish.is_up {
|
.title {
|
||||||
"Up! "
|
h3 { (fish.meta.name_en) }
|
||||||
} @else {
|
|
||||||
"Next uptime " (fish.next_uptime)
|
|
||||||
}
|
}
|
||||||
(fish.meta.name_en)
|
.meta {
|
||||||
details {
|
|
||||||
@if fish.entry.start_hour.is_some() && fish.entry.end_hour.is_some() {
|
@if fish.entry.start_hour.is_some() && fish.entry.end_hour.is_some() {
|
||||||
"From " (fish.entry.start_hour.unwrap()) "h to " (fish.entry.end_hour.unwrap()) "h"
|
div {
|
||||||
}
|
(clock::display_eorzea_time(&clock::set_hm_from_float(&clock::get_current_eorzea_date(), fish.entry.start_hour.unwrap())))
|
||||||
@if fish.entry.weather_set.len() > 0 {
|
" to "
|
||||||
" Weather(s) " (fish.entry.weather_set.iter().map(|i| i.to_string()).collect::<Vec<_>>().join(", "))
|
(clock::display_eorzea_time(&clock::set_hm_from_float(&clock::get_current_eorzea_date(), fish.entry.end_hour.unwrap())))
|
||||||
}
|
}
|
||||||
@if let Some(forecast) = fish.get_forecast(&state.data) {
|
|
||||||
"Current weather in " (data::get_zone_name(&state.data, forecast.zone_id)) ": " (data::get_weather_name(&state.data, forecast.weather_now().weather_id))
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,3 +1,16 @@
|
||||||
h1 {
|
body {
|
||||||
color: red;
|
font-family: sans-serif;
|
||||||
|
margin: 40px;
|
||||||
|
}
|
||||||
|
|
||||||
|
section {
|
||||||
|
margin-bottom: 5px;
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: space-between;
|
||||||
|
padding: 0 10px;
|
||||||
|
}
|
||||||
|
|
||||||
|
section.up {
|
||||||
|
background-color: greenyellow;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue