2 Commits
0.2.2 ... 0.2.3

Author SHA1 Message Date
f7ec98f8e3 0.2.3 2023-11-06 22:29:54 +01:00
924a14cdcb Tweak frontend layout and style 2023-11-06 21:27:27 +01:00
6 changed files with 50 additions and 39 deletions

6
Cargo.lock generated
View File

@ -206,7 +206,7 @@ dependencies = [
[[package]] [[package]]
name = "common" name = "common"
version = "0.2.2" version = "0.2.3"
dependencies = [ dependencies = [
"chrono", "chrono",
"lighter_lib", "lighter_lib",
@ -576,7 +576,7 @@ checksum = "95505c38b4572b2d910cecb0281560f54b440a19336cbbcb27bf6ce6adc6f5a8"
[[package]] [[package]]
name = "hemma" name = "hemma"
version = "0.2.2" version = "0.2.3"
dependencies = [ dependencies = [
"anyhow", "anyhow",
"async-trait", "async-trait",
@ -600,7 +600,7 @@ dependencies = [
[[package]] [[package]]
name = "hemma_web" name = "hemma_web"
version = "0.2.2" version = "0.2.3"
dependencies = [ dependencies = [
"chrono", "chrono",
"common", "common",

View File

@ -1,6 +1,6 @@
[package] [package]
name = "hemma" name = "hemma"
version = "0.2.2" version = "0.2.3"
edition = "2021" edition = "2021"
[dependencies] [dependencies]

View File

@ -1,6 +1,6 @@
[package] [package]
name = "common" name = "common"
version = "0.2.2" version = "0.2.3"
edition = "2021" edition = "2021"
[dependencies] [dependencies]

View File

@ -1,6 +1,6 @@
[package] [package]
name = "hemma_web" name = "hemma_web"
version = "0.2.2" version = "0.2.3"
authors = ["Joakim Hulthe <joakim@hulthe.net"] authors = ["Joakim Hulthe <joakim@hulthe.net"]
edition = "2021" edition = "2021"

View File

@ -3,7 +3,7 @@ use crate::css::C;
use chrono::{NaiveTime, Weekday}; use chrono::{NaiveTime, Weekday};
use common::{BulbGroup, BulbGroupShape, BulbMap, ClientMessage, ServerMessage}; use common::{BulbGroup, BulbGroupShape, BulbMap, ClientMessage, ServerMessage};
use lighter_lib::{BulbId, BulbMode}; use lighter_lib::{BulbId, BulbMode};
use seed::{attrs, button, div, input, C}; use seed::{attrs, button, div, h2, input, table, td, tr, C};
use seed::{prelude::*, IF}; use seed::{prelude::*, IF};
use seed_router::Page; use seed_router::Page;
use std::collections::{BTreeMap, HashMap, HashSet}; use std::collections::{BTreeMap, HashMap, HashSet};
@ -235,14 +235,14 @@ impl Page for Model {
.and_then(|b| b.wake_schedule.get(&day)) .and_then(|b| b.wake_schedule.get(&day))
.map(|t| t.to_string()) .map(|t| t.to_string())
.unwrap_or_default(); .unwrap_or_default();
div![ tr![
C![C.calendar_day], C![C.calendar_day],
day.to_string(), td![day.to_string()],
input![ td![input![
C![C.calendar_time_input], C![C.calendar_time_input],
attrs! {At::Placeholder => time}, attrs! {At::Placeholder => time},
input_ev(Ev::Input, move |input| Msg::LightTime(input, day)) input_ev(Ev::Input, move |input| Msg::LightTime(input, day))
], ]],
] ]
}; };
@ -251,14 +251,14 @@ impl Page for Model {
div![ div![
C![C.bulb_map], C![C.bulb_map],
attrs! { attrs! {
At::Style => format!("width: {}rem; height: {}rem;", bulb_map_width, bulb_map_height), At::Style => format!("min-width: {}rem; height: {}rem;", bulb_map_width, bulb_map_height),
}, },
ev(Ev::Click, |_| Msg::DeselectGroups), ev(Ev::Click, |_| Msg::DeselectGroups),
self.bulb_map.groups.iter().enumerate().map(view_bulb_group), self.bulb_map.groups.iter().enumerate().map(view_bulb_group),
], ],
div![ div![
C![C.bulb_controls], C![C.bulb_controls],
IF!(selected_bulb.is_none() => C![C.bulb_controls_disable]), IF!(selected_bulb.is_none() => C![C.cross_out]),
self.color_picker.view().map_msg(Msg::ColorPicker), self.color_picker.view().map_msg(Msg::ColorPicker),
button![ button![
if selected_bulb.map(|b| b.mode.power).unwrap_or(false) { if selected_bulb.map(|b| b.mode.power).unwrap_or(false) {
@ -279,6 +279,9 @@ impl Page for Model {
], ],
div![ div![
C![C.calendar_box], C![C.calendar_box],
IF!(selected_bulb.is_none() => C![C.cross_out]),
h2!["Wake Schedule"],
table![
calendar_day(Weekday::Mon), calendar_day(Weekday::Mon),
calendar_day(Weekday::Tue), calendar_day(Weekday::Tue),
calendar_day(Weekday::Wed), calendar_day(Weekday::Wed),
@ -287,6 +290,7 @@ impl Page for Model {
calendar_day(Weekday::Sat), calendar_day(Weekday::Sat),
calendar_day(Weekday::Sun), calendar_day(Weekday::Sun),
], ],
],
] ]
} }
} }

View File

@ -94,17 +94,12 @@ body {
} }
.bulb_box { .bulb_box {
display: flex;
flex-direction: row;
flex-wrap: wrap;
align-items: center;
justify-content: space-around;
width: fit-content; width: fit-content;
margin: auto;
} }
.bulb_box > * { .bulb_box > * {
margin-bottom: 1em; margin-bottom: 1.5rem;
margin-right: 1em;
} }
.bulb_controls { .bulb_controls {
@ -112,21 +107,20 @@ body {
flex-direction: row; flex-direction: row;
align-items: center; align-items: center;
padding-right: 0.5em; padding-right: 0.5em;
background: #56636e; background: #00000000;
border: solid 0.25em #5b3f63;
} }
.bulb_controls_disable { .cross_out {
position: relative; position: relative;
overflow: hidden; overflow: hidden;
opacity: 0.5;
} }
.bulb_controls_disable:before { .cross_out:before {
position: absolute; position: absolute;
content: ''; content: '';
display: block; display: block;
background: #000000; background: #00000000;
opacity: 0.5;
left: 0; left: 0;
right: 0; right: 0;
top: 0; top: 0;
@ -135,7 +129,7 @@ body {
z-index: 90; z-index: 90;
} }
.bulb_controls_disable:after { .cross_out:after {
position: absolute; position: absolute;
content: ''; content: '';
background: #56636e; background: #56636e;
@ -151,23 +145,24 @@ body {
bottom: 0; bottom: 0;
margin: auto; margin: auto;
z-index: 91; z-index: 91;
animation: to_full_width .2s ease-out 0s 1 forwards; box-shadow: black 0.5rem 0.6rem 1rem 0.3rem;
animation: to_width_90 .2s ease-out 0s 1 forwards;
} }
@keyframes to_full_width { to { width: 100%; } } @keyframes to_width_90 { to { width: 90%; } }
.bulb_map { .bulb_map {
background: url(images/blueprint_bg.png); background: url(images/blueprint_bg.png);
background-size: auto; background-size: auto;
background-size: 1em; background-size: 1em;
padding: 2rem; padding: 2rem;
border: solid 0.4rem #5b3f63; border: solid 0.1rem;
border-radius: 0.2rem;
} }
.bulb_map::after { .bulb_map::after {
position: absolute; position: absolute;
width: 100%; width: 100%;
height: 100%; height: 100%;
content: #0003;
} }
.bulb_group { .bulb_group {
@ -179,6 +174,7 @@ body {
font-size: 2em; font-size: 2em;
position: absolute; position: absolute;
box-shadow: #0006 0.1em 0.1em 0.1em; box-shadow: #0006 0.1em 0.1em 0.1em;
user-select: none;
transition: 0.3s ease-in-out; transition: 0.3s ease-in-out;
} }
@ -326,7 +322,18 @@ body {
//margin-bottom: .7em; //margin-bottom: .7em;
margin-left: .5em; margin-left: .5em;
} }
.calendar_box { .calendar_box {
with: 10em; display: flex;
justify-content: center;
}
.calendar_box > h2 {
writing-mode: sideways-lr;
margin-top: auto;
margin-bottom: auto;
}
.calendar_box > * {
flex-shrink: 1;
} }