Application prototype #14
@ -24,7 +24,7 @@ li:not(:last-child) {
|
||||
margin-bottom: 8px;
|
||||
}
|
||||
|
||||
li > .elt-name {
|
||||
li > .elt-label {
|
||||
flex-grow: 1;
|
||||
padding: 2px 0px 2px 4px;
|
||||
}
|
||||
|
@ -3,10 +3,10 @@ use sycamore::{prelude::*, web::tags::div};
|
||||
|
||||
#[derive(Clone, PartialEq)]
|
||||
struct Element {
|
||||
id: i64,
|
||||
name: String,
|
||||
id: String,
|
||||
label: String,
|
||||
color: [f32; 3],
|
||||
rep: DVector<f64>,
|
||||
color: [f32; 3]
|
||||
}
|
||||
|
||||
struct EditorState {
|
||||
@ -18,22 +18,22 @@ pub fn Editor() -> View {
|
||||
let state = EditorState {
|
||||
elements: create_signal(vec![
|
||||
Element {
|
||||
id: 1,
|
||||
name: 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]
|
||||
id: String::from("central"),
|
||||
label: String::from("Central"),
|
||||
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 {
|
||||
id: 2,
|
||||
name: 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]
|
||||
id: String::from("wing_a"),
|
||||
label: String::from("Wing A"),
|
||||
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 {
|
||||
id: 3,
|
||||
name: 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]
|
||||
id: String::from("wing_b"),
|
||||
label: String::from("Wing B"),
|
||||
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(
|
||||
list=state.elements,
|
||||
view=|elt| {
|
||||
let name = elt.name.clone();
|
||||
let label = elt.label.clone();
|
||||
let rep_components = elt.rep.iter().map(
|
||||
|u| View::from(div().children(u.to_string().replace("-", "\u{2212}")))
|
||||
).collect::<Vec<_>>();
|
||||
view! {
|
||||
li {
|
||||
div(class="elt-name") { (name) }
|
||||
div(class="elt-label") { (label) }
|
||||
div(class="elt-rep") { (rep_components) }
|
||||
}
|
||||
}
|
||||
},
|
||||
key=|elt| elt.id
|
||||
key=|elt| elt.id.clone()
|
||||
)
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user