Skip to content

Commit

Permalink
Configuring code formatters
Browse files Browse the repository at this point in the history
  • Loading branch information
SeraphyBR authored Aug 27, 2024
1 parent 0962b93 commit 105ef65
Show file tree
Hide file tree
Showing 24 changed files with 552 additions and 534 deletions.
8 changes: 5 additions & 3 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,14 @@ root = true
[*]
charset = utf-8
indent_style = space

[*.js]
quote_type = single
indent_size = 2
insert_final_newline = true
trim_trailing_whitespace = true
end_of_line = lf
max_line_length = 120

[*.js]
quote_type = single

[*.yml]
indent_size = 2
Expand Down
19 changes: 10 additions & 9 deletions .vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
{
"recommendations": [
"rust-lang.rust-analyzer",
"bradlc.vscode-tailwindcss",
"tamasfe.even-better-toml",
"esbenp.prettier-vscode",
"aaron-bond.better-comments",
"arrterian.nix-env-selector"
]
}
"recommendations": [
"rust-lang.rust-analyzer",
"bradlc.vscode-tailwindcss",
"tamasfe.even-better-toml",
"esbenp.prettier-vscode",
"aaron-bond.better-comments",
"arrterian.nix-env-selector",
"editorconfig.editorconfig"
]
}
9 changes: 6 additions & 3 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,16 @@
"comments": "on",
"strings": true
},
"editor.formatOnSave": true,
"editor.defaultFormatter": "esbenp.prettier-vscode",
"editor.codeActionsOnSave": {
"source.organizeImports": "explicit"
},
"[rust]": {
"editor.defaultFormatter": "rust-lang.rust-analyzer",
"editor.formatOnSave": true
"editor.defaultFormatter": "rust-lang.rust-analyzer"
},
"[javascript]": {
"editor.defaultFormatter": "esbenp.prettier-vscode",
"editor.formatOnSave": true,

"tailwindCSS.experimental.classRegex": ["'@apply([^']*)':"]
},
Expand Down
50 changes: 25 additions & 25 deletions build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,41 +3,41 @@ use std::io::Write;
use std::process::Command;

fn main() {
let _ = Command::new("npm")
.args(["run", "build"])
.output()
.expect("Falha ao executar npm run build");
let _ = Command::new("npm")
.args(["run", "build"])
.output()
.expect("Falha ao executar npm run build");

create_markdown_posts_with_files_to_include();
create_markdown_posts_with_files_to_include();
}

