From da0fcaa999345b839d9248214ef2fd536f2373be Mon Sep 17 00:00:00 2001 From: Calli Evers Date: Fri, 14 Jun 2024 19:20:34 +0200 Subject: [PATCH] feat: zoom using scroll --- src/components/atoms/button.rs | 2 +- src/components/atoms/number_input.rs | 7 ++++--- src/components/molecules/canvas.rs | 19 +++++++++++++++++++ src/components/organisms/sidebar.rs | 2 +- 4 files changed, 25 insertions(+), 5 deletions(-) diff --git a/src/components/atoms/button.rs b/src/components/atoms/button.rs index 9e933ea..9af0e86 100644 --- a/src/components/atoms/button.rs +++ b/src/components/atoms/button.rs @@ -9,7 +9,7 @@ where let mut class = "inline-block rounded px-6 py-2 text-base font-semibold uppercase leading-normal shadow-primary-3 dark:shadow-neutral-950 hover:shadow-blue-900 dark:hover:shadow-neutral-900".to_owned(); if outlined { - class += " border-solid border-4 text-blue-400 border-blue-400 hover:text-blue-500 hover:border-blue-500 active:text-blue-600 active:border-blue-600 dark:text-blue-600 dark:border-blue-600 dark:hover:text-blue-700 dark:hover:border-blue-700 dark:active:text-blue-800 dark:active:border-blue-800" + class += " border-solid border-4 text-blue-400 border-blue-400 hover:text-blue-500 hover:border-blue-500 active:text-blue-600 active:border-blue-600 dark:text-blue-500 dark:border-blue-500 dark:hover:text-blue-600 dark:hover:border-blue-600 dark:active:text-blue-700 dark:active:border-blue-700" } else { class += " text-white bg-blue-400 hover:bg-blue-500 active:bg-blue-600 dark:bg-blue-600 dark:hover:bg-blue-700 dark:active:bg-blue-800" } diff --git a/src/components/atoms/number_input.rs b/src/components/atoms/number_input.rs index a8f72cf..a6a59c1 100644 --- a/src/components/atoms/number_input.rs +++ b/src/components/atoms/number_input.rs @@ -3,15 +3,16 @@ use std::i32; use leptos::*; #[component] -pub fn NumberInput( +pub fn NumberInput( text: &'static str, on_input: F, + #[prop(optional)] value: Option, #[prop(optional)] min: f64, #[prop(default = (i32::MAX) as f64)] max: f64, - #[prop(optional)] default: f64, ) -> impl IntoView where F: Fn(f64) + 'static, + V: (Fn() -> f64) + Copy + 'static, { let id = text.to_lowercase().replace(" ", "_"); @@ -24,7 +25,7 @@ where on:input=move |ev| {on_input(event_target_value(&ev).parse().expect("number input does not give number"))} max=max min=min - value={default.max(min)} /> + prop:value=move || min.max(value.map_or(0.0, |v| v())) />