Outline: switch to user-facing ID
This commit is contained in:
parent
336b940471
commit
634e97b659
@ -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;
|
||||||
}
|
}
|
||||||
|
@ -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()
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user