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

@@ -10,8 +10,6 @@ wasm-bindgen = "0.2"
# HTTP client for CalDAV requests
reqwest = { version = "0.11", features = ["json"] }
wasm-bindgen-futures = "0.4"
# Calendar and iCal parsing
ical = "0.7"
serde = { version = "1.0", features = ["derive"] }
@@ -30,7 +28,8 @@ log = "0.4"
console_log = "1.0"
# UUID generation for calendar events
uuid = { version = "1.0", features = ["v4", "wasm-bindgen"] }
uuid = { version = "1.0", features = ["v4", "wasm-bindgen", "serde"] }
getrandom = { version = "0.2", features = ["js"] }
# Environment variable handling
dotenvy = "0.15"
@@ -39,5 +38,16 @@ base64 = "0.21"
# XML/Regex parsing
regex = "1.0"
# Frontend authentication (backend removed for WASM compatibility)
# sqlx = { version = "0.7", features = ["runtime-tokio-rustls", "sqlite", "chrono", "uuid", "migrate"] }
# bcrypt = "0.15"
# jsonwebtoken = "9.0"
# Yew routing and local storage
yew-router = "0.18"
gloo-storage = "0.3"
gloo-timers = "0.3"
wasm-bindgen-futures = "0.4"
[dev-dependencies]
tokio = { version = "1.0", features = ["macros", "rt"] }

View File

@@ -2,38 +2,260 @@
<html>
<head>
<meta charset="utf-8" />
<title>Yew App</title>
<title>Calendar App</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<style>
body {
font-family: Arial, sans-serif;
* {
margin: 0;
padding: 20px;
background-color: #f5f5f5;
padding: 0;
box-sizing: border-box;
}
div {
max-width: 600px;
body {
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
background-color: #f8f9fa;
color: #333;
line-height: 1.6;
}
.app {
min-height: 100vh;
display: flex;
flex-direction: column;
}
.app-header {
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
color: white;
padding: 1rem 2rem;
display: flex;
justify-content: space-between;
align-items: center;
box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}
.app-header h1 {
margin: 0;
font-size: 1.8rem;
}
.app-header nav {
display: flex;
gap: 1rem;
align-items: center;
}
.app-header nav a {
color: white;
text-decoration: none;
padding: 0.5rem 1rem;
border-radius: 4px;
transition: background-color 0.2s;
}
.app-header nav a:hover {
background-color: rgba(255,255,255,0.2);
}
.app-main {
flex: 1;
padding: 2rem;
max-width: 1200px;
margin: 0 auto;
padding: 20px;
background-color: white;
width: 100%;
}
/* Authentication Forms */
.login-container, .register-container {
display: flex;
justify-content: center;
align-items: center;
min-height: 60vh;
}
.login-form, .register-form {
background: white;
padding: 2rem;
border-radius: 8px;
box-shadow: 0 4px 6px rgba(0,0,0,0.1);
width: 100%;
max-width: 400px;
}
.login-form h2, .register-form h2 {
text-align: center;
margin-bottom: 2rem;
color: #333;
}
.form-group {
margin-bottom: 1.5rem;
}
.form-group label {
display: block;
margin-bottom: 0.5rem;
font-weight: 500;
color: #555;
}
.form-group input {
width: 100%;
padding: 0.75rem;
border: 1px solid #ddd;
border-radius: 4px;
font-size: 1rem;
transition: border-color 0.2s;
}
.form-group input:focus {
outline: none;
border-color: #667eea;
box-shadow: 0 0 0 2px rgba(102, 126, 234, 0.2);
}
.form-group input:disabled {
background-color: #f5f5f5;
cursor: not-allowed;
}
.login-button, .register-button {
width: 100%;
padding: 0.75rem;
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
color: white;
border: none;
border-radius: 4px;
font-size: 1rem;
font-weight: 500;
cursor: pointer;
transition: transform 0.2s, box-shadow 0.2s;
}
.login-button:hover, .register-button:hover {
transform: translateY(-1px);
box-shadow: 0 4px 8px rgba(0,0,0,0.2);
}
.login-button:disabled, .register-button:disabled {
background: #ccc;
transform: none;
cursor: not-allowed;
}
.error-message {
background-color: #f8d7da;
color: #721c24;
padding: 0.75rem;
border-radius: 4px;
margin-bottom: 1rem;
border: 1px solid #f5c6cb;
}
.auth-links {
text-align: center;
margin-top: 2rem;
color: #666;
}
.auth-links a {
color: #667eea;
text-decoration: none;
}
.auth-links a:hover {
text-decoration: underline;
}
.logout-button {
background: rgba(255,255,255,0.2);
border: 1px solid rgba(255,255,255,0.3);
color: white;
padding: 0.5rem 1rem;
border-radius: 4px;
cursor: pointer;
transition: background-color 0.2s;
}
.logout-button:hover {
background: rgba(255,255,255,0.3);
}
/* Calendar View */
.calendar-view {
background: white;
padding: 2rem;
border-radius: 8px;
box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}
h1 {
.calendar-view h2 {
color: #333;
margin-bottom: 1rem;
}
.demo-section {
margin: 2rem 0;
padding: 1rem;
background: #f8f9fa;
border-radius: 4px;
border-left: 4px solid #667eea;
}
.demo-section h3 {
margin-bottom: 1rem;
color: #333;
}
button {
.demo-section button {
background-color: #007bff;
color: white;
border: none;
padding: 10px 20px;
padding: 0.5rem 1rem;
border-radius: 4px;
cursor: pointer;
font-size: 16px;
margin-right: 1rem;
}
button:hover {
.demo-section button:hover {
background-color: #0056b3;
}
.calendar-placeholder {
margin-top: 2rem;
padding: 1rem;
background: #e9ecef;
border-radius: 4px;
}
.calendar-placeholder ul {
margin: 1rem 0;
padding-left: 2rem;
}
.calendar-placeholder li {
margin: 0.5rem 0;
}
@media (max-width: 768px) {
.app-header {
flex-direction: column;
text-align: center;
padding: 1rem;
}
.app-header nav {
margin-top: 1rem;
}
.app-main {
padding: 1rem;
}
.login-form, .register-form {
padding: 1.5rem;
}
}
</style>
</head>
<body></body>

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;