Skip to content

Commit f3e30fa

Browse files
authored
Merge pull request RustLangES#22 from SergioRibera/main
Agregando formateo (Rust y Leptos)
2 parents b2d21f5 + 8de2439 commit f3e30fa

22 files changed

+196
-163
lines changed

.github/workflows/clippy.yml

+41-1
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,54 @@
11
name: clippy
22
on:
3+
workflow_dispatch:
34
pull_request:
45
push:
56
branches:
67
- main
78

89
jobs:
9-
clippy:
10+
fmt:
1011
runs-on: ubuntu-22.04
12+
steps:
13+
- uses: actions/checkout@v2
14+
- uses: actions-rs/toolchain@v1
15+
with:
16+
profile: minimal
17+
toolchain: stable
18+
override: true
19+
- run: rustup component add rustfmt
20+
- uses: actions-rs/cargo@v1
21+
with:
22+
command: fmt
23+
args: --all -- --check
24+
25+
leptosfmt:
26+
runs-on: ubuntu-22.04
27+
steps:
28+
- uses: actions/checkout@v2
29+
- uses: actions-rs/toolchain@v1
30+
with:
31+
profile: minimal
32+
toolchain: nightly
33+
override: true
34+
components: clippy
35+
- name: Cache .cargo and target
36+
uses: actions/cache@v2
37+
with:
38+
path: |
39+
~/.cargo
40+
key: ${{ runner.os }}-cargo-leptos-${{ hashFiles('**/Cargo.lock') }}
41+
restore-keys: |
42+
${{ runner.os }}-cargo-leptos-${{ hashFiles('**/Cargo.lock') }}
43+
${{ runner.os }}-cargo-leptos
44+
- name: Install LeptosFmt
45+
run: cargo install leptosfmt --version 0.1.13
46+
- name: Check LeptosFmt
47+
run: leptosfmt --check .
1148

49+
clippy:
50+
needs: [ fmt, leptosfmt ]
51+
runs-on: ubuntu-22.04
1252
steps:
1353
- uses: actions/checkout@v2
1454

clippy.toml

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
too-many-arguments-threshold = 100
2+
type-complexity-threshold = 1000

leptosfmt.toml

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
max_width = 100
2+
tab_spaces = 4
3+
attr_value_brace_style = "WhenRequired"

rustfmt.toml

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
max_width = 100
2+
hard_tabs = false
3+
tab_spaces = 4
4+
newline_style = "Auto"
5+
reorder_imports = true
6+
reorder_modules = true
7+
remove_nested_parens = true
8+
merge_derives = true
9+
imports_granularity = "Crate"

src/app.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,8 @@ pub fn App() -> impl IntoView {
1111
view! {
1212
<Router>
1313
<Routes>
14-
<Route path="" view=|| view! { <Index /> }/>
14+
<Route path="" view=|| view! { <Index/> }/>
1515
</Routes>
1616
</Router>
1717
}
1818
}
19-

src/components/button_link.rs

+8-9
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
use std::collections::HashMap;
21
use leptos::*;
2+
use std::collections::HashMap;
33

