Application prototype #14
@ -18,9 +18,12 @@ body {
|
|||||||
overflow-y: scroll;
|
overflow-y: scroll;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
li {
|
||||||
|
user-select: none;
|
||||||
|
}
|
||||||
|
|
||||||
summary {
|
summary {
|
||||||
display: flex;
|
display: flex;
|
||||||
user-select: none;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
summary.selected {
|
summary.selected {
|
||||||
@ -58,17 +61,25 @@ details[open]:has(li) .elt-switch::after {
|
|||||||
flex-grow: 1;
|
flex-grow: 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.cst-label {
|
||||||
|
flex-grow: 1;
|
||||||
|
}
|
||||||
|
|
||||||
.elt-rep {
|
.elt-rep {
|
||||||
display: flex;
|
display: flex;
|
||||||
}
|
}
|
||||||
|
|
||||||
.elt-rep > div {
|
.elt-rep > div, .cst-rep {
|
||||||
padding: 2px 0px 0px 0px;
|
padding: 2px 0px 0px 0px;
|
||||||
font-size: 10pt;
|
font-size: 10pt;
|
||||||
text-align: center;
|
text-align: center;
|
||||||
width: 56px;
|
width: 56px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.cst {
|
||||||
|
font-style: italic;
|
||||||
|
}
|
||||||
|
|
||||||
/* display */
|
/* display */
|
||||||
|
|
||||||
canvas {
|
canvas {
|
||||||
|
@ -12,6 +12,7 @@ pub struct Element {
|
|||||||
pub constraints: FxHashSet<usize>
|
pub constraints: FxHashSet<usize>
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(Clone)]
|
||||||
pub struct Constraint {
|
pub struct Constraint {
|
||||||
pub args: (usize, usize),
|
pub args: (usize, usize),
|
||||||
pub rep: f64
|
pub rep: f64
|
||||||
|
@ -4,6 +4,12 @@ use web_sys::{Element, KeyboardEvent, MouseEvent, wasm_bindgen::JsCast};
|
|||||||
|
|
||||||
use crate::AppState;
|
use crate::AppState;
|
||||||
|
|
||||||
|
// this component lists the elements of the assembly, showing the constraints
|
||||||
|
// on each element as a collapsible sub-list. its implementation is based on
|
||||||
|
// Kate Morley's HTML + CSS tree views:
|
||||||
|
//
|
||||||
|
// https://iamkate.com/code/tree-views/
|
||||||
|
//
|
||||||
#[component]
|
#[component]
|
||||||
pub fn Outline() -> View {
|
pub fn Outline() -> View {
|
||||||
// sort the elements alphabetically by ID
|
// sort the elements alphabetically by ID
|
||||||
@ -118,9 +124,21 @@ pub fn Outline() -> View {
|
|||||||
ul(class="constraints") {
|
ul(class="constraints") {
|
||||||
Keyed(
|
Keyed(
|
||||||
list=elt.constraints.into_iter().collect::<Vec<_>>(),
|
list=elt.constraints.into_iter().collect::<Vec<_>>(),
|
||||||
view=|c_key: usize| view! {
|
view=move |c_key: usize| {
|
||||||
|
let c_state = use_context::<AppState>();
|
||||||
|
let assembly = &c_state.assembly;
|
||||||
|
let cst = assembly.constraints.with(|csts| csts[c_key].clone());
|
||||||
|
let other_arg = if cst.args.0 == key {
|
||||||
|
cst.args.1
|
||||||
|
} else {
|
||||||
|
cst.args.0
|
||||||
|
};
|
||||||
|
let other_arg_label = assembly.elements.with(|elts| elts[other_arg].label.clone());
|
||||||
|
view! {
|
||||||
li(class="cst") {
|
li(class="cst") {
|
||||||
(c_key.to_string())
|
div(class="cst-label") { (other_arg_label) }
|
||||||
|
div(class="cst-rep") { (cst.rep) }
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
key=|c_key| c_key.clone()
|
key=|c_key| c_key.clone()
|
||||||
|
Loading…
Reference in New Issue
Block a user