From 317905d0f4c0f668e0fc392d1c12e79bb502fab0 Mon Sep 17 00:00:00 2001 From: luoxiao Date: Mon, 19 Jun 2023 21:53:39 +0800 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20feat:=20change=20input=20type?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- examples/basic/src/pages/input/mod.rs | 2 +- gh-pages/src/pages/input/mod.rs | 2 +- gh-pages/src/pages/menu/mod.rs | 12 +++++++----- src/input/mod.rs | 20 ++++++++++++++++++-- 4 files changed, 27 insertions(+), 9 deletions(-) diff --git a/examples/basic/src/pages/input/mod.rs b/examples/basic/src/pages/input/mod.rs index 090f843..1a50d84 100644 --- a/examples/basic/src/pages/input/mod.rs +++ b/examples/basic/src/pages/input/mod.rs @@ -8,7 +8,7 @@ pub fn InputPage(cx: Scope) -> impl IntoView { <> {move || value.get()} - + } } \ No newline at end of file diff --git a/gh-pages/src/pages/input/mod.rs b/gh-pages/src/pages/input/mod.rs index 090f843..1a50d84 100644 --- a/gh-pages/src/pages/input/mod.rs +++ b/gh-pages/src/pages/input/mod.rs @@ -8,7 +8,7 @@ pub fn InputPage(cx: Scope) -> impl IntoView { <> {move || value.get()} - + } } \ No newline at end of file diff --git a/gh-pages/src/pages/menu/mod.rs b/gh-pages/src/pages/menu/mod.rs index 248f5de..2188e47 100644 --- a/gh-pages/src/pages/menu/mod.rs +++ b/gh-pages/src/pages/menu/mod.rs @@ -5,10 +5,12 @@ use melt_ui::*; pub fn MenuPage(cx: Scope) -> impl IntoView { let selected = create_rw_signal(cx, String::from("o")); view! { cx, - { move || selected.get() } - - - - +
+ { move || selected.get() } + + + + +
} } diff --git a/src/input/mod.rs b/src/input/mod.rs index 4775c7a..69c73bd 100644 --- a/src/input/mod.rs +++ b/src/input/mod.rs @@ -7,11 +7,27 @@ use leptos::*; use stylers::style_sheet_str; pub use theme::InputTheme; +#[derive(Default, Clone)] +pub enum InputType { + #[default] + TEXT, + PASSWORD, +} + +impl InputType { + pub fn as_str(&self) -> &'static str { + match self { + InputType::TEXT => "text", + InputType::PASSWORD => "password", + } + } +} + #[component] pub fn Input( cx: Scope, #[prop(into)] value: RwSignal, - #[prop(default = MaybeSignal::Static(String::from("text")), into)] type_: MaybeSignal, + #[prop(optional, into)] type_: MaybeSignal, ) -> impl IntoView { let theme = use_theme(cx, Theme::light); let class_name = mount_style("input", || style_sheet_str!("./src/input/input.css")); @@ -35,7 +51,7 @@ pub fn Input( view! { cx, class=class_name,
- +
} }