Skip to content

Agregando formateo (Rust y Leptos) #22

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
Aug 29, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 41 additions & 1 deletion .github/workflows/clippy.yml
Original file line number Diff line number Diff line change
@@ -1,14 +1,54 @@
name: clippy
on:
workflow_dispatch:
pull_request:
push:
branches:
- main

jobs:
clippy:
fmt:
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v2
- uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
override: true
- run: rustup component add rustfmt
- uses: actions-rs/cargo@v1
with:
command: fmt
args: --all -- --check

leptosfmt:
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v2
- uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: nightly
override: true
components: clippy
- name: Cache .cargo and target
uses: actions/cache@v2
with:
path: |
~/.cargo
key: ${{ runner.os }}-cargo-leptos-${{ hashFiles('**/Cargo.lock') }}
restore-keys: |
${{ runner.os }}-cargo-leptos-${{ hashFiles('**/Cargo.lock') }}
${{ runner.os }}-cargo-leptos
- name: Install LeptosFmt
run: cargo install leptosfmt --version 0.1.13
- name: Check LeptosFmt
run: leptosfmt --check .

clippy:
needs: [ fmt, leptosfmt ]
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v2

Expand Down
2 changes: 2 additions & 0 deletions clippy.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
too-many-arguments-threshold = 100
type-complexity-threshold = 1000
3 changes: 3 additions & 0 deletions leptosfmt.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
max_width = 100
tab_spaces = 4
attr_value_brace_style = "WhenRequired"
9 changes: 9 additions & 0 deletions rustfmt.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
max_width = 100
hard_tabs = false
tab_spaces = 4
newline_style = "Auto"
reorder_imports = true
reorder_modules = true
remove_nested_parens = true
merge_derives = true
imports_granularity = "Crate"
3 changes: 1 addition & 2 deletions src/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,8 @@ pub fn App() -> impl IntoView {
view! {
<Router>
<Routes>
<Route path="" view=|| view! { <Index /> }/>
<Route path="" view=|| view! { <Index/> }/>
</Routes>
</Router>
}
}

17 changes: 8 additions & 9 deletions src/components/button_link.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use std::collections::HashMap;
use leptos::*;
use std::collections::HashMap;

#[component]
pub fn ButtonLink(
Expand All @@ -10,23 +10,22 @@ pub fn ButtonLink(
) -> impl IntoView {
let colors = HashMap::from([
("primary", "bg-orange-300 hover:bg-black hover:text-white"),
("white", "bg-orange-100")
]);
let sizes = HashMap::from([
("tiny", "min-h-7"),
("normal", "h-9"),
("big", "h-12")
("white", "bg-orange-100"),
]);
let sizes = HashMap::from([("tiny", "min-h-7"), ("normal", "h-9"), ("big", "h-12")]);
let current_color = colors.get(&color).unwrap().to_string();
let current_size = sizes.get(&size).unwrap().to_string();


view! {
<a
href=href
target="_blank"
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)
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
)
>

{children()}
</a>
}
Expand Down
17 changes: 6 additions & 11 deletions src/components/cards/card_title.rs
Original file line number Diff line number Diff line change
@@ -1,27 +1,22 @@
use leptos::*;