fn create_markdown_posts_with_files_to_include() {
let posts_folder = "./posts";
let posts_folder = "./posts";

let mut out_file =
fs::File::create("src/markdown_posts.rs").expect("Falha ao criar o arquivo de saída");
let mut out_file =
fs::File::create("src/markdown_posts.rs").expect("Falha ao criar o arquivo de saída");

writeln!(out_file, "// Generated By build.rs").unwrap();
writeln!(out_file, "pub const FILES: &[(&str, &str)] = &[").unwrap();
writeln!(out_file, "// Generated By build.rs").unwrap();
writeln!(out_file, "pub const FILES: &[(&str, &str)] = &[").unwrap();

let files = fs::read_dir(posts_folder).expect("Falha ao listar os arquivos no diretório");
let files = fs::read_dir(posts_folder).expect("Falha ao listar os arquivos no diretório");

for file in files {
let file = file.expect("Falha ao ler o arquivo");
let path = file.path();
for file in files {
let file = file.expect("Falha ao ler o arquivo");
let path = file.path();

if path.is_file() && path.extension().map_or(false, |ext| ext == "md") {
let file_name = path.file_stem().unwrap().to_str().unwrap();
if path.is_file() && path.extension().map_or(false, |ext| ext == "md") {
let file_name = path.file_stem().unwrap().to_str().unwrap();

writeln!(
out_file,
" (\"{}\", include_str!(\"../{}\")),",
file_name,
path.display()
)
.unwrap();
}
writeln!(
out_file,
" (\"{}\", include_str!(\"../{}\")),",
file_name,
path.display()
)
.unwrap();
}
}

writeln!(out_file, "];").unwrap();
writeln!(out_file, "];").unwrap();
}
1 change: 1 addition & 0 deletions rustfmt.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
tab_spaces = 2
42 changes: 21 additions & 21 deletions src/components/back_to_top.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,28 +4,28 @@ use web_sys::{ScrollBehavior, ScrollToOptions};

#[component]
pub fn BackToTopBtn() -> impl IntoView {
let (_, y) = use_window_scroll();
let (_, y) = use_window_scroll();

let opacity_btn = move || {
if y() > 300.0 {
1
} else {
0
}
};
let opacity_btn = move || {
if y() > 300.0 {
1
} else {
0
}
};

let on_click_go_to_top = |_| {
let options = ScrollToOptions::default();
options.set_behavior(ScrollBehavior::Smooth);
options.set_top(0.0);
window().scroll_to_with_scroll_to_options(&options);
};
let on_click_go_to_top = |_| {
let options = ScrollToOptions::default();
options.set_behavior(ScrollBehavior::Smooth);
options.set_top(0.0);
window().scroll_to_with_scroll_to_options(&options);
};

view! {
<div style:opacity=opacity_btn class="tw-fixed tw-bottom-6 tw-right-6 tw-transition-opacity tw-duration-700 tw-ease-in-out">
<button on:click=on_click_go_to_top class="tw-btn-primary tw-bg-opacity-80 tw-backdrop-blur-md">
<i class="fa-solid fa-chevron-up"/>
</button>
</div>
}
view! {
<div style:opacity=opacity_btn class="tw-fixed tw-bottom-6 tw-right-6 tw-transition-opacity tw-duration-700 tw-ease-in-out">
<button on:click=on_click_go_to_top class="tw-btn-primary tw-bg-opacity-80 tw-backdrop-blur-md">
<i class="fa-solid fa-chevron-up"/>
</button>
</div>
}
}
10 changes: 5 additions & 5 deletions src/components/card.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ use leptos::*;

#[component]
pub fn Card(#[prop(optional, into)] class: String, children: Children) -> impl IntoView {
view! {
<div class=class + " tw-w-3/4 tw-md:max-w-8xl tw-bg-white dark:tw-bg-graphite/80 tw-text-gray-700 dark:tw-text-white tw-backdrop-blur-md tw-p-8 tw-rounded-xl tw-shadow-md tw-max-w-4xl">
{children()}
</div>
}
view! {
<div class=class + " tw-w-3/4 tw-md:max-w-8xl tw-bg-white dark:tw-bg-graphite/80 tw-text-gray-700 dark:tw-text-white tw-backdrop-blur-md tw-p-8 tw-rounded-xl tw-shadow-md tw-max-w-4xl">
{children()}
</div>
}
}
56 changes: 28 additions & 28 deletions src/components/content.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,38 +6,38 @@ use wasm_bindgen::prelude::*;

#[wasm_bindgen(module = "/esbuild/js/highlight.min.js")]
extern "C" {
fn highlight_all();
fn highlight_all();
}

#[component]
pub fn BaseContent(
#[prop(into)] title: String,
#[prop(optional_no_strip)] bg_img: Option<String>,
#[prop(optional_no_strip)] bg_color: Option<String>,
#[prop(optional, into)] created_date: Option<DateTime<Utc>>,
#[prop(into)] back_href: String,
#[prop(optional, into)] inner_html: Option<String>,
#[prop(optional)] children: Option<Children>,
#[prop(into)] title: String,
#[prop(optional_no_strip)] bg_img: Option<String>,
#[prop(optional_no_strip)] bg_color: Option<String>,
#[prop(optional, into)] created_date: Option<DateTime<Utc>>,
#[prop(into)] back_href: String,
#[prop(optional, into)] inner_html: Option<String>,
#[prop(optional)] children: Option<Children>,
) -> impl IntoView {
create_effect(move |_| highlight_all());
create_effect(move |_| highlight_all());

view! {
<div class="tw-vflex tw-justify-center tw-items-stretch tw-gap-5 tw-text-neutral-800 tw-p-8">
<div class="tw-vflex tw-items-center tw-gap-6 tw-p-40 -tw-mt-16 -tw-ml-16 -tw-mr-16 tw-rounded-t-xl tw-bg-blend-multiply tw-bg-center tw-bg-cover"
style:background-color=bg_color
style:background-image=bg_img
>
<h1 class="tw-text-3xl tw-font-bold tw-text-center tw-text-white">{title}</h1>
<Show when=move || created_date.is_some()>
<h4 class="tw-text-xl tw-font-bold tw-text-white">Criado em {created_date.map(|d| d.format("%d-%m-%Y").to_string())}</h4>
</Show>
<A href=back_href class="tw-btn-primary">
<i class="fa fa-chevron-left"></i>
</A>
</div>
<article class="tw-prose dark:tw-prose-invert tw-max-w-none hover:prose-a:tw-text-accent dark:hover:prose-a:tw-text-accent-light" inner_html=inner_html>
{children.map(|c| c())}
</article>
</div>
}
view! {
<div class="tw-vflex tw-justify-center tw-items-stretch tw-gap-5 tw-text-neutral-800 tw-p-8">
<div class="tw-vflex tw-items-center tw-gap-6 tw-p-40 -tw-mt-16 -tw-ml-16 -tw-mr-16 tw-rounded-t-xl tw-bg-blend-multiply tw-bg-center tw-bg-cover"
style:background-color=bg_color
style:background-image=bg_img
>
<h1 class="tw-text-3xl tw-font-bold tw-text-center tw-text-white">{title}</h1>
<Show when=move || created_date.is_some()>
<h4 class="tw-text-xl tw-font-bold tw-text-white">Criado em {created_date.map(|d| d.format("%d-%m-%Y").to_string())}</h4>
</Show>
<A href=back_href class="tw-btn-primary">
<i class="fa fa-chevron-left"></i>
</A>
</div>
<article class="tw-prose dark:tw-prose-invert tw-max-w-none hover:prose-a:tw-text-accent dark:hover:prose-a:tw-text-accent-light" inner_html=inner_html>
{children.map(|c| c())}
</article>
</div>
}
}
46 changes: 23 additions & 23 deletions src/components/dark_mode.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,30 +4,30 @@ use leptos_use::{use_color_mode, ColorMode, UseColorModeReturn};

#[component]
pub fn DarkModeToggleBtn() -> impl IntoView {
let UseColorModeReturn { mode, set_mode, .. } = use_color_mode();
let UseColorModeReturn { mode, set_mode, .. } = use_color_mode();

let toggle = move |_| {
if mode() == ColorMode::Dark {
set_mode(ColorMode::Light);
} else {
set_mode(ColorMode::Dark);
}
};

let icon = move || {
if mode() == ColorMode::Dark {
"fa-solid fa-moon tw-w-[14px]"
} else {
"fa-solid fa-sun"
}
};
let toggle = move |_| {
if mode() == ColorMode::Dark {
set_mode(ColorMode::Light);
} else {
set_mode(ColorMode::Dark);
}
};

view! {
<Html class=move || if mode() == ColorMode::Dark {"tw-dark"} else {""} />
<div class="tw-fixed tw-top-6 tw-right-6">
<button on:click=toggle class="tw-btn-primary tw-bg-opacity-80 tw-backdrop-blur-md">
<i class=icon />
</button>
</div>
let icon = move || {
if mode() == ColorMode::Dark {
"fa-solid fa-moon tw-w-[14px]"
} else {
"fa-solid fa-sun"
}
};

view! {
<Html class=move || if mode() == ColorMode::Dark {"tw-dark"} else {""} />
<div class="tw-fixed tw-top-6 tw-right-6">
<button on:click=toggle class="tw-btn-primary tw-bg-opacity-80 tw-backdrop-blur-md">
<i class=icon />
</button>
</div>
}
}
6 changes: 3 additions & 3 deletions src/components/divider.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use leptos::*;

#[component]
pub fn Divider() -> impl IntoView {
view! {
<hr class="!tw-border-t-0 tw-w-full tw-h-px tw-bg-gradient-to-r tw-from-transparent tw-via-black dark:tw-via-white tw-to-transparent tw-opacity-15 tw-my-2"/>
}
view! {
<hr class="!tw-border-t-0 tw-w-full tw-h-px tw-bg-gradient-to-r tw-from-transparent tw-via-black dark:tw-via-white tw-to-transparent tw-opacity-15 tw-my-2"/>
}
}
Loading

0 comments on commit 105ef65

Please sign in to comment.