diff --git a/.gitignore b/.gitignore index d5cdfa9..5ac1419 100644 --- a/.gitignore +++ b/.gitignore @@ -8,6 +8,8 @@ bundled.css /assets/gen_assets/ /src/extras/ +Cargo.lock + # NixOs output folder /result diff --git a/Cargo.toml b/Cargo.toml index ce4ba52..e3e0992 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -4,7 +4,7 @@ version = "0.1.0" edition = "2024" [workspace] -exclude = ["design-system-components"] +exclude = ["design-system-components/"] [lib] crate-type = ["cdylib", "rlib"] @@ -38,7 +38,8 @@ ssr = [ "leptos/ssr", "leptos_meta/ssr", "leptos_router/ssr", - "leptos-use/ssr" + "leptos-use/ssr", + "leptos-use/actix" ] development = [] diff --git a/src/app.rs b/src/app.rs index 8a80195..6fc29a1 100644 --- a/src/app.rs +++ b/src/app.rs @@ -8,7 +8,7 @@ use leptos_router::{ use crate::{ components::{HeadInformation, Header}, - pages::{Aprende, Communities, Index}, + pages::{Aprende, Blog, Communities, Events, Index}, }; pub fn shell(options: LeptosOptions) -> impl IntoView { @@ -60,16 +60,10 @@ pub fn App() -> impl IntoView { - - // - // + + + // diff --git a/src/components/header.rs b/src/components/header.rs index 63f806f..7ac59c8 100644 --- a/src/components/header.rs +++ b/src/components/header.rs @@ -2,13 +2,19 @@ use crate::{ components::icons::{NewLogoRustDarkPageIcon, NewLogoRustLightPageIcon}, context::theme_provider::{Theme, use_theme}, }; -use leptos::{leptos_dom::logging::console_log, prelude::*}; +use leptos::prelude::*; use leptos_use::{use_media_query, use_window}; use rustlanges_components::{ button::{Button, Variant}, icons::{Moon, SunLine, SunMoon}, }; +/// Path that redirects to the book in spanish from RustLangEs +const BOOK_PATH: &str = "https://book.rustlang-es.org/"; + +/// Path that redirects to the discord community server +const JOIN_PATH: &str = "https://discord.rustlang-es.org/"; + #[island] pub fn Header() -> impl IntoView { let this = use_window(); @@ -43,7 +49,7 @@ pub fn Header() -> impl IntoView { let active_link_class = move |link: &str| { if path() == format!("{link:?}") { - "text-red-500 dark:text-orange-300" + "font-bold text-red-500 dark:text-orange-300" } else { "" } @@ -52,42 +58,53 @@ pub fn Header() -> impl IntoView { let handler = move |_| { let current_theme = theme.get(); match current_theme { - Theme::System => theme.set(Theme::Dark), - Theme::Dark => theme.set(Theme::Light), - Theme::Light => theme.set(Theme::System), + Theme::Light => theme.set(Theme::Dark), + Theme::Dark | Theme::System => theme.set(Theme::Light), } }; view! { - {move || logo()} + + {move || logo()} + + - + Inicio - + Aprende Rust - + Comunidad - + Eventos - Blog + + Blog + - - + target="_blank" + rel="noopener noreferrer" + > + + + + + + + String { - String::from(match self { - Theme::Light => "light", - Theme::Dark => "dark", - Theme::System => "system", - }) + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + write!( + f, + "{}", + match self { + Theme::Light => "light", + Theme::Dark => "dark", + Theme::System => "system", + } + ) } } -/// Define a constant for the local storage key used to store the theme setting. -const STORAGE_KEY: &str = "theme"; +/// Define a constant for the cookie key used to store the theme setting. +const COOKIE_KEY: &str = "theme"; /// Updates the class selector for the respective theme. /// This function is responsible for applying the correct CSS class to the HTML and body elements based on the current theme. @@ -102,16 +108,16 @@ pub fn ThemeProvider(children: Children) -> impl IntoView { let is_dark_preferred_signal = use_media_query("(prefers-color-scheme: dark)"); // Attempt to retrieve the theme from local storage - let (theme_storage_state, set_theme_storage_state, _) = - use_local_storage::(STORAGE_KEY); + let (theme_storage_state, set_theme_storage_state) = + use_cookie::(COOKIE_KEY); - let theme_state = RwSignal::new(theme_storage_state.get_untracked()); + let theme_state = RwSignal::new(theme_storage_state.get_untracked().unwrap_or_default()); provide_context(theme_state); // Update local storage and CSS whenever the theme state changes Effect::new(move |_| { - let current_theme = theme_state(); - set_theme_storage_state.set(current_theme); + let current_theme: Theme = theme_state(); + set_theme_storage_state.set(Some(current_theme)); update_css_for_theme( current_theme, is_dark_preferred_signal(), diff --git a/src/pages/blog.rs b/src/pages/blog.rs new file mode 100644 index 0000000..ca0436e --- /dev/null +++ b/src/pages/blog.rs @@ -0,0 +1,4 @@ +use leptos::{IntoView, component}; + +#[component] +pub fn Blog() -> impl IntoView {} diff --git a/src/pages/events.rs b/src/pages/events.rs new file mode 100644 index 0000000..b92f451 --- /dev/null +++ b/src/pages/events.rs @@ -0,0 +1,4 @@ +use leptos::{IntoView, component}; + +#[component] +pub fn Events() -> impl IntoView {} diff --git a/src/pages/mod.rs b/src/pages/mod.rs index 0e86d06..be6f22e 100644 --- a/src/pages/mod.rs +++ b/src/pages/mod.rs @@ -1,11 +1,15 @@ mod aprende; +mod blog; mod communities; mod contributors; +mod events; mod index; mod projects; pub use aprende::Aprende; +pub use blog::Blog; pub use communities::Communities; pub use contributors::Contributors; +pub use events::Events; pub use index::Index; pub use projects::Projects;