44
#[component]
55
pub fn ButtonLink(
@@ -10,23 +10,22 @@ pub fn ButtonLink(
1010
) -> impl IntoView {
1111
let colors = HashMap::from([
1212
("primary", "bg-orange-300 hover:bg-black hover:text-white"),
13-
("white", "bg-orange-100")
14-
]);
15-
let sizes = HashMap::from([
16-
("tiny", "min-h-7"),
17-
("normal", "h-9"),
18-
("big", "h-12")
13+
("white", "bg-orange-100"),
1914
]);
15+
let sizes = HashMap::from([("tiny", "min-h-7"), ("normal", "h-9"), ("big", "h-12")]);
2016
let current_color = colors.get(&color).unwrap().to_string();
2117
let current_size = sizes.get(&size).unwrap().to_string();
2218

23-
2419
view! {
2520
<a
2621
href=href
2722
target="_blank"
28-
class=format!("tracking-wider font-work-sans border border-black flex items-center px-4 drop-shadow-[4px_4px_0_rgba(0,0,0)] hover:drop-shadow-[0_0_0_rgba(0,0,0)] transition w-fit gap-x-4 sm:whitespace-nowrap max-w-[10rem] sm:max-w-none {} {}", current_color, current_size)
23+
class=format!(
24+
"tracking-wider font-work-sans border border-black flex items-center px-4 drop-shadow-[4px_4px_0_rgba(0,0,0)] hover:drop-shadow-[0_0_0_rgba(0,0,0)] transition w-fit gap-x-4 sm:whitespace-nowrap max-w-[10rem] sm:max-w-none {} {}",
25+
current_color, current_size
26+
)
2927
>
28+
3029
{children()}
3130
</a>
3231
}

src/components/cards/card_title.rs

+6-11
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,22 @@
11
use leptos::*;
22

33
#[component]
4-
pub fn CardTitle(
5-
#[prop(into)] texts: Vec<&'static str>
6-
) -> impl IntoView {
4+
pub fn CardTitle(#[prop(into)] texts: Vec<&'static str>) -> impl IntoView {
75
view! {
86
<h5 class="text-xl">
9-
{texts.into_iter()
10-
.map(|word|
7+
{texts
8+
.into_iter()
9+
.map(|word| {
1110
if word.to_lowercase().contains("rust") {
1211
view! {
1312
<span class="font-alfa-slab text-orange-500 group-hover:text-white">
1413
{word}
1514
</span>
1615
}
1716
} else {
18-
view! {
19-
<span class="font-work-sans text-black">
20-
{word}
21-
</span>
22-
}
17+
view! { <span class="font-work-sans text-black">{word}</span> }
2318
}
24-
)
19+
})
2520
.collect::<Vec<_>>()}
2621
</h5>
2722
}

src/components/cards/community_card.rs

+13-14
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
use leptos::*;
22

3-
use crate::components::dummy_component::DummyComponent;
4-
use crate::components::icons::discord_icon::DiscordIcon;
5-
use crate::components::icons::github_icon::GithubIcon;
6-
use crate::components::icons::telegram_icon::TelegramIcon;
7-
use crate::components::cards::card_title::CardTitle;
3+
use crate::components::{
4+
cards::card_title::CardTitle,
5+
dummy_component::DummyComponent,
6+
icons::{discord_icon::DiscordIcon, github_icon::GithubIcon, telegram_icon::TelegramIcon},
7+
};
88

99
#[component]
1010
pub fn CommunityCard(
@@ -22,19 +22,18 @@ pub fn CommunityCard(
2222
class="group flex flex-col gap-y-6 border border-black p-6 hover:bg-orange-500 bg-orange-100 drop-shadow-[0_0_0_rgba(0,0,0)] hover:drop-shadow-[-4px_-4px_0_rgba(0,0,0)] transition justify-between"
2323
>
2424
<div>
25-
<img src=brand_src width="60" class="rounded-full mb-4" alt=brand_alt />
26-
<CardTitle texts=name />
27-
<p class="font-work-sans text-black">
28-
{description}
29-
</p>
25+
<img src=brand_src width="60" class="rounded-full mb-4" alt=brand_alt/>
26+
<CardTitle texts=name/>
27+
<p class="font-work-sans text-black">{description}</p>
3028
</div>
3129
<span class="ml-auto">
3230
{move || match icon {
33-
"discord" => view!{ <DiscordIcon size=30 /> },
34-
"github" => view!{ <GithubIcon size=30 /> },
35-
"telegram" => view!{ <TelegramIcon size=30 /> },
36-
_ => view!{ <DummyComponent /> }
31+
"discord" => view! { <DiscordIcon size=30/> },
32+
"github" => view! { <GithubIcon size=30/> },
33+
"telegram" => view! { <TelegramIcon size=30/> },
34+
_ => view! { <DummyComponent/> },
3735
}}
36+
3837
</span>
3938
</a>
4039
}

src/components/cards/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1+
pub mod card_title;
12
pub mod community_card;
23
pub mod project_card;
3-
pub mod card_title;

src/components/cards/project_card.rs

+15-16
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
use std::collections::HashMap;
21
use leptos::*;
2+
use std::collections::HashMap;
33

4-
use crate::components::cards::card_title::CardTitle;
5-
use crate::components::button_link::ButtonLink;
6-
use crate::components::icons::github_icon::GithubIcon;
4+
use crate::components::{
5+
button_link::ButtonLink, cards::card_title::CardTitle, icons::github_icon::GithubIcon,
6+
};
77

88
#[component]
99
pub fn ProjectCard(
@@ -32,30 +32,28 @@ pub fn ProjectCard(
3232
<div class="flex flex-col justify-between gap-y-2">
3333
{if brand_as_letter {
3434
view! {
35-
<span
36-
class=format!(
37-
"h-[60px] w-[60px] rounded-full text-4xl flex justify-center items-center {}",
38-
current_color
39-
)
40-
>
35+
<span class=format!(
36+
"h-[60px] w-[60px] rounded-full text-4xl flex justify-center items-center {}",
37+
current_color
38+
)>
39+
4140
{brand_src}
4241
</span>
4342
}
4443
} else {
4544
view! {
4645
<span>
4746
<img
48-
src=brand_src width="60"
47+
src=brand_src
48+
width="60"
4949
class=format!("rounded-full h-[60px] w-[60px] {}", current_color)
5050
alt=brand_alt
5151
/>
5252
</span>
5353
}
5454
}}
55-
<CardTitle texts=name.clone() />
56-
<p class="mt-2 font-work-sans text-black">
57-
{description}
58-
</p>
55+
<CardTitle texts=name.clone()/>
56+
<p class="mt-2 font-work-sans text-black">{description}</p>
5957
</div>
6058
<div class="flex gap-2 items-center mt-4">
6159
<ButtonLink href=button_link size="tiny">
@@ -64,9 +62,10 @@ pub fn ProjectCard(
6462
} else {
6563
button_text.to_string()
6664
}}
65+
6766
</ButtonLink>
6867
<span class="ml-auto">
69-
<GithubIcon size=30 />
68+
<GithubIcon size=30/>
7069
</span>
7170
</div>
7271
</a>

src/components/community_projects.rs

+17-14
Original file line numberDiff line numberDiff line change
@@ -96,20 +96,23 @@ pub fn CommunityProjects() -> impl IntoView {
9696
<span class="font-alfa-slab text-orange-500">"Comunidad"</span>
9797
</h2>
9898
<div class="w-full grid sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 sm:gap-x-8 gap-y-4">
99-
{items.into_iter().map(|item| {
100-
view! {
101-
<ProjectCard
102-
name=item.name
103-
description=item.description
104-
link=item.link
105-
brand_src=item.brand_src
106-
button_link=item.button_link
107-
button_text=item.button_text
108-
brand_as_letter=item.brand_as_letter
109-
button_bg_color=item.button_bg_color
110-
/>
111-
}
112-
}).collect::<Vec<_>>()}
99+
{items
100+
.into_iter()
101+
.map(|item| {
102+
view! {
103+
<ProjectCard
104+
name=item.name
105+
description=item.description
106+
link=item.link
107+
brand_src=item.brand_src
108+
button_link=item.button_link
109+
button_text=item.button_text
110+
brand_as_letter=item.brand_as_letter
111+
button_bg_color=item.button_bg_color
112+
/>
113+
}
114+
})
115+
.collect::<Vec<_>>()}
113116
</div>
114117
</div>
115118
</section>

src/components/dummy_component.rs

+1-3
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,5 @@ use leptos::*;
22

33
#[component]
44
pub fn DummyComponent() -> impl IntoView {
5-
view! {
6-
<div></div>
7-
}
5+
view! { <div></div> }
86
}

src/components/header.rs

+11-10
Original file line numberDiff line numberDiff line change
@@ -17,22 +17,23 @@ pub fn Header() -> impl IntoView {
1717
alt="Rust Lang en Español"
1818
/>
1919
</div>
20-
<button class="lg:hidden" on:click=move |_| {set_is_open.update(|n| *n = !*n)}>
20+
<button
21+
class="lg:hidden"
22+
on:click=move |_| { set_is_open.update(|n| *n = !*n) }
23+
>
2124
<span class="w-6 h-1 bg-black block my-4 relative after:absolute after:block after:bg-black after:w-6 after:h-1 after:bottom-2 before:absolute before:block before:bg-black before:w-6 before:h-1 before:-bottom-2"></span>
2225
</button>
2326
</div>
24-
<nav
25-
class=move || format!(
26-
"w-full lg:w-auto pb-10 pt-5 lg:p-0 {}",
27-
if is_open() { "block" } else { "hidden lg:block" }
27+
<nav class=move || {
28+
format!(
29+
"w-full lg:w-auto pb-10 pt-5 lg:p-0 {}", if is_open() { "block" } else {
30+
"hidden lg:block" }
2831
)
29-
>
32+
}>
33+
3034
<ul class="flex items-center gap-6 flex-col lg:flex-row lg:items-center">
3135
<li>
32-
<a
33-
href="https://rustlanges.github.io/rust-book-es"
34-
target="_blank"
35-
>
36+
<a href="https://rustlanges.github.io/rust-book-es" target="_blank">
3637
"Aprende"
3738
</a>
3839
</li>

src/components/hero.rs

+11-5
Original file line numberDiff line numberDiff line change
@@ -6,17 +6,23 @@ use crate::components::header::Header;
66
pub fn Hero() -> impl IntoView {
77
view! {
88
<section class="w-full flex flex-col">
9-
<Header />
9+
<Header/>
1010
<div class="flex items-center justify-center py-14 lg:py-32 px-4">
1111
<div class="grid items-center gap-x-20 gap-y-10 lg:grid-cols-2">
1212
<figure class="w-80 mx-auto lg:w-full">
13-
<img src="./rhq3ezvso9611-min.png" width="500" class="mx-auto" />
13+
<img src="./rhq3ezvso9611-min.png" width="500" class="mx-auto"/>
1414
</figure>
1515
<div class="">
1616
<h1 class="flex flex-col mb-4 gap-y-2">
17-
<span class="font-work-sans text-4xl font-light text-center lg:text-left">"Bienvenidos a"</span>
18-
<span class="font-alfa-slab text-orange-500 text-6xl sm:text-7xl lg:text-8xl text-center lg:text-left">"Rust Lang"</span>
19-
<span class="font-work-sans text-5xl font-semibold text-center lg:text-left">"En Español"</span>
17+
<span class="font-work-sans text-4xl font-light text-center lg:text-left">
18+
"Bienvenidos a"
19+
</span>
20+
<span class="font-alfa-slab text-orange-500 text-6xl sm:text-7xl lg:text-8xl text-center lg:text-left">
21+
"Rust Lang"
22+
</span>
23+
<span class="font-work-sans text-5xl font-semibold text-center lg:text-left">
24+
"En Español"
25+
</span>
2026
</h1>
2127
<p class="font-work-sans font-light text-center lg:text-left">
2228
"Una comunidad de gente mal intencionada y tonta."

0 commit comments

Comments
 (0)