diff --git a/accounts/src/forms/cookies.rs b/accounts/src/forms/cookies.rs index 3d6f10d..6988fdf 100644 --- a/accounts/src/forms/cookies.rs +++ b/accounts/src/forms/cookies.rs @@ -9,6 +9,7 @@ pub type CookiesArgs = (Session, web::Data); #[derive(Debug)] pub struct CookiesState { state: State, + pub(crate) dark: bool, } pub fn cookies_page((cookies, state): CookiesPageArgs) -> Result { @@ -29,9 +30,14 @@ impl CookiesState { fn new(state: &State) -> Self { CookiesState { state: state.clone(), + dark: false, } } + pub fn dark(&mut self, dark: bool) { + self.dark = dark; + } + pub(crate) fn cookies_path(&self) -> String { self.state.pages.cookies_path() } diff --git a/accounts/src/forms/delete_user.rs b/accounts/src/forms/delete_user.rs index 7e34779..3a5cce2 100644 --- a/accounts/src/forms/delete_user.rs +++ b/accounts/src/forms/delete_user.rs @@ -21,6 +21,7 @@ pub struct DeleteUserState { state: State, form: Option, error: Option, + pub(crate) dark: bool, } pub fn delete_user_page((_, state): DeleteUserPageArgs) -> Result { @@ -44,6 +45,7 @@ impl DeleteUserState { state: state.clone(), form: None, error: None, + dark: false, } } @@ -52,9 +54,14 @@ impl DeleteUserState { state: state.clone(), form: form.into(), error: error.into(), + dark: false, } } + pub fn dark(&mut self, dark: bool) { + self.dark = dark; + } + pub(crate) fn delete_user_path(&self) -> String { self.state.pages.delete_user_path() } diff --git a/accounts/src/forms/login.rs b/accounts/src/forms/login.rs index a9b4a58..affbebf 100644 --- a/accounts/src/forms/login.rs +++ b/accounts/src/forms/login.rs @@ -27,6 +27,7 @@ pub struct LoginState { state: State, form: Option, error: Option, + pub(crate) dark: bool, } pub fn login_page( @@ -63,11 +64,16 @@ pub async fn login( } impl LoginState { + pub fn dark(&mut self, dark: bool) { + self.dark = dark; + } + fn new_empty(state: &State) -> Self { LoginState { state: state.clone(), form: None, error: None, + dark: false, } } @@ -76,6 +82,7 @@ impl LoginState { state: state.clone(), form: Some(form), error: Some(error), + dark: false, } } diff --git a/accounts/src/forms/logout.rs b/accounts/src/forms/logout.rs index 4a2ea01..14de2cf 100644 --- a/accounts/src/forms/logout.rs +++ b/accounts/src/forms/logout.rs @@ -10,6 +10,7 @@ pub type LogoutArgs = (Authenticated, web::Data, Session); #[derive(Clone)] pub struct LogoutState { state: State, + pub(crate) dark: bool, } pub fn logout_page((_, state): LogoutPageArgs) -> LogoutState { @@ -26,9 +27,15 @@ impl LogoutState { fn new(state: &State) -> Self { LogoutState { state: state.clone(), + dark: false, } } + pub fn dark(&mut self, dark: bool) -> &mut Self { + self.dark = dark; + self + } + pub fn button<'a>(&self, btn: &'a hyaenidae_toolkit::Button) -> &'a hyaenidae_toolkit::Button { btn.form(&self.logout_path()) } diff --git a/accounts/src/forms/register.rs b/accounts/src/forms/register.rs index 1413eae..cf9e404 100644 --- a/accounts/src/forms/register.rs +++ b/accounts/src/forms/register.rs @@ -28,6 +28,7 @@ pub struct RegisterState { state: State, form: Option, error: Option, + pub(crate) dark: bool, } pub fn register_page( @@ -69,6 +70,7 @@ impl RegisterState { state: state.clone(), form: None, error: None, + dark: false, } } @@ -77,9 +79,14 @@ impl RegisterState { state: state.clone(), form: Some(form), error: Some(error), + dark: false, } } + pub fn dark(&mut self, dark: bool) { + self.dark = dark; + } + pub(crate) fn register_path(&self) -> String { self.state.pages.register_path() } diff --git a/accounts/src/forms/update_password.rs b/accounts/src/forms/update_password.rs index 9abe8bd..2e8999c 100644 --- a/accounts/src/forms/update_password.rs +++ b/accounts/src/forms/update_password.rs @@ -21,6 +21,7 @@ pub struct UpdatePasswordState { state: State, form: Option, error: Option, + pub(crate) dark: bool, } pub fn update_password_page((_, state): UpdatePasswordPageArgs) -> UpdatePasswordState { @@ -44,6 +45,7 @@ impl UpdatePasswordState { state: state.clone(), form: None, error: None, + dark: false, } } @@ -56,9 +58,14 @@ impl UpdatePasswordState { state: state.clone(), form: Some(form), error: Some(error), + dark: false, } } + pub fn dark(&mut self, dark: bool) { + self.dark = dark; + } + pub(crate) fn update_password_path(&self) -> String { self.state.pages.update_password_path() } diff --git a/accounts/src/forms/update_username.rs b/accounts/src/forms/update_username.rs index a38649e..b2bc079 100644 --- a/accounts/src/forms/update_username.rs +++ b/accounts/src/forms/update_username.rs @@ -20,6 +20,7 @@ pub struct UpdateUsernameState { state: State, form: Option, error: Option, + pub(crate) dark: bool, } pub fn update_username_page((_, state): UpdateUsernamePageArgs) -> UpdateUsernameState { @@ -43,6 +44,7 @@ impl UpdateUsernameState { state: state.clone(), form: None, error: None, + dark: false, } } @@ -55,9 +57,14 @@ impl UpdateUsernameState { state: state.clone(), form: Some(form), error: Some(error), + dark: false, } } + pub fn dark(&mut self, dark: bool) { + self.dark = dark; + } + pub(crate) fn update_username_path(&self) -> String { self.state.pages.update_username_path() } diff --git a/accounts/templates/cookies.rs.html b/accounts/templates/cookies.rs.html index c325e2a..b3ef92c 100644 --- a/accounts/templates/cookies.rs.html +++ b/accounts/templates/cookies.rs.html @@ -11,8 +11,8 @@ @:card_body({
@:button_group(&[ - &Button::primary("Accept Cookies"), - Button::primary_outline("Cancel").href(&state.home_path()), + &Button::primary("Accept Cookies").dark(state.dark), + Button::primary_outline("Cancel").href(&state.home_path()).dark(state.dark), ])
}) diff --git a/accounts/templates/delete_user.rs.html b/accounts/templates/delete_user.rs.html index a23d357..d55ab52 100644 --- a/accounts/templates/delete_user.rs.html +++ b/accounts/templates/delete_user.rs.html @@ -8,12 +8,12 @@
@:card_title({ Delete Account }) @:card_body({ - @:password_input("password", "Password", state.password(), state.password_error()) + @:password_input("password", "Password", state.password(), state.password_error(), state.dark) }) @:card_body({ @:button_group(&[ - &Button::primary("Delete Account"), - Button::primary_outline("Cancel").href(&state.accounts_path()) + &Button::primary("Delete Account").dark(state.dark), + Button::primary_outline("Cancel").href(&state.accounts_path()).dark(state.dark), ]) })
diff --git a/accounts/templates/inputs/password_input.rs.html b/accounts/templates/inputs/password_input.rs.html index 842ebd0..b4416f5 100644 --- a/accounts/templates/inputs/password_input.rs.html +++ b/accounts/templates/inputs/password_input.rs.html @@ -1,5 +1,5 @@ @use hyaenidae_toolkit::{templates::text_input, TextInput}; -@(name: &str, title: &str, value: Option, error: Option) +@(name: &str, title: &str, value: Option, error: Option, dark: bool) -@:text_input(TextInput::new(name).title(title).value_opt(value).error_opt(error).password()) +@:text_input(TextInput::new(name).title(title).value_opt(value).error_opt(error).password().dark(dark)) diff --git a/accounts/templates/inputs/text_input.rs.html b/accounts/templates/inputs/text_input.rs.html index 10b7a45..e725a1e 100644 --- a/accounts/templates/inputs/text_input.rs.html +++ b/accounts/templates/inputs/text_input.rs.html @@ -1,5 +1,5 @@ @use hyaenidae_toolkit::{templates::text_input, TextInput}; -@(name: &str, title: &str, value: Option, error: Option) +@(name: &str, title: &str, value: Option, error: Option, dark:bool) -@:text_input(TextInput::new(name).title(title).value_opt(value).error_opt(error)) +@:text_input(TextInput::new(name).title(title).value_opt(value).error_opt(error).dark(dark)) diff --git a/accounts/templates/login.rs.html b/accounts/templates/login.rs.html index fde3f90..5cebcc8 100644 --- a/accounts/templates/login.rs.html +++ b/accounts/templates/login.rs.html @@ -8,14 +8,14 @@
@:card_title({ Login }) @:card_body({ - @:text_input("username", "Username", state.username(), state.username_error()) - @:password_input("password", "Password", state.password(), None) - @:link(&Link::current_tab(&state.register_path()), { I do not have an account }) + @:text_input("username", "Username", state.username(), state.username_error(), state.dark) + @:password_input("password", "Password", state.password(), None, state.dark) + @:link(&Link::current_tab(&state.register_path()).dark(state.dark), { I do not have an account }) }) @:card_body({ @:button_group(&[ - &Button::primary("Login"), - Button::primary_outline("Cancel").href(&state.home_path()), + &Button::primary("Login").dark(state.dark), + Button::primary_outline("Cancel").href(&state.home_path()).dark(state.dark), ]) })
diff --git a/accounts/templates/register.rs.html b/accounts/templates/register.rs.html index 1f7e36d..35c35b9 100644 --- a/accounts/templates/register.rs.html +++ b/accounts/templates/register.rs.html @@ -8,15 +8,15 @@
@:card_title({ Register }) @:card_body({ - @:text_input("username", "Username", state.username(), state.username_error()) - @:password_input("password", "Password", state.password(), None) - @:password_input("password_confirmation", "Password Confirmation", state.confirmation(), state.confirmation_error()) - @:link(&Link::current_tab(&state.login_path()), { I already have an account }) + @:text_input("username", "Username", state.username(), state.username_error(), state.dark) + @:password_input("password", "Password", state.password(), None, state.dark) + @:password_input("password_confirmation", "Password Confirmation", state.confirmation(), state.confirmation_error(), state.dark) + @:link(&Link::current_tab(&state.login_path()).dark(state.dark), { I already have an account }) }) @:card_body({ @:button_group(&[ - &Button::primary("Register"), - Button::primary_outline("Cancel").href(&state.home_path()), + &Button::primary("Register").dark(state.dark), + Button::primary_outline("Cancel").href(&state.home_path()).dark(state.dark), ]) })
diff --git a/accounts/templates/update_password.rs.html b/accounts/templates/update_password.rs.html index 19a59e3..5c416b6 100644 --- a/accounts/templates/update_password.rs.html +++ b/accounts/templates/update_password.rs.html @@ -8,12 +8,12 @@
@:card_title({ Update Password }) @:card_body({ - @:password_input("new_password", "New Password", state.new_password(), None) - @:password_input("new_password_confirmation", "New Password Confirmation", state.new_password_confirmation(), state.new_password_confirmation_error()) - @:password_input("password", "Password", state.password(), state.password_error()) + @:password_input("new_password", "New Password", state.new_password(), None, state.dark) + @:password_input("new_password_confirmation", "New Password Confirmation", state.new_password_confirmation(), state.new_password_confirmation_error(), state.dark) + @:password_input("password", "Password", state.password(), state.password_error(), state.dark) }) @:card_body({ - @:button_group(&[&Button::primary("Update Password")]) + @:button_group(&[&Button::primary("Update Password").dark(state.dark)]) })
}) diff --git a/accounts/templates/update_username.rs.html b/accounts/templates/update_username.rs.html index 0739c8a..db7960e 100644 --- a/accounts/templates/update_username.rs.html +++ b/accounts/templates/update_username.rs.html @@ -8,11 +8,11 @@
@:card_title({ Update Username }) @:card_body({ - @:text_input("new_username", "New Username", state.username(), state.username_error()) - @:password_input("password", "Password", state.password(), state.password_error()) + @:text_input("new_username", "New Username", state.username(), state.username_error(), state.dark) + @:password_input("password", "Password", state.password(), state.password_error(), state.dark) }) @:card_body({ - @:button_group(&[&Button::primary("Update Username")]) + @:button_group(&[&Button::primary("Update Username").dark(state.dark)]) })
})