Skip to content

Commit

Permalink
fix: dioxus fmt
Browse files Browse the repository at this point in the history
  • Loading branch information
mrxiaozhuox committed Mar 8, 2023
1 parent 2526b32 commit a45eac7
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 87 deletions.
15 changes: 2 additions & 13 deletions src/components/content.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,7 @@ use crate::hooks::markdown::use_markdown;
#[inline_props]
pub fn Href<'a>(cx: Scope, to: &'a str, children: Element<'a>) -> Element {
cx.render(rsx! {
a {
class: "text-cyan-700 dark:text-cyan-100 underline",
href: "{to}",
target: "_blank",
children
}
a { class: "text-cyan-700 dark:text-cyan-100 underline", href: "{to}", target: "_blank", children }
})
}

Expand All @@ -25,11 +20,5 @@ pub fn Markdown<'a>(cx: Scope<'a, MarkdownProps<'a>>) -> Element {
let md_parser = use_markdown(&cx);
let content = md_parser(cx.props.content.clone());
let extra_class = &cx.props.class;
cx.render(rsx! {
div {
id: "markdown-body",
class: "prose {extra_class}",
dangerous_inner_html: "{content}",
}
})
cx.render(rsx! {div { id: "markdown-body", class: "prose {extra_class}", dangerous_inner_html: "{content}" }})
}
24 changes: 5 additions & 19 deletions src/components/footer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,11 @@ pub fn Footer(cx: Scope) -> Element {
log::info!("dark mode: {:?}", is_dark(&cx));
let current_mode = is_dark(&cx);
cx.render(rsx! {
div {
class: "mt-6 flex space-x-4 justify-center",
div { class: "mt-6 flex space-x-4 justify-center",
Link {
class: "text-black dark:text-white hover:text-gray-800 dark:hover:text-gray-200",
to: "/",
Icon {
height: 26,
width: 26,
icon: fa_solid_icons::FaHouse
}
Icon { height: 26, width: 26, icon: fa_solid_icons::FaHouse }
}
a {
class: "text-black dark:text-white hover:text-gray-800 dark:hover:text-gray-200",
Expand Down Expand Up @@ -51,24 +46,15 @@ pub fn Footer(cx: Scope) -> Element {
Link {
class: "text-black dark:text-white hover:text-gray-800 dark:hover:text-gray-200",
to: "/about",
Icon {
height: 26,
width: 26,
icon: fa_solid_icons::FaBook
}
Icon { height: 26, width: 26, icon: fa_solid_icons::FaBook }
}
a {
class: "text-black dark:text-white hover:text-gray-800 dark:hover:text-gray-200",
href: "https://github.com/mrxiaozhuox/dioxus-starter",
Icon {
height: 26,
width: 26,
icon: fa_brands_icons::FaGithub
}
Icon { height: 26, width: 26, icon: fa_brands_icons::FaGithub }
}
}
div {
class: "mt-10 flex justify-center text-gray-400",
div { class: "mt-10 flex justify-center text-gray-400",
span {
"[ made by "
a {
Expand Down
21 changes: 5 additions & 16 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,23 +30,12 @@ fn App(cx: Scope) -> Element {

cx.render(rsx! {
// dioxus toast manager init
ToastFrame {
manager: use_atom_ref(&cx, TOAST_MANAGER),
}
ToastFrame { manager: use_atom_ref(&cx, TOAST_MANAGER) }
// dioxus router info
Router {
Route {
to: "/",
HelloDioxus {}
}
Route {
to: "/hi/:name",
SayHi {}
}
Route {
to: "/about",
About {}
}
Router {
Route { to: "/", HelloDioxus {} }
Route { to: "/hi/:name", SayHi {} }
Route { to: "/about", About {} }
// 404 page
Route { to: "", pages::_404::NotFound {} }
}
Expand Down
12 changes: 4 additions & 8 deletions src/pages/_404.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,10 @@ use crate::components::footer::Footer;

pub fn NotFound(cx: Scope) -> Element {
cx.render(rsx! {
section {
class: "h-screen bg-cover bg-white dark:bg-gray-600",
div {
class: "flex h-full w-full items-center justify-center container mx-auto px-8",
div {
class: "max-w-2xl text-center",
h1 {
class: "text-3xl sm:text-5xl capitalize tracking-widest dark:text-white lg:text-6xl",
section { class: "h-screen bg-cover bg-white dark:bg-gray-600",
div { class: "flex h-full w-full items-center justify-center container mx-auto px-8",
div { class: "max-w-2xl text-center",
h1 { class: "text-3xl sm:text-5xl capitalize tracking-widest dark:text-white lg:text-6xl",
"Page Not Found"
}
Footer {}
Expand Down
46 changes: 15 additions & 31 deletions src/pages/starter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,22 +15,16 @@ pub fn HelloDioxus(cx: Scope) -> Element {
let toast = use_atom_ref(&cx, TOAST_MANAGER);

cx.render(rsx! {
section {
class: "h-screen bg-cover bg-white dark:bg-gray-600",
div {
class: "flex h-full w-full items-center justify-center container mx-auto px-8",
div {
class: "max-w-2xl text-center",
h1 {
class: "text-3xl sm:text-5xl capitalize tracking-widest text-gray-600 dark:text-white lg:text-6xl",
section { class: "h-screen bg-cover bg-white dark:bg-gray-600",
div { class: "flex h-full w-full items-center justify-center container mx-auto px-8",
div { class: "max-w-2xl text-center",
h1 { class: "text-3xl sm:text-5xl capitalize tracking-widest text-gray-600 dark:text-white lg:text-6xl",
"Dioxus Starter"
}
p {
class: "mt-6 lg:text-lg text-gray-600 dark:text-white",
p { class: "mt-6 lg:text-lg text-gray-600 dark:text-white",
"Opinionated Dioxus Starter Template"
}
div {
class: "mt-8 flex flex-col space-y-3 sm:-mx-2 sm:flex-row sm:justify-center sm:space-y-0",
div { class: "mt-8 flex flex-col space-y-3 sm:-mx-2 sm:flex-row sm:justify-center sm:space-y-0",
input {
r#type: "text",
class: "rounded-md border border-transparent bg-gray-800 dark:bg-white/20 px-4 py-2 text-white placeholder-white backdrop-blur-sm focus:border-blue-400 focus:outline-none focus:ring focus:ring-blue-300 focus:ring-opacity-40 sm:mx-2",
Expand Down Expand Up @@ -64,15 +58,11 @@ pub fn SayHi(cx: Scope) -> Element {
let name = route.segment("name").unwrap();
let name = urlencoding::decode(name).expect("UTF-8").to_string();
cx.render(rsx! {
section {
class: "h-screen bg-cover bg-white dark:bg-gray-600",
div {
class: "flex h-full w-full items-center justify-center container mx-auto px-8",
div {
class: "max-w-2xl text-center",
h1 {
class: "text-3xl sm:text-5xl capitalize tracking-widest dark:text-white lg:text-6xl",
"Hi, \"{name}\""
section { class: "h-screen bg-cover bg-white dark:bg-gray-600",
div { class: "flex h-full w-full items-center justify-center container mx-auto px-8",
div { class: "max-w-2xl text-center",
h1 { class: "text-3xl sm:text-5xl capitalize tracking-widest dark:text-white lg:text-6xl",
"Hi, "{name}""
}
Footer {}
}
Expand All @@ -84,17 +74,11 @@ pub fn SayHi(cx: Scope) -> Element {
pub fn About(cx: Scope) -> Element {
let content = include_str!("../markdown/readme.md");
cx.render(rsx! {
div {
class: "dark:bg-gray-600",
div { class: "dark:bg-gray-600",
br {}
div {
class: "md:flex md:justify-center",
div {
class: "block p-8 rounded-lg shadow-2xl bg-white dark:bg-gray-700",
Markdown {
class: "dark:text-white",
content: content.to_string()
}
div { class: "md:flex md:justify-center",
div { class: "block p-8 rounded-lg shadow-2xl bg-white dark:bg-gray-700",
Markdown { class: "dark:text-white", content: content.to_string() }
}
}
Footer {}
Expand Down

0 comments on commit a45eac7

Please sign in to comment.