Skip to content

Commit d4ade3a

Browse files
committed
refactor: improve formatting and structure in ProjectCard, CommunityProjects, and Hero components
1 parent 5a87e7d commit d4ade3a

3 files changed

Lines changed: 55 additions & 36 deletions

File tree

src/components/cards/project_card.rs

Lines changed: 27 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
use crate::components::{button_link::ButtonLink, cards::card_title::CardTitle, icons::GithubIcon};
2-
use leptos::{component, prelude::*, view, IntoView};
2+
use leptos::{component, leptos_dom::helpers::window, prelude::*, view, IntoView};
33
use std::collections::HashMap;
4-
use leptos::leptos_dom::helpers::window;
54

65
#[component]
76
pub fn ProjectCard(
@@ -25,37 +24,43 @@ pub fn ProjectCard(
2524

2625
view! {
2726
<div class="group flex flex-col items-center sm:items-stretch gap-y-6 border border-black p-4 sm:p-6 hover:bg-orange-500 dark:hover:bg-zinc-900/40 bg-orange-100 dark:bg-black/40 drop-shadow-[0_0_0_rgba(0,0,0)] hover:drop-shadow-[-4px_-4px_0_rgba(0,0,0)] transition justify-between">
28-
<button on:click=move |_| {
29-
let win = window();
30-
win.open_with_url_and_target(link, "_blank").unwrap();
31-
} class="all-[unset] w-full cursor-pointer text-left flex items-stretch flex-col h-full justify-between ">
27+
<button
28+
on:click=move |_| {
29+
let win = window();
30+
win.open_with_url_and_target(link, "_blank").unwrap();
31+
}
32+
class="all-[unset] w-full cursor-pointer text-left flex items-stretch flex-col h-full justify-between "
33+
>
3234
<div class="flex flex-col justify-between gap-y-2">
33-
<Show
34-
when=move || { brand_as_letter }
35+
<Show
36+
when=move || { brand_as_letter }
3537
fallback={
3638
let color = current_color.clone();
3739
let src = brand_src.clone();
38-
move || view!{
39-
<img
40-
src=src.clone()
41-
loading="lazy"
42-
width="60"
43-
class=format!("rounded-full h-[60px] w-[60px] {color}")
44-
alt=name.join(" ")
45-
/>
40+
move || {
41+
view! {
42+
<img
43+
src=src.clone()
44+
loading="lazy"
45+
width="60"
46+
class=format!("rounded-full h-[60px] w-[60px] {color}")
47+
alt=name.join(" ")
48+
/>
49+
}
4650
}
4751
}
4852
>
49-
<span class=format!("h-[60px] w-[60px] rounded-full text-4xl flex justify-center items-center {current_color}")>
50-
{brand_src.clone()}
51-
</span>
52-
</Show> <CardTitle texts=name />
53+
<span class=format!(
54+
"h-[60px] w-[60px] rounded-full text-4xl flex justify-center items-center {current_color}",
55+
)>{brand_src.clone()}</span>
56+
</Show>
57+
<CardTitle texts=name />
5358
<p class="mt-2 font-work-sans text-black dark:text-white">{description}</p>
5459
</div>
5560
<div class="flex gap-4 sm:gap-0 justify-around items-center mt-4">
5661
<ButtonLink href=button_link size="tiny">
57-
<Show
58-
when=move || { !button_text.is_empty() }
62+
<Show
63+
when=move || { !button_text.is_empty() }
5964
fallback=move || name.join(" ")
6065
>
6166
<span>{button_text}</span>

src/components/community_projects.rs

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,14 @@ pub fn CommunityProjects(#[prop(default = false)] show_more: bool) -> impl IntoV
1616
<span class="font-alfa-slab text-orange-500">"Comunidad"</span>
1717
</h2>
1818
<div class="w-full grid sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 sm:gap-x-8 gap-y-8">
19-
<For
20-
each=move || COMMUNITY_PROJECTS.iter().take(if show_more { 4 } else { COMMUNITY_PROJECTS.len() })
19+
<For
20+
each=move || {
21+
COMMUNITY_PROJECTS
22+
.iter()
23+
.take(if show_more { 4 } else { COMMUNITY_PROJECTS.len() })
24+
}
2125
key=|item| item.name
22-
children={move |item| {
26+
children=move |item| {
2327
let image_src = if cfg!(debug_assertions)
2428
&& item.brand_src.starts_with("/gen_assets")
2529
{
@@ -40,7 +44,7 @@ pub fn CommunityProjects(#[prop(default = false)] show_more: bool) -> impl IntoV
4044
button_bg_color=item.button_bg_color
4145
/>
4246
}
43-
}}
47+
}
4448
/>
4549
</div>
4650
<Show when=move || show_more>

src/components/hero.rs

Lines changed: 20 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
use crate::components::SloganButton;
2-
use leptos::leptos_dom::logging;
3-
use leptos::{component, prelude::*, view, IntoView};
4-
use leptos::leptos_dom::helpers::location;
2+
use leptos::{
3+
component,
4+
leptos_dom::{helpers::location, logging},
5+
prelude::*,
6+
view, IntoView,
7+
};
58

69
#[component]
710
pub fn Hero() -> impl IntoView {
@@ -11,7 +14,12 @@ pub fn Hero() -> impl IntoView {
1114

1215
Effect::new(move |_| {
1316
let location = location();
14-
set_uwu.set(location.search().map(|s| s.contains("uwu")).unwrap_or(false));
17+
set_uwu.set(
18+
location
19+
.search()
20+
.map(|s| s.contains("uwu"))
21+
.unwrap_or(false),
22+
);
1523
});
1624

1725
let image_src = move || match (is_in_debug_mode, uwu.get()) {
@@ -21,16 +29,18 @@ pub fn Hero() -> impl IntoView {
2129
(false, true) => "./RustLang_uwu.png",
2230
};
2331

24-
let class_fn = move || if !uwu.get() {
32+
let class_fn = move || {
33+
if !uwu.get() {
2534
"grid items-center py-14 lg:py-32 px-4 gap-x-20 gap-y-10 lg:grid-cols-2 w-full"
26-
} else {
35+
} else {
2736
"grid items-center justify-center"
28-
};
37+
}
38+
};
2939

3040
view! {
3141
<section class=class_fn>
3242
<figure class="w-80 mx-auto lg:w-full">
33-
{move ||
43+
{move || {
3444
if !uwu.get() {
3545
view! {
3646
<img
@@ -53,10 +63,10 @@ pub fn Hero() -> impl IntoView {
5363
}
5464
.into_any()
5565
}
56-
}
66+
}}
5767
</figure>
5868
<div>
59-
<Show when=move || !uwu.get() >
69+
<Show when=move || !uwu.get()>
6070
<h1 class="flex flex-col mb-4 gap-y-2">
6171
<span class="font-work-sans text-4xl font-light text-center lg:text-left">
6272
"Bienvenidos a"

0 commit comments

Comments
 (0)