Renamed frontend directory

This commit is contained in:
2026-01-27 19:37:20 +02:00
parent a9dd3eea7a
commit 207947c095
37 changed files with 1 additions and 1 deletions

57
frontend/src/app.rs Normal file
View File

@@ -0,0 +1,57 @@
use leptos::{prelude::*, reactive::spawn_local};
use leptos_router::{
components::{Route, Router, Routes},
path,
};
use wasm_bindgen::prelude::*;
#[wasm_bindgen]
extern "C" {
#[wasm_bindgen(js_namespace = ["window", "__TAURI__", "core"])]
async fn invoke(cmd: &str, args: JsValue) -> JsValue;
}
#[component]
pub fn App() -> impl IntoView {
view! {
<Router>
<Routes fallback=|| view! { "Page not found."}>
<Route path=path!("/") view=Dashboard />
<Route path=path!("/popup") view=Popup />
</Routes>
</Router>
}
}
#[component]
fn Dashboard() -> impl IntoView {
let on_click = move |_ev: leptos::ev::MouseEvent| {
spawn_local(async move {
let empty_args = serde_wasm_bindgen::to_value(&serde_json::json!({})).unwrap();
invoke("toggle_popup", empty_args).await;
});
};
let prompt = |_ev: leptos::ev::MouseEvent| {
spawn_local(async {
let prompt = serde_wasm_bindgen::to_value(&serde_json::json!({"prompt": "jee juu juu"})).unwrap();
invoke("prompt_llm", prompt).await;
});
};
view! {
<main class="window-shell opaque-bg">
<h1>"AI Dashboard"</h1>
<button on:click=on_click>Test popup</button>
<button on:click=prompt>Prompt!</button>
</main>
}
}
#[component]
fn Popup() -> impl IntoView {
view! {
<main class="window-shell rounded-container">
<h3>"AI quick action"</h3>
<input type="text" placeholder="Ask Gordon AI" autofocus />
</main>
}
}