From 634e97b6595ac16ef70817baeb6161bbab662cca Mon Sep 17 00:00:00 2001 From: Aaron Fenyes Date: Thu, 12 Sep 2024 22:36:54 -0700 Subject: [PATCH] Outline: switch to user-facing ID --- app-proto/sketch-outline/main.css | 2 +- app-proto/sketch-outline/src/editor.rs | 36 +++++++++++++------------- 2 files changed, 19 insertions(+), 19 deletions(-) diff --git a/app-proto/sketch-outline/main.css b/app-proto/sketch-outline/main.css index 2e6aedc..7e0fe01 100644 --- a/app-proto/sketch-outline/main.css +++ b/app-proto/sketch-outline/main.css @@ -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; } diff --git a/app-proto/sketch-outline/src/editor.rs b/app-proto/sketch-outline/src/editor.rs index b0d3f2e..07c0084 100644 --- a/app-proto/sketch-outline/src/editor.rs +++ b/app-proto/sketch-outline/src/editor.rs @@ -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, - 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::::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::::from_column_slice(&[0.0, 0.0, 0.0, 0.25, -1.0]) }, Element { - id: 2, - name: String::from("Wing A"), - rep: DVector::::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::::from_column_slice(&[0.5, 0.5, 0.0, 0.5, -0.25]) }, Element { - id: 3, - name: String::from("Wing B"), - rep: DVector::::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::::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::>(); 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() ) } }