Initial template commit
This commit is contained in:
119
frontend/src/main.rs
Normal file
119
frontend/src/main.rs
Normal file
@@ -0,0 +1,119 @@
|
||||
#![forbid(unsafe_code)]
|
||||
#![forbid(clippy::unwrap_used)]
|
||||
#![warn(clippy::all)]
|
||||
#![warn(clippy::pedantic)]
|
||||
#![warn(clippy::nursery)]
|
||||
#![warn(clippy::cargo)]
|
||||
#![allow(clippy::multiple_crate_versions)]
|
||||
#![allow(clippy::module_name_repetitions)]
|
||||
|
||||
use leptos::{
|
||||
either::Either,
|
||||
html::{
|
||||
a,
|
||||
div,
|
||||
img,
|
||||
},
|
||||
prelude::*,
|
||||
};
|
||||
|
||||
fn main() {
|
||||
console_error_panic_hook::set_once();
|
||||
leptos::mount::mount_to_body(|| app);
|
||||
}
|
||||
|
||||
// Look mom, no macros!
|
||||
fn app() -> impl IntoView {
|
||||
console_error_panic_hook::set_once();
|
||||
|
||||
div()
|
||||
.attr("data-theme", "dracula")
|
||||
.class("flex justify-center w-screen min-h-screen bg-base-100")
|
||||
.child(
|
||||
div()
|
||||
.class("flex flex-col gap-8 justify-center items-center font-semibold lg:gap-12")
|
||||
.child(title())
|
||||
.child(description())
|
||||
.child(source_code_link())
|
||||
.child(tools_links()),
|
||||
)
|
||||
}
|
||||
|
||||
fn title() -> impl IntoView {
|
||||
div()
|
||||
.class("text-2xl font-semibold md:text-3xl lg:text-4xl xl:text-5xl 2xl:text-6xl font-display")
|
||||
.child("Cheemsburger's Template")
|
||||
}
|
||||
|
||||
fn description() -> impl IntoView {
|
||||
div()
|
||||
.class("font-sans text-base font-light lg:text-lg xl:text-xl 2xl:text-2xl")
|
||||
.child("Welcome to my awesome template!")
|
||||
}
|
||||
|
||||
fn source_code_link() -> impl IntoView {
|
||||
div()
|
||||
.attr("data-tip", "Source")
|
||||
.class("tooltip tooltip-top tooltip-info")
|
||||
.child(
|
||||
a().id("source_code_btn_link")
|
||||
.class("gap-3 font-mono normal-case btn btn-lg btn-wide btn-outline")
|
||||
.attr("target", "_blank")
|
||||
.href("https://git.powerware.ie/opensourcecheemsburgers/template")
|
||||
.child(
|
||||
img()
|
||||
.src("assets/logos/gitea.svg")
|
||||
.class("w-8 h-8"),
|
||||
)
|
||||
.child("Source"),
|
||||
)
|
||||
}
|
||||
|
||||
fn tools_links() -> impl IntoView {
|
||||
div()
|
||||
.class("flex flex-col gap-x-4 gap-y-6 items-center md:grid md:grid-cols-3 xl:flex xl:flex-row")
|
||||
.child(link_btn("https://tauri.app", "Tauri", Some("tauri.svg")))
|
||||
.child(link_btn("https://leptos.dev", "Leptos", Some("leptos.svg")))
|
||||
.child(link_btn("https://tailwindcss.com", "TailwindCSS", Some("tailwind.svg")))
|
||||
.child(link_btn("https://daisyui.com", "DaisyUI", Some("daisyui.svg")))
|
||||
.child(link_btn("https://helix-editor.com", "Helix", Some("helix.svg")))
|
||||
.child(link_btn("https://dprint.dev", "Dprint", None))
|
||||
}
|
||||
|
||||
fn link_btn(link: &'static str, name: &'static str, logo: Option<&'static str>) -> impl IntoView {
|
||||
let tip = link.replace("https://", "");
|
||||
let mut id = name.to_string().to_ascii_lowercase();
|
||||
id.push_str("_link_btn");
|
||||
|
||||
if let Some(logo) = logo {
|
||||
let mut logo_path = String::from("assets/logos/");
|
||||
logo_path.push_str(logo);
|
||||
|
||||
Either::Left(
|
||||
div()
|
||||
.attr("data-tip", tip)
|
||||
.class("tooltip tooltip-top tooltip-info")
|
||||
.child(
|
||||
a().class("gap-3 font-mono normal-case btn btn-outline btn-md lg:btn-lg")
|
||||
.attr("target", "_blank")
|
||||
.href(link)
|
||||
.id(id)
|
||||
.child(img().src(logo_path).class("w-8 h-8"))
|
||||
.child(name),
|
||||
),
|
||||
)
|
||||
} else {
|
||||
Either::Right(
|
||||
div()
|
||||
.attr("data-tip", tip)
|
||||
.class("tooltip tooltip-top tooltip-info")
|
||||
.child(
|
||||
a().class("gap-3 font-mono normal-case btn btn-outline btn-md lg:btn-lg")
|
||||
.attr("target", "_blank")
|
||||
.href(link)
|
||||
.id(id)
|
||||
.child(name),
|
||||
),
|
||||
)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user