Application prototype #14

Merged
glen merged 101 commits from app-proto into main 2024-10-21 23:38:28 +00:00
2 changed files with 19 additions and 19 deletions
Showing only changes of commit 634e97b659 - Show all commits

View File

@ -24,7 +24,7 @@ li:not(:last-child) {
margin-bottom: 8px; margin-bottom: 8px;
} }
li > .elt-name { li > .elt-label {
flex-grow: 1; flex-grow: 1;
padding: 2px 0px 2px 4px; padding: 2px 0px 2px 4px;
} }

View File

@ -3,10 +3,10 @@ use sycamore::{prelude::*, web::tags::div};
#[derive(Clone, PartialEq)] #[derive(Clone, PartialEq)]
struct Element { struct Element {
id: i64, id: String,
name: String, label: String,
color: [f32; 3],
rep: DVector<f64>, rep: DVector<f64>,
color: [f32; 3]
} }
struct EditorState { struct EditorState {
@ -18,22 +18,22 @@ pub fn Editor() -> View {
let state = EditorState { let state = EditorState {
elements: create_signal(vec![ elements: create_signal(vec![
Element { Element {
id: 1, id: String::from("central"),
name: String::from("Central"), label: String::from("Central"),
rep: DVector::<f64>::from_column_slice(&[0.0, 0.0, 0.0, 0.25, -1.0]), color: [0.75_f32, 0.75_f32, 0.75_f32],
color: [0.75_f32, 0.75_f32, 0.75_f32] rep: DVector::<f64>::from_column_slice(&[0.0, 0.0, 0.0, 0.25, -1.0])
}, },
Element { Element {
id: 2, id: String::from("wing_a"),
name: String::from("Wing A"), label: String::from("Wing A"),
rep: DVector::<f64>::from_column_slice(&[0.5, 0.5, 0.0, 0.5, -0.25]), color: [1.00_f32, 0.25_f32, 0.00_f32],
color: [1.00_f32, 0.25_f32, 0.00_f32] rep: DVector::<f64>::from_column_slice(&[0.5, 0.5, 0.0, 0.5, -0.25])
}, },
Element { Element {
id: 3, id: String::from("wing_b"),
name: String::from("Wing B"), label: String::from("Wing B"),
rep: DVector::<f64>::from_column_slice(&[-0.5, -0.5, 0.0, 0.5, -0.25]), color: [1.00_f32, 0.25_f32, 0.00_f32],
color: [1.00_f32, 0.25_f32, 0.00_f32] rep: DVector::<f64>::from_column_slice(&[-0.5, -0.5, 0.0, 0.5, -0.25])
} }
]) ])
}; };
@ -43,18 +43,18 @@ pub fn Editor() -> View {
Keyed( Keyed(
list=state.elements, list=state.elements,
view=|elt| { view=|elt| {
let name = elt.name.clone(); let label = elt.label.clone();
let rep_components = elt.rep.iter().map( let rep_components = elt.rep.iter().map(
|u| View::from(div().children(u.to_string().replace("-", "\u{2212}"))) |u| View::from(div().children(u.to_string().replace("-", "\u{2212}")))
).collect::<Vec<_>>(); ).collect::<Vec<_>>();
view! { view! {
li { li {
div(class="elt-name") { (name) } div(class="elt-label") { (label) }
div(class="elt-rep") { (rep_components) } div(class="elt-rep") { (rep_components) }
} }
} }
}, },
key=|elt| elt.id key=|elt| elt.id.clone()
) )
} }
} }