refactor: Code formatting (#108)
All checks were successful
/ test (push) Successful in 3m34s
All checks were successful
/ test (push) Successful in 3m34s
Primarily, switch to using trailing commas. Also uniformizes commas with respect to switch branches, makes function call layout more consistent, line breaking more consistent, alphabetizes imports, uses the field init shorthand when possible, etc. Resolves #99. Co-authored-by: Aaron Fenyes <aaron.fenyes@fareycircles.ooo> Reviewed-on: #108 Co-authored-by: Vectornaut <vectornaut@nobody@nowhere.net> Co-committed-by: Vectornaut <vectornaut@nobody@nowhere.net>
This commit is contained in:
parent
2eba80fb69
commit
ef1a579ac0
12 changed files with 310 additions and 297 deletions
|
@ -1,11 +1,7 @@
|
|||
use itertools::Itertools;
|
||||
use std::rc::Rc;
|
||||
use sycamore::prelude::*;
|
||||
use web_sys::{
|
||||
KeyboardEvent,
|
||||
MouseEvent,
|
||||
wasm_bindgen::JsCast
|
||||
};
|
||||
use web_sys::{KeyboardEvent, MouseEvent, wasm_bindgen::JsCast};
|
||||
|
||||
use crate::{
|
||||
AppState,
|
||||
|
@ -13,7 +9,7 @@ use crate::{
|
|||
Element,
|
||||
HalfCurvatureRegulator,
|
||||
InversiveDistanceRegulator,
|
||||
Regulator
|
||||
Regulator,
|
||||
},
|
||||
specified::SpecifiedValue
|
||||
};
|
||||
|
@ -49,8 +45,8 @@ fn RegulatorInput(regulator: Rc<dyn Regulator>) -> View {
|
|||
|
||||
view! {
|
||||
input(
|
||||
r#type="text",
|
||||
class=move || {
|
||||
r#type = "text",
|
||||
class = move || {
|
||||
if valid.get() {
|
||||
set_point.with(|set_pt| {
|
||||
if set_pt.is_present() {
|
||||
|
@ -63,27 +59,27 @@ fn RegulatorInput(regulator: Rc<dyn Regulator>) -> View {
|
|||
"regulator-input invalid"
|
||||
}
|
||||
},
|
||||
placeholder=measurement.with(|result| result.to_string()),
|
||||
bind:value=value,
|
||||
on:change=move |_| {
|
||||
placeholder = measurement.with(|result| result.to_string()),
|
||||
bind:value = value,
|
||||
on:change = move |_| {
|
||||
valid.set(
|
||||
match SpecifiedValue::try_from(value.get_clone_untracked()) {
|
||||
Ok(set_pt) => {
|
||||
set_point.set(set_pt);
|
||||
true
|
||||
}
|
||||
Err(_) => false
|
||||
},
|
||||
Err(_) => false,
|
||||
}
|
||||
)
|
||||
},
|
||||
on:keydown={
|
||||
on:keydown = {
|
||||
move |event: KeyboardEvent| {
|
||||
match event.key().as_str() {
|
||||
"Escape" => reset_value(),
|
||||
_ => ()
|
||||
_ => (),
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
)
|
||||
}
|
||||
}
|
||||
|
@ -100,11 +96,11 @@ impl OutlineItem for InversiveDistanceRegulator {
|
|||
self.subjects[0].label()
|
||||
}.clone();
|
||||
view! {
|
||||
li(class="regulator") {
|
||||
div(class="regulator-label") { (other_subject_label) }
|
||||
div(class="regulator-type") { "Inversive distance" }
|
||||
RegulatorInput(regulator=self)
|
||||
div(class="status")
|
||||
li(class = "regulator") {
|
||||
div(class = "regulator-label") { (other_subject_label) }
|
||||
div(class = "regulator-type") { "Inversive distance" }
|
||||
RegulatorInput(regulator = self)
|
||||
div(class = "status")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -113,11 +109,11 @@ impl OutlineItem for InversiveDistanceRegulator {
|
|||
impl OutlineItem for HalfCurvatureRegulator {
|
||||
fn outline_item(self: Rc<Self>, _element: &Rc<dyn Element>) -> View {
|
||||
view! {
|
||||
li(class="regulator") {
|
||||
div(class="regulator-label") // for spacing
|
||||
div(class="regulator-type") { "Half-curvature" }
|
||||
RegulatorInput(regulator=self)
|
||||
div(class="status")
|
||||
li(class = "regulator") {
|
||||
div(class = "regulator-label") // for spacing
|
||||
div(class = "regulator-type") { "Half-curvature" }
|
||||
RegulatorInput(regulator = self)
|
||||
div(class = "status")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -156,10 +152,10 @@ fn ElementOutlineItem(element: Rc<dyn Element>) -> View {
|
|||
let details_node = create_node_ref();
|
||||
view! {
|
||||
li {
|
||||
details(ref=details_node) {
|
||||
details(ref = details_node) {
|
||||
summary(
|
||||
class=class.get(),
|
||||
on:keydown={
|
||||
class = class.get(),
|
||||
on:keydown = {
|
||||
let element_for_handler = element.clone();
|
||||
move |event: KeyboardEvent| {
|
||||
match event.key().as_str() {
|
||||
|
@ -179,18 +175,18 @@ fn ElementOutlineItem(element: Rc<dyn Element>) -> View {
|
|||
.unchecked_into::<web_sys::Element>()
|
||||
.remove_attribute("open");
|
||||
},
|
||||
_ => ()
|
||||
_ => (),
|
||||
}
|
||||
}
|
||||
}
|
||||
) {
|
||||
div(
|
||||
class="element-switch",
|
||||
on:click=|event: MouseEvent| event.stop_propagation()
|
||||
class = "element-switch",
|
||||
on:click = |event: MouseEvent| event.stop_propagation()
|
||||
)
|
||||
div(
|
||||
class="element",
|
||||
on:click={
|
||||
class = "element",
|
||||
on:click = {
|
||||
let state_for_handler = state.clone();
|
||||
let element_for_handler = element.clone();
|
||||
move |event: MouseEvent| {
|
||||
|
@ -200,20 +196,20 @@ fn ElementOutlineItem(element: Rc<dyn Element>) -> View {
|
|||
}
|
||||
}
|
||||
) {
|
||||
div(class="element-label") { (label) }
|
||||
div(class="element-representation") { (rep_components) }
|
||||
div(class = "element-label") { (label) }
|
||||
div(class = "element-representation") { (rep_components) }
|
||||
input(
|
||||
r#type="checkbox",
|
||||
bind:checked=element.ghost(),
|
||||
on:click=|event: MouseEvent| event.stop_propagation()
|
||||
r#type = "checkbox",
|
||||
bind:checked = element.ghost(),
|
||||
on:click = |event: MouseEvent| event.stop_propagation()
|
||||
)
|
||||
}
|
||||
}
|
||||
ul(class="regulators") {
|
||||
ul(class = "regulators") {
|
||||
Keyed(
|
||||
list=regulator_list,
|
||||
view=move |reg| reg.outline_item(&element),
|
||||
key=|reg| reg.serial()
|
||||
list = regulator_list,
|
||||
view = move |reg| reg.outline_item(&element),
|
||||
key = |reg| reg.serial()
|
||||
)
|
||||
}
|
||||
}
|
||||
|
@ -246,18 +242,18 @@ pub fn Outline() -> View {
|
|||
|
||||
view! {
|
||||
ul(
|
||||
id="outline",
|
||||
on:click={
|
||||
id = "outline",
|
||||
on:click = {
|
||||
let state = use_context::<AppState>();
|
||||
move |_| state.selection.update(|sel| sel.clear())
|
||||
}
|
||||
) {
|
||||
Keyed(
|
||||
list=element_list,
|
||||
view=|elt| view! {
|
||||
ElementOutlineItem(element=elt)
|
||||
list = element_list,
|
||||
view = |elt| view! {
|
||||
ElementOutlineItem(element = elt)
|
||||
},
|
||||
key=|elt| elt.serial()
|
||||
key = |elt| elt.serial()
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue