feat: with como_web
Some checks failed
continuous-integration/drone/push Build is failing

Signed-off-by: kjuulh <contact@kjuulh.io>
This commit is contained in:
2023-10-21 11:23:11 +02:00
parent 6e16fc6b2b
commit 71b5a63700
48 changed files with 7900 additions and 27 deletions

View File

@@ -0,0 +1,56 @@
use leptos::*;
#[derive(Clone, Debug)]
pub struct CommandLineState {
hidden: bool,
}
#[component]
pub fn CommandLineModalView() -> impl IntoView {
view! { <div>"modal"</div> }
}
#[component]
pub fn CommandLineModal() -> impl IntoView {
let state =
use_context::<RwSignal<CommandLineState>>().expect("command line state must be provided");
let (hidden, _) = create_slice(state, |state| state.hidden, |state, n| state.hidden = n);
view! {
{move || {
if !hidden.get() {
view! { <CommandLineModalView/> }
} else {
view! { }.into_view()
}
}}
}
}
#[component]
pub fn CommandLine(children: Children) -> impl IntoView {
let state = create_rw_signal(CommandLineState { hidden: true });
provide_context(state);
let (hidden, set_hidden) =
create_slice(state, |state| state.hidden, |state, n| state.hidden = n);
leptos_dom::helpers::window_event_listener(ev::keypress, move |event| {
if event.ctrl_key() {
match event.code().as_str() {
"KeyK" => {
set_hidden.set(!hidden.get());
//log!("toggle command")
}
_ => {}
}
}
});
view! {
<div>
<div>{children()}</div>
<CommandLineModal/>
</div>
}
}