summaryrefslogtreecommitdiff
path: root/crates/wipfel/src/widgets.rs
diff options
context:
space:
mode:
Diffstat (limited to 'crates/wipfel/src/widgets.rs')
-rw-r--r--crates/wipfel/src/widgets.rs29
1 files changed, 29 insertions, 0 deletions
diff --git a/crates/wipfel/src/widgets.rs b/crates/wipfel/src/widgets.rs
index 1d22bac..93e2cdc 100644
--- a/crates/wipfel/src/widgets.rs
+++ b/crates/wipfel/src/widgets.rs
@@ -46,6 +46,35 @@ pub fn slider_item(p: &SliderProps) -> Html {
}
}
+/// single-line text row (e.g. paste a GPS string)
+#[derive(Properties, PartialEq)]
+pub struct TextProps {
+ pub label: AttrValue,
+ pub placeholder: AttrValue,
+ pub onchange: Callback<String>,
+}
+
+#[function_component(TextItem)]
+pub fn text_item(p: &TextProps) -> Html {
+ let onchange = {
+ let onchange = p.onchange.clone();
+ Callback::from(move |e: Event| {
+ let input: HtmlInputElement = e.target_unchecked_into();
+ onchange.emit(input.value());
+ })
+ };
+ html! {
+ <label class="numrow">
+ <span>{ p.label.as_ref().to_string() }</span>
+ <input
+ type="text"
+ placeholder={p.placeholder.as_ref().to_string()}
+ {onchange}
+ />
+ </label>
+ }
+}
+
#[derive(Properties, PartialEq)]
pub struct NumProps {
pub label: AttrValue,