From 36f7c9fd80401a209ac2a517817e534dcf1c2826 Mon Sep 17 00:00:00 2001 From: Calli Date: Sat, 21 Dec 2024 00:05:32 +0100 Subject: [PATCH] chore: fix clippy errors --- src/components/atoms/button.rs | 4 ++-- src/components/atoms/canvas_info_box.rs | 14 ++++++------- src/components/atoms/text_with_edit.rs | 10 +++++----- src/components/canvas/keydown.rs | 10 +++------- src/components/canvas/mod.rs | 9 +-------- src/components/molecules/edge_info_box.rs | 2 +- src/components/organisms/canvas_controls.rs | 10 ++++------ src/components/state/history.rs | 22 +++++++++++++++------ src/components/state/mod.rs | 2 -- 9 files changed, 38 insertions(+), 45 deletions(-) diff --git a/src/components/atoms/button.rs b/src/components/atoms/button.rs index fd8a843..0939b5c 100644 --- a/src/components/atoms/button.rs +++ b/src/components/atoms/button.rs @@ -153,7 +153,7 @@ pub fn Button( let hover_class = "hidden group-hover:block rounded text-xs absolute z-10 width-fit p-1.5 bg-neutral-800 text-center bottom-[110%] right-0 whitespace-pre"; - let text_for_children = text.clone(); + let text_for_children = text; let children_signal = move || { children .clone() @@ -178,7 +178,7 @@ pub fn Button( {children_signal} - {text.clone()} + {text} diff --git a/src/components/atoms/canvas_info_box.rs b/src/components/atoms/canvas_info_box.rs index 8e87143..1617654 100644 --- a/src/components/atoms/canvas_info_box.rs +++ b/src/components/atoms/canvas_info_box.rs @@ -3,25 +3,23 @@ use leptos::{ html::Div, prelude::*, + text_prop::TextProp, }; use crate::MapState; /// A generic canvas info box that others can be based upon. -#[allow(clippy::needless_pass_by_value)] // cannot be a reference because of the `Fn` trait #[component] -pub fn CanvasInfoBox( +pub fn CanvasInfoBox( /// The title of the info box, - title: S, + #[prop(into)] + title: TextProp, /// If the info box should be shown. click_position: Signal>, /// The body of the info box if applicable. #[prop(optional)] children: Option, -) -> impl IntoView -where - S: ToString + 'static, -{ +) -> impl IntoView { let info_box_ref: NodeRef
= NodeRef::new(); let map_state = use_context::>().expect("to have found the global map state"); @@ -78,7 +76,7 @@ where class="absolute w-80 max-w-2xl max-h-full"> // title
-

{title.to_string()}

+

{move || title.get()}

{text.get()} - @@ -109,14 +109,14 @@ where type="text" maxlength="100" class="grow peer block min-h-[auto] w-full rounded border-b-2 rounded-md border-solid border-blue-400 bg-transparent px-3 py-[0.32rem] leading-[1.6] outline-none transition-all duration-200 ease-linear peer-focus:text-primary motion-reduce:transition-none dark:text-white dark:placeholder:text-neutral-300 dark:autofill:shadow-autofill dark:peer-focus:text-primary dark:border-blue-600 focus:border-blue-600 dark:focus:border-blue-800" - id={id.clone()} + id={id} on:input=move |ev| set_text_input(event_target_value(&ev)) prop:value=move || text_input.get() on:keydown=on_submit />