feat(components): add the Input component
This commit is contained in:
54
src/components/input/component.rs
Normal file
54
src/components/input/component.rs
Normal file
@@ -0,0 +1,54 @@
|
|||||||
|
use dioxus::prelude::*;
|
||||||
|
|
||||||
|
#[component]
|
||||||
|
pub fn Input(
|
||||||
|
oninput: Option<EventHandler<FormEvent>>,
|
||||||
|
onchange: Option<EventHandler<FormEvent>>,
|
||||||
|
oninvalid: Option<EventHandler<FormEvent>>,
|
||||||
|
onselect: Option<EventHandler<SelectionEvent>>,
|
||||||
|
onselectionchange: Option<EventHandler<SelectionEvent>>,
|
||||||
|
onfocus: Option<EventHandler<FocusEvent>>,
|
||||||
|
onblur: Option<EventHandler<FocusEvent>>,
|
||||||
|
onfocusin: Option<EventHandler<FocusEvent>>,
|
||||||
|
onfocusout: Option<EventHandler<FocusEvent>>,
|
||||||
|
onkeydown: Option<EventHandler<KeyboardEvent>>,
|
||||||
|
onkeypress: Option<EventHandler<KeyboardEvent>>,
|
||||||
|
onkeyup: Option<EventHandler<KeyboardEvent>>,
|
||||||
|
oncompositionstart: Option<EventHandler<CompositionEvent>>,
|
||||||
|
oncompositionupdate: Option<EventHandler<CompositionEvent>>,
|
||||||
|
oncompositionend: Option<EventHandler<CompositionEvent>>,
|
||||||
|
oncopy: Option<EventHandler<ClipboardEvent>>,
|
||||||
|
oncut: Option<EventHandler<ClipboardEvent>>,
|
||||||
|
onpaste: Option<EventHandler<ClipboardEvent>>,
|
||||||
|
#[props(extends=GlobalAttributes)]
|
||||||
|
#[props(extends=input)]
|
||||||
|
attributes: Vec<Attribute>,
|
||||||
|
children: Element,
|
||||||
|
) -> Element {
|
||||||
|
rsx! {
|
||||||
|
document::Link { rel: "stylesheet", href: asset!("./style.css") }
|
||||||
|
input {
|
||||||
|
class: "input",
|
||||||
|
oninput: move |e| _ = oninput.map(|callback| callback(e)),
|
||||||
|
onchange: move |e| _ = onchange.map(|callback| callback(e)),
|
||||||
|
oninvalid: move |e| _ = oninvalid.map(|callback| callback(e)),
|
||||||
|
onselect: move |e| _ = onselect.map(|callback| callback(e)),
|
||||||
|
onselectionchange: move |e| _ = onselectionchange.map(|callback| callback(e)),
|
||||||
|
onfocus: move |e| _ = onfocus.map(|callback| callback(e)),
|
||||||
|
onblur: move |e| _ = onblur.map(|callback| callback(e)),
|
||||||
|
onfocusin: move |e| _ = onfocusin.map(|callback| callback(e)),
|
||||||
|
onfocusout: move |e| _ = onfocusout.map(|callback| callback(e)),
|
||||||
|
onkeydown: move |e| _ = onkeydown.map(|callback| callback(e)),
|
||||||
|
onkeypress: move |e| _ = onkeypress.map(|callback| callback(e)),
|
||||||
|
onkeyup: move |e| _ = onkeyup.map(|callback| callback(e)),
|
||||||
|
oncompositionstart: move |e| _ = oncompositionstart.map(|callback| callback(e)),
|
||||||
|
oncompositionupdate: move |e| _ = oncompositionupdate.map(|callback| callback(e)),
|
||||||
|
oncompositionend: move |e| _ = oncompositionend.map(|callback| callback(e)),
|
||||||
|
oncopy: move |e| _ = oncopy.map(|callback| callback(e)),
|
||||||
|
oncut: move |e| _ = oncut.map(|callback| callback(e)),
|
||||||
|
onpaste: move |e| _ = onpaste.map(|callback| callback(e)),
|
||||||
|
..attributes,
|
||||||
|
{children}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
2
src/components/input/mod.rs
Normal file
2
src/components/input/mod.rs
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
mod component;
|
||||||
|
pub use component::*;
|
||||||
39
src/components/input/style.css
Normal file
39
src/components/input/style.css
Normal file
@@ -0,0 +1,39 @@
|
|||||||
|
/* Input Styles */
|
||||||
|
.input {
|
||||||
|
position: relative;
|
||||||
|
display: flex;
|
||||||
|
box-sizing: border-box;
|
||||||
|
flex-direction: row;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: space-between;
|
||||||
|
padding: 0.25rem;
|
||||||
|
padding: 8px 12px;
|
||||||
|
border: none;
|
||||||
|
border-radius: 0.5rem;
|
||||||
|
border-radius: calc(0.5rem);
|
||||||
|
background: none;
|
||||||
|
background-color: var(--light, var(--primary-color)) var(--dark, color-mix(in oklab, #FFFFFF26 30%, transparent));
|
||||||
|
box-shadow: inset 0 0 0 1px var(--light, var(--primary-color-6))
|
||||||
|
var(--dark, var(--primary-color-7));
|
||||||
|
color: var(--secondary-color-4);
|
||||||
|
cursor: pointer;
|
||||||
|
gap: 0.25rem;
|
||||||
|
transition: background-color 100ms ease-out;
|
||||||
|
}
|
||||||
|
|
||||||
|
.input::placeholder {
|
||||||
|
color: var(--secondary-color-5);
|
||||||
|
}
|
||||||
|
|
||||||
|
.input:disabled {
|
||||||
|
color: var(--secondary-color-5);
|
||||||
|
cursor: not-allowed;
|
||||||
|
}
|
||||||
|
|
||||||
|
.input:hover:not(:disabled),
|
||||||
|
.input:focus-visible {
|
||||||
|
background: var(--light, var(--primary-color-4))
|
||||||
|
var(--dark, color-mix(in oklab, #FFFFFF26 50%, transparent));
|
||||||
|
color: var(--secondary-color-1);
|
||||||
|
outline: none;
|
||||||
|
}
|
||||||
@@ -5,5 +5,8 @@
|
|||||||
mod hero;
|
mod hero;
|
||||||
pub use hero::Hero;
|
pub use hero::Hero;
|
||||||
|
|
||||||
|
mod input;
|
||||||
|
pub use input::Input;
|
||||||
|
|
||||||
mod echo;
|
mod echo;
|
||||||
pub use echo::Echo;
|
pub use echo::Echo;
|
||||||
|
|||||||
Reference in New Issue
Block a user