Update dependencies and UI for WASM compatibility

- Simplify Cargo.toml dependencies for frontend-only build
- Add comprehensive CSS styling with responsive design
- Update app routing and main module structure
- Fix WASM getrandom compatibility with js feature

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
Connor Johnstone
2025-08-28 15:56:41 -04:00
parent 181e0c58c1
commit 08c333dcba
4 changed files with 371 additions and 22 deletions

View File

@@ -1,7 +1,109 @@
use yew::prelude::*;
use yew_router::prelude::*;
use gloo_storage::{LocalStorage, Storage};
use crate::components::{Login, Register};
#[derive(Clone, Routable, PartialEq)]
enum Route {
#[at("/")]
Home,
#[at("/login")]
Login,
#[at("/register")]
Register,
#[at("/calendar")]
Calendar,
}
#[function_component]
pub fn App() -> Html {
let auth_token = use_state(|| -> Option<String> {
LocalStorage::get("auth_token").ok()
});
let on_login = {
let auth_token = auth_token.clone();
Callback::from(move |token: String| {
auth_token.set(Some(token));
})
};
let on_logout = {
let auth_token = auth_token.clone();
Callback::from(move |_| {
let _ = LocalStorage::delete("auth_token");
auth_token.set(None);
})
};
html! {
<BrowserRouter>
<div class="app">
<header class="app-header">
<h1>{"Calendar App"}</h1>
{
if auth_token.is_some() {
html! {
<nav>
<Link<Route> to={Route::Calendar}>{"Calendar"}</Link<Route>>
<button onclick={on_logout} class="logout-button">{"Logout"}</button>
</nav>
}
} else {
html! {
<nav>
<Link<Route> to={Route::Login}>{"Login"}</Link<Route>>
<Link<Route> to={Route::Register}>{"Register"}</Link<Route>>
</nav>
}
}
}
</header>
<main class="app-main">
<Switch<Route> render={move |route| {
let auth_token = (*auth_token).clone();
let on_login = on_login.clone();
match route {
Route::Home => {
if auth_token.is_some() {
html! { <Redirect<Route> to={Route::Calendar}/> }
} else {
html! { <Redirect<Route> to={Route::Login}/> }
}
}
Route::Login => {
if auth_token.is_some() {
html! { <Redirect<Route> to={Route::Calendar}/> }
} else {
html! { <Login {on_login} /> }
}
}
Route::Register => {
if auth_token.is_some() {
html! { <Redirect<Route> to={Route::Calendar}/> }
} else {
html! { <Register on_register={on_login.clone()} /> }
}
}
Route::Calendar => {
if auth_token.is_some() {
html! { <CalendarView /> }
} else {
html! { <Redirect<Route> to={Route::Login}/> }
}
}
}
}} />
</main>
</div>
</BrowserRouter>
}
}
#[function_component]
fn CalendarView() -> Html {
let counter = use_state(|| 0);
let onclick = {
let counter = counter.clone();
@@ -12,13 +114,27 @@ pub fn App() -> Html {
};
html! {
<div>
<h1>{ "Hello Yew!" }</h1>
<p>{ "This is a basic Yew application template." }</p>
<div>
<div class="calendar-view">
<h2>{"Welcome to your Calendar!"}</h2>
<p>{"You are now authenticated and can access your calendar."}</p>
// Temporary counter demo - will be replaced with calendar functionality
<div class="demo-section">
<h3>{"Demo Counter"}</h3>
<button {onclick}>{ "Click me!" }</button>
<p>{ format!("Counter: {}", *counter) }</p>
</div>
<div class="calendar-placeholder">
<p>{"Calendar functionality will be implemented here."}</p>
<p>{"This will include:"}</p>
<ul>
<li>{"Calendar view with events"}</li>
<li>{"Integration with CalDAV server"}</li>
<li>{"Event creation and editing"}</li>
<li>{"Synchronization with Baikal server"}</li>
</ul>
</div>
</div>
}
}

View File

@@ -1,8 +1,9 @@
use yew::prelude::*;
mod app;
mod config;
mod calendar;
mod auth;
mod components;
use app::App;