Add themes, update layout, fix pages
Some checks failed
Build Crate / build (push) Failing after 1m53s

This commit is contained in:
2024-08-31 03:12:28 -04:00
parent 659037ec00
commit 3e2163dbf3
18 changed files with 347 additions and 123 deletions

View File

@@ -15,6 +15,8 @@ pub struct AppState {
pub auth: AuthData,
#[rx(nested)]
pub modals_open: ModalOpenData,
#[rx(nested)]
pub style: StyleData,
}
#[derive(Serialize, Deserialize, ReactiveState, Clone)]
@@ -27,6 +29,62 @@ pub struct AuthData {
pub auth_info: Option<WebAuthInfo>,
}
#[derive(Serialize, Deserialize, ReactiveState, Clone)]
#[rx(alias = "ModalOpenDataRx")]
pub struct ModalOpenData {
pub login: OpenState,
pub register: OpenState,
pub forgot_password: OpenState,
}
#[derive(Serialize, Deserialize, ReactiveState, Clone)]
#[rx(alias = "StyleDataRx")]
pub struct StyleData {
#[rx(nested)]
pub theme: ThemeData,
}
#[derive(Serialize, Deserialize, ReactiveState, Clone)]
#[rx(alias = "ThemeDataRx")]
pub struct ThemeData {
pub current: String,
pub pool: String,
pub pickleball: String,
pub table_tennis: String,
pub default: String,
}
pub fn get_global_state_creator() -> GlobalStateCreator {
GlobalStateCreator::new().build_state_fn(get_build_state)
}
#[engine_only_fn]
pub async fn get_build_state() -> AppState {
AppState {
auth: AuthData {
state: LoginState::Unknown,
pending_username: String::new(),
username: None,
remember_me: None,
auth_info: None,
},
modals_open: ModalOpenData {
login: OpenState::Closed,
register: OpenState::Closed,
forgot_password: OpenState::Closed,
},
style: StyleData {
theme: ThemeData {
current: "light".to_owned(),
pool: "autumn".to_owned(),
pickleball: "lemonade".to_owned(),
table_tennis: "nord".to_owned(),
default: "light".to_owned(),
},
},
}
}
impl AuthDataRx {
#[cfg(client)]
pub fn handle_log_in(&self, auth_info: WebAuthInfo) {
@@ -73,36 +131,6 @@ impl AuthDataRx {
}
}
#[derive(Serialize, Deserialize, ReactiveState, Clone)]
#[rx(alias = "ModalOpenDataRx")]
pub struct ModalOpenData {
pub login: OpenState,
pub register: OpenState,
pub forgot_password: OpenState,
}
pub fn get_global_state_creator() -> GlobalStateCreator {
GlobalStateCreator::new().build_state_fn(get_build_state)
}
#[engine_only_fn]
pub async fn get_build_state() -> AppState {
AppState {
auth: AuthData {
state: LoginState::Unknown,
pending_username: String::new(),
username: None,
remember_me: None,
auth_info: None,
},
modals_open: ModalOpenData {
login: OpenState::Closed,
register: OpenState::Closed,
forgot_password: OpenState::Closed,
},
}
}
// Client only code to check if they're authenticated
#[cfg(client)]
impl AuthDataRx {