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.lock b/Cargo.lock index 32e7c4c..cebd2d9 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1742,6 +1742,7 @@ version = "0.19.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cc07f2657dcc366ef2d80045354143f6e0a86919763a1a5753cd3871f8f95e2d" dependencies = [ + "actix-web", "cfg-if", "chrono", "codee", @@ -1749,9 +1750,11 @@ dependencies = [ "default-struct-builder", "futures-util", "gloo-timers", + "http 0.2.12", "js-sys", "lazy_static", "leptos", + "leptos_actix", "paste", "send_wrapper", "thiserror 2.0.19", diff --git a/Cargo.toml b/Cargo.toml index 83c9de7..46443e3 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -40,7 +40,8 @@ ssr = [ "leptos/ssr", "leptos_meta/ssr", "leptos_router/ssr", - "leptos-use/ssr" + "leptos-use/ssr", + "leptos-use/actix" ] development = [] diff --git a/README.md b/README.md index 80c917d..1a7ebcf 100644 --- a/README.md +++ b/README.md @@ -12,6 +12,8 @@ ## Como ejecutar +La configuración está pensada para funcionar en entornos Linux y Mac, si tienes alguna configuración extra en tu `.cargo/config.toml` puede que el proceso de buildeo falle. + ### Requisitos Generales Antes de empezar es necesario tener estos programas @@ -49,13 +51,6 @@ Si usas NixOS direnv allow ``` -### Requisitos Windows >= 10 - -[BusyBox](https://busybox.net/) - -- Usando scoop `scoop install busybox` -- Usando choco `choco install busybox` - ### Desarrollo > [!NOTE] @@ -121,6 +116,36 @@ Agrega esto en tu `settings.json` } ``` +## Configura tu Zed + +Agrega esto en tu `settings.json` + +```json +{ + "lsp": { + "rust-analyzer": { + "binary": { + "path": "rust-analyzer" + }, + "initialization_options": { + "cargo": { + "features": [ + "ssr" + ] + }, + "check": { + "command": "check", + "extraArgs": [ + "--features", + "ssr" + ] + } + } + } + } +} +``` + ## Resumen Este proyecto utiliza una rama personalizada de Leptos para poder servir 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..0eccbc2 100644 --- a/src/components/header.rs +++ b/src/components/header.rs @@ -1,18 +1,22 @@ use crate::{ - components::icons::{NewLogoRustDarkPageIcon, NewLogoRustLightPageIcon}, + components::{ + BOOK_PATH, JOIN_PATH, + 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}, + icons::{Close, Menu, Moon, SunLine, SunMoon}, }; #[island] pub fn Header() -> impl IntoView { let this = use_window(); let path = RwSignal::new("/".to_string()); + let menu_open = RwSignal::new(false); Effect::new(move |_| { let result = format!( @@ -35,6 +39,18 @@ pub fn Header() -> impl IntoView { Theme::System => view! { }.into_any(), }; + let menu_handler = move |_| { + menu_open.update(|open| *open = !*open); + }; + + let menu_icon = move || { + if menu_open() { + view! { }.into_any() + } else { + view! { }.into_any() + } + }; + let theme_switcher_icon = move || match theme() { Theme::Dark => view! { }.into_any(), Theme::Light => view! { }.into_any(), @@ -43,25 +59,35 @@ 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 { "" } }; - let handler = move |_| { + let theme_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()} + +
+
+ + diff --git a/src/components/mod.rs b/src/components/mod.rs index c2432bd..ed278de 100644 --- a/src/components/mod.rs +++ b/src/components/mod.rs @@ -22,3 +22,9 @@ pub mod project_card; pub mod resources; pub mod sponsor_block; pub mod why_rust; + +const BOOK_PATH: &str = "https://book.rustlang-es.org/"; +const JOIN_PATH: &str = "https://discord.rustlang-es.org/"; +const GITHUB_PATH: &str = "https://github.com/RustLangES"; +const LINKEDIN_PATH: &str = "https://www.linkedin.com/company/rustlanges"; +const TELEGRAM_PATH: &str = "https://t.me/rust_es"; diff --git a/src/context/theme_provider.rs b/src/context/theme_provider.rs index 6a1c0fa..ab68919 100644 --- a/src/context/theme_provider.rs +++ b/src/context/theme_provider.rs @@ -1,13 +1,14 @@ +use std::fmt::Display; + use leptos::{ children::Children, prelude::{RwSignal, use_context, *}, server::codee::string::JsonSerdeCodec, *, }; -use leptos_use::{storage::use_local_storage, use_media_query}; +use leptos_use::{use_cookie, use_media_query}; use serde::{Deserialize, Serialize}; -/// Defines an enumeration for UI themes. -/// + /// This enum can be cloned, copied, and compared for equality. /// It also supports serialization and deserialization for local storage. #[derive(Clone, Copy, PartialEq, Serialize, Deserialize, Debug)] @@ -17,28 +18,28 @@ pub enum Theme { System, } -// Implementation of the default value for the `Theme` enum impl Default for Theme { - /// provides the default theme as `Dark` fn default() -> Self { Theme::Dark } } -#[allow(clippy::inherent_to_string)] -impl Theme { - /// Converts the `Theme` variant into a corresponding string. - pub fn to_string(self) -> String { - String::from(match self { - Theme::Light => "light", - Theme::Dark => "dark", - Theme::System => "system", - }) +impl Display for Theme { + 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 +103,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;