ppc login works in mme main
This commit is contained in:
@@ -0,0 +1,103 @@
|
||||
use dioxus::prelude::*;
|
||||
|
||||
const STYLE: &str = r#".dx-prompt {
|
||||
position: relative;
|
||||
display: flex;
|
||||
width: 100%;
|
||||
box-sizing: border-box;
|
||||
flex-direction: row;
|
||||
align-items: center;
|
||||
padding: 0.4rem 0.75rem;
|
||||
border: 1px solid var(--border);
|
||||
border-radius: 0.375rem;
|
||||
background: var(--surface);
|
||||
box-shadow: none;
|
||||
gap: 0.5rem;
|
||||
}
|
||||
|
||||
.dx-prompt-input {
|
||||
display: block;
|
||||
width: 100%;
|
||||
min-height: 1.5rem;
|
||||
max-height: 1.5rem;
|
||||
box-sizing: border-box;
|
||||
padding: 0;
|
||||
border: none;
|
||||
margin: 0;
|
||||
background: transparent;
|
||||
color: var(--text);
|
||||
font-family: inherit;
|
||||
font-size: 0.875rem;
|
||||
line-height: 1.5rem;
|
||||
outline: none;
|
||||
overflow: hidden;
|
||||
resize: none;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.dx-prompt-input::placeholder {
|
||||
color: var(--text-2);
|
||||
}
|
||||
"#;
|
||||
|
||||
#[component]
|
||||
pub fn Prompt(
|
||||
/// Controlled value of the prompt text.
|
||||
#[props(default)]
|
||||
value: String,
|
||||
/// Placeholder shown when empty.
|
||||
#[props(default = "Ask anything…".to_string())]
|
||||
placeholder: String,
|
||||
/// Autofocus the textarea when mounted (default true).
|
||||
#[props(default = true)]
|
||||
autofocus: bool,
|
||||
oninput: Option<EventHandler<FormEvent>>,
|
||||
onkeydown: Option<EventHandler<KeyboardEvent>>,
|
||||
#[props(extends = GlobalAttributes)]
|
||||
attributes: Vec<Attribute>,
|
||||
) -> Element {
|
||||
let mut textarea_el = use_signal(|| None::<std::rc::Rc<MountedData>>);
|
||||
|
||||
use_effect(move || {
|
||||
if !autofocus {
|
||||
return;
|
||||
}
|
||||
if let Some(el) = textarea_el() {
|
||||
spawn(async move {
|
||||
let _ = el.set_focus(true).await;
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
rsx! {
|
||||
crate::OnceStyle { href: "dioxus-components/prompt", css: STYLE }
|
||||
|
||||
div {
|
||||
class: "dx-prompt",
|
||||
"data-slot": "prompt",
|
||||
..attributes,
|
||||
textarea {
|
||||
class: "dx-prompt-input",
|
||||
"data-slot": "prompt-input",
|
||||
value,
|
||||
placeholder,
|
||||
rows: 1,
|
||||
onmounted: move |e| textarea_el.set(Some(e.data())),
|
||||
oninput: move |e| {
|
||||
if let Some(cb) = &oninput {
|
||||
cb.call(e);
|
||||
}
|
||||
},
|
||||
onkeydown: move |e| {
|
||||
// Enter does nothing for now (no submit).
|
||||
if e.key() == Key::Enter {
|
||||
e.prevent_default();
|
||||
}
|
||||
if let Some(cb) = &onkeydown {
|
||||
cb.call(e);
|
||||
}
|
||||
},
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
mod component;
|
||||
pub use component::*;
|
||||
Reference in New Issue
Block a user