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.
|
||||
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()
|
||||
.and_hms_opt(hm as u32, minutes, date.second())
|
||||
.unwrap()
|
||||
.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();
|
||||
values.sort_by(|afish, bfish| bfish.is_up.cmp(&afish.is_up));
|
||||
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 {
|
||||
li {
|
||||
@if fish.is_up {
|
||||
"Up! "
|
||||
} @else {
|
||||
"Next uptime " (fish.next_uptime)
|
||||
section.up[fish.is_up] {
|
||||
.title {
|
||||
h3 { (fish.meta.name_en) }
|
||||
}
|
||||
(fish.meta.name_en)
|
||||
details {
|
||||
.meta {
|
||||
@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"
|
||||
}
|
||||
@if fish.entry.weather_set.len() > 0 {
|
||||
" Weather(s) " (fish.entry.weather_set.iter().map(|i| i.to_string()).collect::<Vec<_>>().join(", "))
|
||||
}
|
||||
@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))
|
||||
div {
|
||||
(clock::display_eorzea_time(&clock::set_hm_from_float(&clock::get_current_eorzea_date(), fish.entry.start_hour.unwrap())))
|
||||
" to "
|
||||
(clock::display_eorzea_time(&clock::set_hm_from_float(&clock::get_current_eorzea_date(), fish.entry.end_hour.unwrap())))
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,3 +1,16 @@
|
|||
h1 {
|
||||
color: red;
|
||||
body {
|
||||
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