Skip to content

Commit

Permalink
chore: add callbacks for textield
Browse files Browse the repository at this point in the history
  • Loading branch information
Michael-Liendo committed Jul 20, 2024
1 parent a37c914 commit 65e4c92
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions crates/web/src/components/text_field.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ use core::fmt;
use std::{collections::HashSet, fmt::Debug};

use leptos::{
component, create_memo, event_target_value, leptos_dom::logging::console_log, logging, view,
IntoView, MaybeProp, SignalGet, TextProp,
component, create_memo, event_target_value, view, Callable, Callback, IntoView, MaybeProp,
SignalGet, TextProp,
};

#[derive(Clone, Debug, Default)]
Expand Down Expand Up @@ -39,6 +39,7 @@ pub fn TextField(
#[prop(optional, into)] label: TextProp,
#[prop(optional, into)] class: TextProp,
#[prop(optional, into)] variant: MaybeProp<TextFieldVariant>,
#[prop(optional, into)] on_input: MaybeProp<Callback<String>>,
#[prop(optional, into)] r#type: TextFieldType,
#[prop(optional, into)] disabled: MaybeProp<bool>,
#[prop(optional, into)] full_width: MaybeProp<bool>,
Expand Down Expand Up @@ -85,7 +86,7 @@ pub fn TextField(
view! {
<div>
<label class="block mb-2 text-sm font-medium text-purple-500" for=id.clone()>{label}</label>
<input type=format!("{}", r#type) name=name value=value id=id placeholder=placeholder class=class_names disabled=disabled on:change=move |ev| {console_log(event_target_value(&ev).as_str())} />
<input type=format!("{}", r#type) name=name value=value id=id placeholder=placeholder class=class_names disabled=disabled on:change=move |ev| {on_input.get().unwrap().call(event_target_value(&ev))} />
</div>
}
}

0 comments on commit 65e4c92

Please sign in to comment.