#[component]
pub fn CardTitle(
#[prop(into)] texts: Vec<&'static str>
) -> impl IntoView {
pub fn CardTitle(#[prop(into)] texts: Vec<&'static str>) -> impl IntoView {
view! {
<h5 class="text-xl">
{texts.into_iter()
.map(|word|
{texts
.into_iter()
.map(|word| {
if word.to_lowercase().contains("rust") {
view! {
<span class="font-alfa-slab text-orange-500 group-hover:text-white">
{word}
</span>
}
} else {
view! {
<span class="font-work-sans text-black">
{word}
</span>
}
view! { <span class="font-work-sans text-black">{word}</span> }
}
)
})
.collect::<Vec<_>>()}
</h5>
}
Expand Down
27 changes: 13 additions & 14 deletions src/components/cards/community_card.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
use leptos::*;

use crate::components::dummy_component::DummyComponent;
use crate::components::icons::discord_icon::DiscordIcon;
use crate::components::icons::github_icon::GithubIcon;
use crate::components::icons::telegram_icon::TelegramIcon;
use crate::components::cards::card_title::CardTitle;
use crate::components::{
cards::card_title::CardTitle,
dummy_component::DummyComponent,
icons::{discord_icon::DiscordIcon, github_icon::GithubIcon, telegram_icon::TelegramIcon},
};

#[component]
pub fn CommunityCard(
Expand All @@ -22,19 +22,18 @@ pub fn CommunityCard(
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"
>
<div>
<img src=brand_src width="60" class="rounded-full mb-4" alt=brand_alt />
<CardTitle texts=name />
<p class="font-work-sans text-black">
{description}
</p>
<img src=brand_src width="60" class="rounded-full mb-4" alt=brand_alt/>
<CardTitle texts=name/>
<p class="font-work-sans text-black">{description}</p>
</div>
<span class="ml-auto">
{move || match icon {
"discord" => view!{ <DiscordIcon size=30 /> },
"github" => view!{ <GithubIcon size=30 /> },
"telegram" => view!{ <TelegramIcon size=30 /> },
_ => view!{ <DummyComponent /> }
"discord" => view! { <DiscordIcon size=30/> },
"github" => view! { <GithubIcon size=30/> },
"telegram" => view! { <TelegramIcon size=30/> },
_ => view! { <DummyComponent/> },
}}

</span>
</a>
}
Expand Down
2 changes: 1 addition & 1 deletion src/components/cards/mod.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
pub mod card_title;
pub mod community_card;
pub mod project_card;
pub mod card_title;
31 changes: 15 additions & 16 deletions src/components/cards/project_card.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
use std::collections::HashMap;
use leptos::*;
use std::collections::HashMap;

use crate::components::cards::card_title::CardTitle;
use crate::components::button_link::ButtonLink;
use crate::components::icons::github_icon::GithubIcon;
use crate::components::{
button_link::ButtonLink, cards::card_title::CardTitle, icons::github_icon::GithubIcon,
};

#[component]
pub fn ProjectCard(
Expand Down Expand Up @@ -32,30 +32,28 @@ pub fn ProjectCard(
<div class="flex flex-col justify-between gap-y-2">
{if brand_as_letter {
view! {
<span
class=format!(
"h-[60px] w-[60px] rounded-full text-4xl flex justify-center items-center {}",
current_color
)
>
<span class=format!(
"h-[60px] w-[60px] rounded-full text-4xl flex justify-center items-center {}",
current_color
)>

{brand_src}
</span>
}
} else {
view! {
<span>
<img
src=brand_src width="60"
src=brand_src
width="60"
class=format!("rounded-full h-[60px] w-[60px] {}", current_color)
alt=brand_alt
/>
</span>
}
}}
<CardTitle texts=name.clone() />
<p class="mt-2 font-work-sans text-black">
{description}
</p>
<CardTitle texts=name.clone()/>
<p class="mt-2 font-work-sans text-black">{description}</p>
</div>
<div class="flex gap-2 items-center mt-4">
<ButtonLink href=button_link size="tiny">
Expand All @@ -64,9 +62,10 @@ pub fn ProjectCard(
} else {
button_text.to_string()
}}

</ButtonLink>
<span class="ml-auto">
<GithubIcon size=30 />
<GithubIcon size=30/>
</span>
</div>
</a>
Expand Down
31 changes: 17 additions & 14 deletions src/components/community_projects.rs
Original file line number Diff line number Diff line change
Expand Up @@ -96,20 +96,23 @@ pub fn CommunityProjects() -> impl IntoView {
<span class="font-alfa-slab text-orange-500">"Comunidad"</span>
</h2>
<div class="w-full grid sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 sm:gap-x-8 gap-y-4">
{items.into_iter().map(|item| {
view! {
<ProjectCard
name=item.name
description=item.description
link=item.link
brand_src=item.brand_src
button_link=item.button_link
button_text=item.button_text
brand_as_letter=item.brand_as_letter
button_bg_color=item.button_bg_color
/>
}
}).collect::<Vec<_>>()}
{items
.into_iter()
.map(|item| {
view! {
<ProjectCard
name=item.name
description=item.description
link=item.link
brand_src=item.brand_src
button_link=item.button_link
button_text=item.button_text
brand_as_letter=item.brand_as_letter
button_bg_color=item.button_bg_color
/>
}
})
.collect::<Vec<_>>()}
</div>
</div>
</section>
Expand Down
4 changes: 1 addition & 3 deletions src/components/dummy_component.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,5 @@ use leptos::*;

#[component]
pub fn DummyComponent() -> impl IntoView {
view! {
<div></div>
}
view! { <div></div> }
}
21 changes: 11 additions & 10 deletions src/components/header.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,22 +17,23 @@ pub fn Header() -> impl IntoView {
alt="Rust Lang en Español"
/>
</div>
<button class="lg:hidden" on:click=move |_| {set_is_open.update(|n| *n = !*n)}>
<button
class="lg:hidden"
on:click=move |_| { set_is_open.update(|n| *n = !*n) }
>
<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>
</button>
</div>
<nav
class=move || format!(
"w-full lg:w-auto pb-10 pt-5 lg:p-0 {}",
if is_open() { "block" } else { "hidden lg:block" }
<nav class=move || {
format!(
"w-full lg:w-auto pb-10 pt-5 lg:p-0 {}", if is_open() { "block" } else {
"hidden lg:block" }
)
>
}>

<ul class="flex items-center gap-6 flex-col lg:flex-row lg:items-center">
<li>
<a
href="https://rustlanges.github.io/rust-book-es"
target="_blank"
>
<a href="https://rustlanges.github.io/rust-book-es" target="_blank">
"Aprende"
</a>
</li>
Expand Down
16 changes: 11 additions & 5 deletions src/components/hero.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,23 @@ use crate::components::header::Header;
pub fn Hero() -> impl IntoView {
view! {
<section class="w-full flex flex-col">
<Header />
<Header/>
<div class="flex items-center justify-center py-14 lg:py-32 px-4">
<div class="grid items-center gap-x-20 gap-y-10 lg:grid-cols-2">
<figure class="w-80 mx-auto lg:w-full">
<img src="./rhq3ezvso9611-min.png" width="500" class="mx-auto" />
<img src="./rhq3ezvso9611-min.png" width="500" class="mx-auto"/>
</figure>
<div class="">
<h1 class="flex flex-col mb-4 gap-y-2">
<span class="font-work-sans text-4xl font-light text-center lg:text-left">"Bienvenidos a"</span>
<span class="font-alfa-slab text-orange-500 text-6xl sm:text-7xl lg:text-8xl text-center lg:text-left">"Rust Lang"</span>
<span class="font-work-sans text-5xl font-semibold text-center lg:text-left">"En Español"</span>
<span class="font-work-sans text-4xl font-light text-center lg:text-left">
"Bienvenidos a"
</span>
<span class="font-alfa-slab text-orange-500 text-6xl sm:text-7xl lg:text-8xl text-center lg:text-left">
"Rust Lang"
</span>
<span class="font-work-sans text-5xl font-semibold text-center lg:text-left">
"En Español"
</span>
</h1>
<p class="font-work-sans font-light text-center lg:text-left">
"Una comunidad de gente mal intencionada y tonta."
Expand Down
Loading