Skip to content

Commit 87c7ed0

Browse files
committed
feat: Update component structure and improve formatting for readability
1 parent e9b836b commit 87c7ed0

File tree

9 files changed

+111
-47
lines changed

9 files changed

+111
-47
lines changed

Cargo.lock

Lines changed: 6 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/components/community_project.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,12 @@ pub fn CommunityProjectSection() -> impl IntoView {
6161
/>
6262
</div>
6363

64-
<Button variant=Variant::Secondary label="Ver proyectos" icon=view!{<Github />}.into_any() on_click=move |_| {}>
65-
</Button>
64+
<Button
65+
variant=Variant::Secondary
66+
label="Ver proyectos"
67+
icon=view! { <Github /> }.into_any()
68+
on_click=move |_| {}
69+
></Button>
6670
</div>
6771
</section>
6872
}

src/components/header.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,11 @@ pub fn Header() -> impl IntoView {
7979
</div>
8080
<div class="flex gap-[16px] items-center">
8181
<Button variant=Variant::Secondary label="El Libro" on_click=|_| {} />
82-
<Button variant=Variant::Primary label="¡Únete!" on_click=move |_| console_log("hola") />
82+
<Button
83+
variant=Variant::Primary
84+
label="¡Únete!"
85+
on_click=move |_| console_log("hola")
86+
/>
8387
<Button variant=Variant::Icon on_click=handler icon=theme_switcher_icon() />
8488
</div>
8589
</div>

src/components/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,6 @@ pub use icons::{
1111

1212
pub mod community_project;
1313
pub mod our_community;
14-
pub mod project_card;
1514
pub mod our_sponsors;
16-
pub mod sponsor_block;
15+
pub mod project_card;
16+
pub mod sponsor_block;

src/components/our_sponsors.rs

Lines changed: 33 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,17 @@
1-
use leptos::*;
2-
use leptos::prelude::*;
1+
use leptos::{prelude::*, *};
32

43
use crate::components::sponsor_block::SponsorBlock;
54

6-
7-
85
#[component]
96
pub fn OurSponsorsSection() -> impl IntoView {
10-
11-
view!{
7+
view! {
128
<section class="flex flex-col justify-center items-center w-full gap-8 py-20 dark:bg-neutral-900">
139
<div class="container flex flex-col justify-center items-center gap-8">
1410
<h2 class="text-h2 mb-4">"Nuestros sponsors"</h2>
1511
<p class="text-center mb-8 max-w-lg">
16-
Todos nuestros eventos y actividades son <span class="font-bold">gratuitas</span> gracias a las organizaciones que apoyan nuestro trabajo.
12+
Todos nuestros eventos y actividades son
13+
<span class="font-bold">gratuitas</span>
14+
gracias a las organizaciones que apoyan nuestro trabajo.
1715
</p>
1816

1917
<div>
@@ -23,32 +21,52 @@ pub fn OurSponsorsSection() -> impl IntoView {
2321
<div class="flex justify-center items-center relative z-[2] -mt-11">
2422
<SponsorBlock class="text-primary-500" />
2523
<SponsorBlock class="text-black">
26-
<img src="/assets/sponsors/sysarmy.webp" alt="SysArmy" class="max-h-[50px]" />
24+
<img
25+
src="/assets/sponsors/sysarmy.webp"
26+
alt="SysArmy"
27+
class="max-h-[50px]"
28+
/>
2729
</SponsorBlock>
2830
<SponsorBlock class="text-secondary-500" />
2931
<SponsorBlock class="text-white">
30-
<img src="/assets/new/sponsors/testing-bolivia.png" alt="Testing Bolivia" class="max-h-[50px] mix-blend-difference" />
32+
<img
33+
src="/assets/new/sponsors/testing-bolivia.png"
34+
alt="Testing Bolivia"
35+
class="max-h-[50px] mix-blend-difference"
36+
/>
3137
</SponsorBlock>
3238
<SponsorBlock class="text-primary-500" />
3339
</div>
3440
<div class="flex justify-center items-center relative z-[1] -mt-11">
3541
<SponsorBlock class="text-[#00c39d]">
36-
<img src="/assets/new/sponsors/frontendcafe.png" alt="FrontendCafe" class="max-h-[50px] shadow-frontendcafe" />
42+
<img
43+
src="/assets/new/sponsors/frontendcafe.png"
44+
alt="FrontendCafe"
45+
class="max-h-[50px] shadow-frontendcafe"
46+
/>
3747
</SponsorBlock>
3848
<SponsorBlock class="text-primary-200" />
3949
<SponsorBlock class="text-[#193270]">
40-
<img src="/assets/new/sponsors/universidad_nur.png" alt="Universidad Nur" class="max-h-[50px]" />
50+
<img
51+
src="/assets/new/sponsors/universidad_nur.png"
52+
alt="Universidad Nur"
53+
class="max-h-[50px]"
54+
/>
4155
</SponsorBlock>
4256
<SponsorBlock class="text-primary-200" />
4357
<SponsorBlock class="text-black">
44-
<img src="/assets/sponsors/shuttle.webp" alt="ShuttleRS" class="max-h-[50px] mix-blend-difference" />
58+
<img
59+
src="/assets/sponsors/shuttle.webp"
60+
alt="ShuttleRS"
61+
class="max-h-[50px] mix-blend-difference"
62+
/>
4563
</SponsorBlock>
4664
<SponsorBlock class="text-primary-200" />
4765
</div>
4866

49-
// <SponsorBlock class="text-[#00c39d]">
50-
// <img src="/assets/sponsors/crabnebula.png" alt="Crabnebula" class="max-h-[50px]" />
51-
// </SponsorBlock>
67+
// <SponsorBlock class="text-[#00c39d]">
68+
// <img src="/assets/sponsors/crabnebula.png" alt="Crabnebula" class="max-h-[50px]" />
69+
// </SponsorBlock>
5270
</div>
5371
</section>
5472
}

src/components/project_card.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ pub fn ProjectCard(
3838
</div>
3939

4040
<div class="rounded-full border border-white p-1">
41-
// <Button>
41+
// <Button>
4242
<Github size=40 as u32 />
4343
</div>
4444
</div>

src/components/sponsor_block.rs

Lines changed: 28 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,38 @@
1-
use leptos::*;
2-
use leptos::prelude::*;
3-
4-
1+
use leptos::{prelude::*, *};
52

63
#[component]
74
pub fn SponsorBlock(
8-
#[prop(into, default="fill-primary-500")] class: &'static str,
9-
#[prop(optional)] children: Option<Children>
5+
#[prop(into, default = "fill-primary-500")] class: &'static str,
6+
#[prop(optional)] children: Option<Children>,
107
) -> impl IntoView {
11-
12-
view!{
8+
view! {
139
<div class="relative flex justify-center items-center">
14-
<div class="absolute mt-3">
15-
{children.map(|v| v())}
16-
</div>
17-
<svg xmlns="http://www.w3.org/2000/svg" width="143" height="74" viewBox="0 0 143 74" class={class}>
10+
<div class="absolute mt-3">{children.map(|v| v())}</div>
11+
<svg
12+
xmlns="http://www.w3.org/2000/svg"
13+
width="143"
14+
height="74"
15+
viewBox="0 0 143 74"
16+
class=class
17+
>
1818
<mask id="path-1-inside-1_715_7648" fill="black">
19-
<path fill-rule="evenodd" clip-rule="evenodd" d="M12.8464 2C12.8464 0.895431 13.7418 0 14.8464 0H33.9233C35.0279 0 35.9233 0.895431 35.9233 2V9.2303H43.6161V2C43.6161 0.895431 44.5116 0 45.6161 0H64.6931C65.7976 0 66.6931 0.895431 66.6931 2V9.2303H74.3853V2C74.3853 0.895431 75.2807 0 76.3853 0H95.4622C96.5668 0 97.4622 0.895431 97.4622 2V9.2303H105.155V2C105.155 0.895431 106.05 0 107.155 0H126.232C127.336 0 128.232 0.895431 128.232 2V9.2303H138.077C140.286 9.2303 142.077 11.0212 142.077 13.2303V73.8457H0.538879V13.2303C0.538879 11.0212 2.32974 9.2303 4.53888 9.2303H12.8464V2Z"/>
19+
<path
20+
fill-rule="evenodd"
21+
clip-rule="evenodd"
22+
d="M12.8464 2C12.8464 0.895431 13.7418 0 14.8464 0H33.9233C35.0279 0 35.9233 0.895431 35.9233 2V9.2303H43.6161V2C43.6161 0.895431 44.5116 0 45.6161 0H64.6931C65.7976 0 66.6931 0.895431 66.6931 2V9.2303H74.3853V2C74.3853 0.895431 75.2807 0 76.3853 0H95.4622C96.5668 0 97.4622 0.895431 97.4622 2V9.2303H105.155V2C105.155 0.895431 106.05 0 107.155 0H126.232C127.336 0 128.232 0.895431 128.232 2V9.2303H138.077C140.286 9.2303 142.077 11.0212 142.077 13.2303V73.8457H0.538879V13.2303C0.538879 11.0212 2.32974 9.2303 4.53888 9.2303H12.8464V2Z"
23+
/>
2024
</mask>
21-
<path fill-rule="evenodd" clip-rule="evenodd" d="M12.8464 2C12.8464 0.895431 13.7418 0 14.8464 0H33.9233C35.0279 0 35.9233 0.895431 35.9233 2V9.2303H43.6161V2C43.6161 0.895431 44.5116 0 45.6161 0H64.6931C65.7976 0 66.6931 0.895431 66.6931 2V9.2303H74.3853V2C74.3853 0.895431 75.2807 0 76.3853 0H95.4622C96.5668 0 97.4622 0.895431 97.4622 2V9.2303H105.155V2C105.155 0.895431 106.05 0 107.155 0H126.232C127.336 0 128.232 0.895431 128.232 2V9.2303H138.077C140.286 9.2303 142.077 11.0212 142.077 13.2303V73.8457H0.538879V13.2303C0.538879 11.0212 2.32974 9.2303 4.53888 9.2303H12.8464V2Z" fill="currentColor"/>
22-
<path d="M35.9233 9.2303H34.9233V10.2303H35.9233V9.2303ZM43.6161 9.2303V10.2303H44.6161V9.2303H43.6161ZM66.6931 9.2303H65.6931V10.2303H66.6931V9.2303ZM74.3853 9.2303V10.2303H75.3853V9.2303H74.3853ZM97.4622 9.2303H96.4622V10.2303H97.4622V9.2303ZM105.155 9.2303V10.2303H106.155V9.2303H105.155ZM128.232 9.2303H127.232V10.2303H128.232V9.2303ZM142.077 73.8457V74.8457H143.077V73.8457H142.077ZM0.538879 73.8457H-0.461121V74.8457H0.538879V73.8457ZM12.8464 9.2303V10.2303H13.8464V9.2303H12.8464ZM14.8464 -1C13.1895 -1 11.8464 0.343147 11.8464 2H13.8464C13.8464 1.44772 14.2941 1 14.8464 1V-1ZM33.9233 -1H14.8464V1H33.9233V-1ZM36.9233 2C36.9233 0.343144 35.5802 -1 33.9233 -1V1C34.4756 1 34.9233 1.44772 34.9233 2H36.9233ZM36.9233 9.2303V2H34.9233V9.2303H36.9233ZM43.6161 8.2303H35.9233V10.2303H43.6161V8.2303ZM42.6161 2V9.2303H44.6161V2H42.6161ZM45.6161 -1C43.9593 -1 42.6161 0.343147 42.6161 2H44.6161C44.6161 1.44772 45.0639 1 45.6161 1V-1ZM64.6931 -1H45.6161V1H64.6931V-1ZM67.6931 2C67.6931 0.343145 66.3499 -1 64.6931 -1V1C65.2453 1 65.6931 1.44772 65.6931 2H67.6931ZM67.6931 9.2303V2H65.6931V9.2303H67.6931ZM74.3853 8.2303H66.6931V10.2303H74.3853V8.2303ZM73.3853 2V9.2303H75.3853V2H73.3853ZM76.3853 -1C74.7285 -1 73.3853 0.343147 73.3853 2H75.3853C75.3853 1.44772 75.833 1 76.3853 1V-1ZM95.4622 -1H76.3853V1H95.4622V-1ZM98.4622 2C98.4622 0.343141 97.1191 -1 95.4622 -1V1C96.0145 1 96.4622 1.44772 96.4622 2H98.4622ZM98.4622 9.2303V2H96.4622V9.2303H98.4622ZM105.155 8.2303H97.4622V10.2303H105.155V8.2303ZM106.155 9.2303V2H104.155V9.2303H106.155ZM106.155 2C106.155 1.44772 106.603 1 107.155 1V-1C105.498 -1 104.155 0.343147 104.155 2H106.155ZM107.155 1H126.232V-1H107.155V1ZM126.232 1C126.784 1 127.232 1.44772 127.232 2H129.232C129.232 0.343141 127.889 -1 126.232 -1V1ZM127.232 2V9.2303H129.232V2H127.232ZM138.077 8.2303H128.232V10.2303H138.077V8.2303ZM143.077 13.2303C143.077 10.4689 140.839 8.2303 138.077 8.2303V10.2303C139.734 10.2303 141.077 11.5734 141.077 13.2303H143.077ZM143.077 73.8457V13.2303H141.077V73.8457H143.077ZM0.538879 74.8457H142.077V72.8457H0.538879V74.8457ZM-0.461121 13.2303V73.8457H1.53888V13.2303H-0.461121ZM4.53888 8.2303C1.77746 8.2303 -0.461121 10.4689 -0.461121 13.2303H1.53888C1.53888 11.5734 2.88203 10.2303 4.53888 10.2303V8.2303ZM12.8464 8.2303H4.53888V10.2303H12.8464V8.2303ZM11.8464 2V9.2303H13.8464V2H11.8464Z" fill="black" mask="url(#path-1-inside-1_715_7648)"/>
25+
<path
26+
fill-rule="evenodd"
27+
clip-rule="evenodd"
28+
d="M12.8464 2C12.8464 0.895431 13.7418 0 14.8464 0H33.9233C35.0279 0 35.9233 0.895431 35.9233 2V9.2303H43.6161V2C43.6161 0.895431 44.5116 0 45.6161 0H64.6931C65.7976 0 66.6931 0.895431 66.6931 2V9.2303H74.3853V2C74.3853 0.895431 75.2807 0 76.3853 0H95.4622C96.5668 0 97.4622 0.895431 97.4622 2V9.2303H105.155V2C105.155 0.895431 106.05 0 107.155 0H126.232C127.336 0 128.232 0.895431 128.232 2V9.2303H138.077C140.286 9.2303 142.077 11.0212 142.077 13.2303V73.8457H0.538879V13.2303C0.538879 11.0212 2.32974 9.2303 4.53888 9.2303H12.8464V2Z"
29+
fill="currentColor"
30+
/>
31+
<path
32+
d="M35.9233 9.2303H34.9233V10.2303H35.9233V9.2303ZM43.6161 9.2303V10.2303H44.6161V9.2303H43.6161ZM66.6931 9.2303H65.6931V10.2303H66.6931V9.2303ZM74.3853 9.2303V10.2303H75.3853V9.2303H74.3853ZM97.4622 9.2303H96.4622V10.2303H97.4622V9.2303ZM105.155 9.2303V10.2303H106.155V9.2303H105.155ZM128.232 9.2303H127.232V10.2303H128.232V9.2303ZM142.077 73.8457V74.8457H143.077V73.8457H142.077ZM0.538879 73.8457H-0.461121V74.8457H0.538879V73.8457ZM12.8464 9.2303V10.2303H13.8464V9.2303H12.8464ZM14.8464 -1C13.1895 -1 11.8464 0.343147 11.8464 2H13.8464C13.8464 1.44772 14.2941 1 14.8464 1V-1ZM33.9233 -1H14.8464V1H33.9233V-1ZM36.9233 2C36.9233 0.343144 35.5802 -1 33.9233 -1V1C34.4756 1 34.9233 1.44772 34.9233 2H36.9233ZM36.9233 9.2303V2H34.9233V9.2303H36.9233ZM43.6161 8.2303H35.9233V10.2303H43.6161V8.2303ZM42.6161 2V9.2303H44.6161V2H42.6161ZM45.6161 -1C43.9593 -1 42.6161 0.343147 42.6161 2H44.6161C44.6161 1.44772 45.0639 1 45.6161 1V-1ZM64.6931 -1H45.6161V1H64.6931V-1ZM67.6931 2C67.6931 0.343145 66.3499 -1 64.6931 -1V1C65.2453 1 65.6931 1.44772 65.6931 2H67.6931ZM67.6931 9.2303V2H65.6931V9.2303H67.6931ZM74.3853 8.2303H66.6931V10.2303H74.3853V8.2303ZM73.3853 2V9.2303H75.3853V2H73.3853ZM76.3853 -1C74.7285 -1 73.3853 0.343147 73.3853 2H75.3853C75.3853 1.44772 75.833 1 76.3853 1V-1ZM95.4622 -1H76.3853V1H95.4622V-1ZM98.4622 2C98.4622 0.343141 97.1191 -1 95.4622 -1V1C96.0145 1 96.4622 1.44772 96.4622 2H98.4622ZM98.4622 9.2303V2H96.4622V9.2303H98.4622ZM105.155 8.2303H97.4622V10.2303H105.155V8.2303ZM106.155 9.2303V2H104.155V9.2303H106.155ZM106.155 2C106.155 1.44772 106.603 1 107.155 1V-1C105.498 -1 104.155 0.343147 104.155 2H106.155ZM107.155 1H126.232V-1H107.155V1ZM126.232 1C126.784 1 127.232 1.44772 127.232 2H129.232C129.232 0.343141 127.889 -1 126.232 -1V1ZM127.232 2V9.2303H129.232V2H127.232ZM138.077 8.2303H128.232V10.2303H138.077V8.2303ZM143.077 13.2303C143.077 10.4689 140.839 8.2303 138.077 8.2303V10.2303C139.734 10.2303 141.077 11.5734 141.077 13.2303H143.077ZM143.077 73.8457V13.2303H141.077V73.8457H143.077ZM0.538879 74.8457H142.077V72.8457H0.538879V74.8457ZM-0.461121 13.2303V73.8457H1.53888V13.2303H-0.461121ZM4.53888 8.2303C1.77746 8.2303 -0.461121 10.4689 -0.461121 13.2303H1.53888C1.53888 11.5734 2.88203 10.2303 4.53888 10.2303V8.2303ZM12.8464 8.2303H4.53888V10.2303H12.8464V8.2303ZM11.8464 2V9.2303H13.8464V2H11.8464Z"
33+
fill="black"
34+
mask="url(#path-1-inside-1_715_7648)"
35+
/>
2336
</svg>
2437
</div>
2538
}

src/context/theme_provider.rs

Lines changed: 28 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,10 @@ use leptos::{
66
server::codee::string::JsonSerdeCodec,
77
*,
88
};
9-
use leptos_use::{storage::use_local_storage, use_media_query, use_preferred_dark, watch_with_options, WatchOptions};
9+
use leptos_use::{
10+
storage::use_local_storage, use_media_query, use_preferred_dark, watch_with_options,
11+
WatchOptions,
12+
};
1013
use serde::{Deserialize, Serialize};
1114
/// Defines an enumeration for UI themes.
1215
///
@@ -48,21 +51,34 @@ const STORAGE_KEY: &'static str = "theme";
4851
/// * `theme` - The current theme (Light, Dark, System)
4952
/// * `prefers_dark` - Boolean flag indicating whether the system prefers a dark theme.
5053
fn update_css_for_theme(theme: Theme, prefers_dark: bool, use_data_attribute: bool) {
51-
let document = web_sys::window().expect("should get window").document().expect("document should be available");
52-
let html_element = document.document_element().expect("document should have a root element");
54+
let document = web_sys::window()
55+
.expect("should get window")
56+
.document()
57+
.expect("document should be available");
58+
let html_element = document
59+
.document_element()
60+
.expect("document should have a root element");
5361

5462
// TODO: Change the theme following the system preference when Theme::System is selected
5563
if use_data_attribute {
5664
match theme {
5765
Theme::Light => {
58-
html_element.set_attribute("data-theme", "light").expect("should set data-theme to light");
66+
html_element
67+
.set_attribute("data-theme", "light")
68+
.expect("should set data-theme to light");
5969
}
6070
Theme::Dark => {
61-
html_element.set_attribute("data-theme", "dark").expect("should set data-theme to dark");
71+
html_element
72+
.set_attribute("data-theme", "dark")
73+
.expect("should set data-theme to dark");
6274
}
6375
Theme::System => match prefers_dark {
64-
true => html_element.set_attribute("data-theme", "dark").expect("should set data-theme to dark"),
65-
false => html_element.set_attribute("data-theme", "light").expect("should set data-theme to light"),
76+
true => html_element
77+
.set_attribute("data-theme", "dark")
78+
.expect("should set data-theme to dark"),
79+
false => html_element
80+
.set_attribute("data-theme", "light")
81+
.expect("should set data-theme to light"),
6682
},
6783
}
6884
}
@@ -111,15 +127,17 @@ pub fn ThemeProvider(children: Children) -> impl IntoView {
111127
});
112128

113129
Effect::watch(
114-
move || is_dark_preferred_signal(),
115-
move | is_dark_preferred_signal, _, _| {
130+
move || is_dark_preferred_signal(),
131+
move |is_dark_preferred_signal, _, _| {
116132
console_log(&format!("Theme changed to: {:?}", is_dark_preferred_signal));
117133
// update_css_for_theme(
118134
// theme_state(),
119135
// is_dark_preferred_signal(),
120136
// use_data_attribute,
121137
// );
122-
}, true);
138+
},
139+
true,
140+
);
123141

124142
view! { {children()} }
125143
}

src/pages/index.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@ use rustlanges_components::{
66
};
77

88
use crate::components::{
9-
community_project::CommunityProjectSection, our_community::OurCommunitySection, our_sponsors::OurSponsorsSection,
9+
community_project::CommunityProjectSection, our_community::OurCommunitySection,
10+
our_sponsors::OurSponsorsSection,
1011
};
1112

1213
#[component]

0 commit comments

Comments
 (0)