feat(leptos): frontend crate scaffold with empty app
- frontend/ crate compiles to WASM via trunk - empty Leptos app mounted to body via wasm_bindgen(start) - dependencies: leptos 0.7 CSR, leptos-use, lucide-leptos, gloo-net, web-sys - workspace cargo check passes (first time the workspace compiles end-to-end) - trunk build produces 65KB WASM + 25KB JS glue Deviations from brief: - lucide-leptos: 0.5 (brief) -> 3 (only version published) - web-sys: removed invalid features ArrayBuffer/DataView (in js-sys/wasm-bindgen) - src/main.rs -> src/lib.rs with #[wasm_bindgen(start)] to avoid bin/lib duplicate artifact
This commit is contained in:
@@ -13,3 +13,5 @@ logs/
|
||||
.moon/docker
|
||||
worktrees/
|
||||
.worktrees/
|
||||
frontend-leptos/frontend/dist/
|
||||
target/
|
||||
|
||||
Generated
+2544
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,49 @@
|
||||
[package]
|
||||
name = "frontend"
|
||||
version = "0.1.0"
|
||||
edition = "2021"
|
||||
|
||||
[lib]
|
||||
crate-type = ["cdylib", "rlib"]
|
||||
|
||||
[dependencies]
|
||||
leptos = { version = "0.7", features = ["csr"] }
|
||||
leptos-use = "0.14"
|
||||
lucide-leptos = "3"
|
||||
shared-types = { path = "../shared-types" }
|
||||
wasm-bindgen = "0.2"
|
||||
js-sys = "0.3"
|
||||
web-sys = { version = "0.3", features = [
|
||||
"WebSocket",
|
||||
"MessageEvent",
|
||||
"CloseEvent",
|
||||
"CanvasRenderingContext2d",
|
||||
"AudioContext",
|
||||
"AudioBuffer",
|
||||
"AudioBufferSourceNode",
|
||||
"Window",
|
||||
"Document",
|
||||
"Element",
|
||||
"HtmlElement",
|
||||
"KeyboardEvent",
|
||||
"Storage",
|
||||
"IntersectionObserver",
|
||||
"ResizeObserver",
|
||||
"Url",
|
||||
"Headers",
|
||||
"Request",
|
||||
"RequestInit",
|
||||
"Response",
|
||||
"HtmlInputElement",
|
||||
"HtmlAudioElement",
|
||||
"HtmlCanvasElement",
|
||||
"MediaDevices",
|
||||
"MediaStream",
|
||||
"Navigator",
|
||||
"console",
|
||||
] }
|
||||
gloo-net = "0.6"
|
||||
serde = { version = "1", features = ["derive"] }
|
||||
serde-wasm-bindgen = "0.6"
|
||||
wasm-logger = "0.2"
|
||||
console_error_panic_hook = "0.1"
|
||||
@@ -0,0 +1,7 @@
|
||||
[build]
|
||||
target = "index.html"
|
||||
dist = "dist"
|
||||
|
||||
[serve]
|
||||
port = 8080
|
||||
open = false
|
||||
@@ -0,0 +1,20 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="id">
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<meta name="theme-color" content="#23a1eb" />
|
||||
<title>IMPHNEN -- Discord Moderation</title>
|
||||
<link data-trunk rel="rust" data-crate="frontend" data-wasm="frontend.wasm" />
|
||||
<link data-trunk rel="copy-dir" href="public/" />
|
||||
<!-- Poppins font -->
|
||||
<link rel="preconnect" href="https://fonts.googleapis.com" />
|
||||
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
|
||||
<link href="https://fonts.googleapis.com/css2?family=Poppins:wght@300;400;500;600;700;800&display=swap" rel="stylesheet" />
|
||||
<!-- Preload WASM (Trunk inlines this, but just in case) -->
|
||||
<link rel="preload" href="/frontend.wasm" as="fetch" crossorigin="anonymous" />
|
||||
</head>
|
||||
<body>
|
||||
<!-- Leptos CSR mounts to document.body by default -->
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1 @@
|
||||
# Trunk copies this directory to dist/
|
||||
@@ -0,0 +1,10 @@
|
||||
use leptos::prelude::*;
|
||||
|
||||
#[component]
|
||||
pub fn App() -> impl IntoView {
|
||||
view! {
|
||||
<div style="display: flex; align-items: center; justify-content: center; height: 100vh; font-family: 'Poppins', sans-serif; font-size: 1.5rem; background: #0f172a; color: #e2e8f0;">
|
||||
"Hello from Leptos"
|
||||
</div>
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
pub mod app;
|
||||
|
||||
use wasm_bindgen::prelude::*;
|
||||
|
||||
#[wasm_bindgen(start)]
|
||||
pub fn start() {
|
||||
// Set up panic hook for better error messages in the browser console
|
||||
console_error_panic_hook::set_once();
|
||||
// Initialize logger
|
||||
wasm_logger::init(wasm_logger::Config::default());
|
||||
|
||||
// Mount the Leptos app to the body
|
||||
leptos::mount::mount_to_body(app::App);
|
||||
}
|
||||
Reference in New Issue
Block a user