diff --git a/public/fonts/DejaVuSansMono.ttf b/public/fonts/DejaVuSansMono.ttf deleted file mode 100644 index 10c879b..0000000 Binary files a/public/fonts/DejaVuSansMono.ttf and /dev/null differ diff --git a/public/fonts/OpenDyslexic-Bold.otf b/public/fonts/OpenDyslexic-Bold.otf new file mode 100644 index 0000000..4c492e2 Binary files /dev/null and b/public/fonts/OpenDyslexic-Bold.otf differ diff --git a/public/fonts/OpenDyslexic-BoldItalic.otf b/public/fonts/OpenDyslexic-BoldItalic.otf new file mode 100644 index 0000000..f71b430 Binary files /dev/null and b/public/fonts/OpenDyslexic-BoldItalic.otf differ diff --git a/public/fonts/OpenDyslexic-Italic.otf b/public/fonts/OpenDyslexic-Italic.otf new file mode 100644 index 0000000..fdead4d Binary files /dev/null and b/public/fonts/OpenDyslexic-Italic.otf differ diff --git a/public/fonts/OpenDyslexic-Regular.otf b/public/fonts/OpenDyslexic-Regular.otf new file mode 100644 index 0000000..1226d2a Binary files /dev/null and b/public/fonts/OpenDyslexic-Regular.otf differ diff --git a/public/images/black_square_button.png b/public/images/black_square_button.png new file mode 100644 index 0000000..45b1d40 Binary files /dev/null and b/public/images/black_square_button.png differ diff --git a/public/images/white_square_button.png b/public/images/white_square_button.png new file mode 100644 index 0000000..a34b731 Binary files /dev/null and b/public/images/white_square_button.png differ diff --git a/public/styles/tailwind.min.css b/public/styles/tailwind.min.css index b5d8578..ea6c80f 100644 --- a/public/styles/tailwind.min.css +++ b/public/styles/tailwind.min.css @@ -1 +1 @@ -/*! tailwindcss v3.3.0 | MIT License | https://tailwindcss.com*/*,:after,:before{box-sizing:border-box;border:0 solid #e5e7eb}:after,:before{--tw-content:""}html{line-height:1.5;-webkit-text-size-adjust:100%;-moz-tab-size:4;-o-tab-size:4;tab-size:4;font-family:ui-sans-serif,system-ui,-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Helvetica Neue,Arial,Noto Sans,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol,Noto Color Emoji;font-feature-settings:normal;font-variation-settings:normal}body{margin:0;line-height:inherit}hr{height:0;color:inherit;border-top-width:1px}abbr:where([title]){-webkit-text-decoration:underline dotted;text-decoration:underline dotted}h1,h2,h3,h4,h5,h6{font-size:inherit;font-weight:inherit}a{color:inherit;text-decoration:inherit}b,strong{font-weight:bolder}code,kbd,pre,samp{font-family:ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,Liberation Mono,Courier New,monospace;font-size:1em}small{font-size:80%}sub,sup{font-size:75%;line-height:0;position:relative;vertical-align:initial}sub{bottom:-.25em}sup{top:-.5em}table{text-indent:0;border-color:inherit;border-collapse:collapse}button,input,optgroup,select,textarea{font-family:inherit;font-size:100%;font-weight:inherit;line-height:inherit;color:inherit;margin:0;padding:0}button,select{text-transform:none}[type=button],[type=reset],[type=submit],button{-webkit-appearance:button;background-color:initial;background-image:none}:-moz-focusring{outline:auto}:-moz-ui-invalid{box-shadow:none}progress{vertical-align:initial}::-webkit-inner-spin-button,::-webkit-outer-spin-button{height:auto}[type=search]{-webkit-appearance:textfield;outline-offset:-2px}::-webkit-search-decoration{-webkit-appearance:none}::-webkit-file-upload-button{-webkit-appearance:button;font:inherit}summary{display:list-item}blockquote,dd,dl,figure,h1,h2,h3,h4,h5,h6,hr,p,pre{margin:0}fieldset{margin:0}fieldset,legend{padding:0}menu,ol,ul{list-style:none;margin:0;padding:0}textarea{resize:vertical}input::-moz-placeholder,textarea::-moz-placeholder{opacity:1;color:#9ca3af}input::placeholder,textarea::placeholder{opacity:1;color:#9ca3af}[role=button],button{cursor:pointer}:disabled{cursor:default}audio,canvas,embed,iframe,img,object,svg,video{display:block;vertical-align:middle}img,video{max-width:100%;height:auto}[hidden]{display:none}*,::backdrop,:after,:before{--tw-border-spacing-x:0;--tw-border-spacing-y:0;--tw-translate-x:0;--tw-translate-y:0;--tw-rotate:0;--tw-skew-x:0;--tw-skew-y:0;--tw-scale-x:1;--tw-scale-y:1;--tw-pan-x: ;--tw-pan-y: ;--tw-pinch-zoom: ;--tw-scroll-snap-strictness:proximity;--tw-ordinal: ;--tw-slashed-zero: ;--tw-numeric-figure: ;--tw-numeric-spacing: ;--tw-numeric-fraction: ;--tw-ring-inset: ;--tw-ring-offset-width:0px;--tw-ring-offset-color:#fff;--tw-ring-color:#3b82f680;--tw-ring-offset-shadow:0 0 #0000;--tw-ring-shadow:0 0 #0000;--tw-shadow:0 0 #0000;--tw-shadow-colored:0 0 #0000;--tw-blur: ;--tw-brightness: ;--tw-contrast: ;--tw-grayscale: ;--tw-hue-rotate: ;--tw-invert: ;--tw-saturate: ;--tw-sepia: ;--tw-drop-shadow: ;--tw-backdrop-blur: ;--tw-backdrop-brightness: ;--tw-backdrop-contrast: ;--tw-backdrop-grayscale: ;--tw-backdrop-hue-rotate: ;--tw-backdrop-invert: ;--tw-backdrop-opacity: ;--tw-backdrop-saturate: ;--tw-backdrop-sepia: }.container{width:100%}@media (min-width:640px){.container{max-width:640px}}@media (min-width:768px){.container{max-width:768px}}@media (min-width:1024px){.container{max-width:1024px}}@media (min-width:1280px){.container{max-width:1280px}}@media (min-width:1536px){.container{max-width:1536px}}.mx-4{margin-left:1rem;margin-right:1rem}.mx-auto{margin-left:auto;margin-right:auto}.ml-6{margin-left:1.5rem}.mr-6{margin-right:1.5rem}.flex{display:flex}.min-h-screen{min-height:100vh}.max-w-fit{max-width:-moz-fit-content;max-width:fit-content}.flex-col{flex-direction:column}.justify-center{justify-content:center}.space-y-4>:not([hidden])~:not([hidden]){--tw-space-y-reverse:0;margin-top:calc(1rem*(1 - var(--tw-space-y-reverse)));margin-bottom:calc(1rem*var(--tw-space-y-reverse))}.border-4{border-width:4px}.border-alice-werefox-red-dark{--tw-border-opacity:1;border-color:rgb(128 0 8/var(--tw-border-opacity))}.bg-alice-werefox-grey-light{--tw-bg-opacity:1;background-color:rgb(204 204 204/var(--tw-bg-opacity))}.bg-alice-werefox-grey-lightest{--tw-bg-opacity:1;background-color:rgb(238 238 238/var(--tw-bg-opacity))}.p-4{padding:1rem}.py-4{padding-top:1rem;padding-bottom:1rem}.text-center{text-align:center}.font-nerd{font-family:DejaVuSansMono}.text-lg{font-size:1.125rem;line-height:1.75rem}.text-alice-werefox-red-dark{--tw-text-opacity:1;color:rgb(128 0 8/var(--tw-text-opacity))}.ring-2{--tw-ring-offset-shadow:var(--tw-ring-inset) 0 0 0 var(--tw-ring-offset-width) var(--tw-ring-offset-color);--tw-ring-shadow:var(--tw-ring-inset) 0 0 0 calc(2px + var(--tw-ring-offset-width)) var(--tw-ring-color)}.ring-2,.ring-4{box-shadow:var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow,0 0 #0000)}.ring-4{--tw-ring-offset-shadow:var(--tw-ring-inset) 0 0 0 var(--tw-ring-offset-width) var(--tw-ring-offset-color);--tw-ring-shadow:var(--tw-ring-inset) 0 0 0 calc(4px + var(--tw-ring-offset-width)) var(--tw-ring-color)}.ring-alice-werefox-red-dark{--tw-ring-opacity:1;--tw-ring-color:rgb(128 0 8/var(--tw-ring-opacity))}.transition{transition-property:color,background-color,border-color,text-decoration-color,fill,stroke,opacity,box-shadow,transform,filter,-webkit-backdrop-filter;transition-property:color,background-color,border-color,text-decoration-color,fill,stroke,opacity,box-shadow,transform,filter,backdrop-filter;transition-property:color,background-color,border-color,text-decoration-color,fill,stroke,opacity,box-shadow,transform,filter,backdrop-filter,-webkit-backdrop-filter;transition-timing-function:cubic-bezier(.4,0,.2,1);transition-duration:.15s}@font-face{font-family:DejaVuSansMono;src:url(/fonts/DejaVuSansMono.ttf)}@keyframes yip{0%,to{transform:scale(1)}50%{transform:scale(1.01)}}.hover\:animate-yip:hover{animation:yip .1s ease-in-out}.hover\:text-alice-werefox-blue-dark:hover{--tw-text-opacity:1;color:rgb(51 0 255/var(--tw-text-opacity))}.hover\:ring-alice-werefox-blue:hover{--tw-ring-opacity:1;--tw-ring-color:rgb(27 41 224/var(--tw-ring-opacity))}@media (prefers-color-scheme:dark){.dark\:border-alice-werefox-red{--tw-border-opacity:1;border-color:rgb(201 52 57/var(--tw-border-opacity))}.dark\:bg-alice-werefox-grey{--tw-bg-opacity:1;background-color:rgb(36 36 36/var(--tw-bg-opacity))}.dark\:bg-alice-werefox-grey-dark{--tw-bg-opacity:1;background-color:rgb(18 18 18/var(--tw-bg-opacity))}.dark\:text-alice-werefox-red-light{--tw-text-opacity:1;color:rgb(224 133 135/var(--tw-text-opacity))}.dark\:ring-alice-werefox-red{--tw-ring-opacity:1;--tw-ring-color:rgb(201 52 57/var(--tw-ring-opacity))}.dark\:hover\:text-alice-werefox-blue-light:hover{--tw-text-opacity:1;color:rgb(145 151 243/var(--tw-text-opacity))}.dark\:hover\:ring-alice-werefox-blue:hover{--tw-ring-opacity:1;--tw-ring-color:rgb(27 41 224/var(--tw-ring-opacity))}} \ No newline at end of file +/*! tailwindcss v3.3.0 | MIT License | https://tailwindcss.com*/*,:after,:before{box-sizing:border-box;border:0 solid #e5e7eb}:after,:before{--tw-content:""}html{line-height:1.5;-webkit-text-size-adjust:100%;-moz-tab-size:4;-o-tab-size:4;tab-size:4;font-family:ui-sans-serif,system-ui,-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Helvetica Neue,Arial,Noto Sans,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol,Noto Color Emoji;font-feature-settings:normal;font-variation-settings:normal}body{margin:0;line-height:inherit}hr{height:0;color:inherit;border-top-width:1px}abbr:where([title]){-webkit-text-decoration:underline dotted;text-decoration:underline dotted}h1,h2,h3,h4,h5,h6{font-size:inherit;font-weight:inherit}a{color:inherit;text-decoration:inherit}b,strong{font-weight:bolder}code,kbd,pre,samp{font-family:ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,Liberation Mono,Courier New,monospace;font-size:1em}small{font-size:80%}sub,sup{font-size:75%;line-height:0;position:relative;vertical-align:initial}sub{bottom:-.25em}sup{top:-.5em}table{text-indent:0;border-color:inherit;border-collapse:collapse}button,input,optgroup,select,textarea{font-family:inherit;font-size:100%;font-weight:inherit;line-height:inherit;color:inherit;margin:0;padding:0}button,select{text-transform:none}[type=button],[type=reset],[type=submit],button{-webkit-appearance:button;background-color:initial;background-image:none}:-moz-focusring{outline:auto}:-moz-ui-invalid{box-shadow:none}progress{vertical-align:initial}::-webkit-inner-spin-button,::-webkit-outer-spin-button{height:auto}[type=search]{-webkit-appearance:textfield;outline-offset:-2px}::-webkit-search-decoration{-webkit-appearance:none}::-webkit-file-upload-button{-webkit-appearance:button;font:inherit}summary{display:list-item}blockquote,dd,dl,figure,h1,h2,h3,h4,h5,h6,hr,p,pre{margin:0}fieldset{margin:0}fieldset,legend{padding:0}menu,ol,ul{list-style:none;margin:0;padding:0}textarea{resize:vertical}input::-moz-placeholder,textarea::-moz-placeholder{opacity:1;color:#9ca3af}input::placeholder,textarea::placeholder{opacity:1;color:#9ca3af}[role=button],button{cursor:pointer}:disabled{cursor:default}audio,canvas,embed,iframe,img,object,svg,video{display:block;vertical-align:middle}img,video{max-width:100%;height:auto}[hidden]{display:none}*,::backdrop,:after,:before{--tw-border-spacing-x:0;--tw-border-spacing-y:0;--tw-translate-x:0;--tw-translate-y:0;--tw-rotate:0;--tw-skew-x:0;--tw-skew-y:0;--tw-scale-x:1;--tw-scale-y:1;--tw-pan-x: ;--tw-pan-y: ;--tw-pinch-zoom: ;--tw-scroll-snap-strictness:proximity;--tw-ordinal: ;--tw-slashed-zero: ;--tw-numeric-figure: ;--tw-numeric-spacing: ;--tw-numeric-fraction: ;--tw-ring-inset: ;--tw-ring-offset-width:0px;--tw-ring-offset-color:#fff;--tw-ring-color:#3b82f680;--tw-ring-offset-shadow:0 0 #0000;--tw-ring-shadow:0 0 #0000;--tw-shadow:0 0 #0000;--tw-shadow-colored:0 0 #0000;--tw-blur: ;--tw-brightness: ;--tw-contrast: ;--tw-grayscale: ;--tw-hue-rotate: ;--tw-invert: ;--tw-saturate: ;--tw-sepia: ;--tw-drop-shadow: ;--tw-backdrop-blur: ;--tw-backdrop-brightness: ;--tw-backdrop-contrast: ;--tw-backdrop-grayscale: ;--tw-backdrop-hue-rotate: ;--tw-backdrop-invert: ;--tw-backdrop-opacity: ;--tw-backdrop-saturate: ;--tw-backdrop-sepia: }.container{width:100%}@media (min-width:640px){.container{max-width:640px}}@media (min-width:768px){.container{max-width:768px}}@media (min-width:1024px){.container{max-width:1024px}}@media (min-width:1280px){.container{max-width:1280px}}@media (min-width:1536px){.container{max-width:1536px}}.mx-4{margin-left:1rem;margin-right:1rem}.mx-auto{margin-left:auto;margin-right:auto}.ml-6{margin-left:1.5rem}.mr-6{margin-right:1.5rem}.flex{display:flex}.min-h-screen{min-height:100vh}.max-w-fit{max-width:-moz-fit-content;max-width:fit-content}.max-w-full{max-width:100%}.flex-row{flex-direction:row}.flex-col{flex-direction:column}.justify-center{justify-content:center}.space-y-4>:not([hidden])~:not([hidden]){--tw-space-y-reverse:0;margin-top:calc(1rem*(1 - var(--tw-space-y-reverse)));margin-bottom:calc(1rem*var(--tw-space-y-reverse))}.border-4{border-width:4px}.border-alice-werefox-red-dark{--tw-border-opacity:1;border-color:rgb(128 0 8/var(--tw-border-opacity))}.bg-alice-werefox-grey-light{--tw-bg-opacity:1;background-color:rgb(204 204 204/var(--tw-bg-opacity))}.bg-alice-werefox-grey-lightest{--tw-bg-opacity:1;background-color:rgb(238 238 238/var(--tw-bg-opacity))}.p-4{padding:1rem}.py-4{padding-top:1rem;padding-bottom:1rem}.text-center{text-align:center}.font-nerd{font-family:OpenDyslexic}.text-lg{font-size:1.125rem;line-height:1.75rem}.text-alice-werefox-red-dark{--tw-text-opacity:1;color:rgb(128 0 8/var(--tw-text-opacity))}.ring-2{--tw-ring-offset-shadow:var(--tw-ring-inset) 0 0 0 var(--tw-ring-offset-width) var(--tw-ring-offset-color);--tw-ring-shadow:var(--tw-ring-inset) 0 0 0 calc(2px + var(--tw-ring-offset-width)) var(--tw-ring-color)}.ring-2,.ring-4{box-shadow:var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow,0 0 #0000)}.ring-4{--tw-ring-offset-shadow:var(--tw-ring-inset) 0 0 0 var(--tw-ring-offset-width) var(--tw-ring-offset-color);--tw-ring-shadow:var(--tw-ring-inset) 0 0 0 calc(4px + var(--tw-ring-offset-width)) var(--tw-ring-color)}.ring-alice-werefox-red-dark{--tw-ring-opacity:1;--tw-ring-color:rgb(128 0 8/var(--tw-ring-opacity))}.transition{transition-property:color,background-color,border-color,text-decoration-color,fill,stroke,opacity,box-shadow,transform,filter,-webkit-backdrop-filter;transition-property:color,background-color,border-color,text-decoration-color,fill,stroke,opacity,box-shadow,transform,filter,backdrop-filter;transition-property:color,background-color,border-color,text-decoration-color,fill,stroke,opacity,box-shadow,transform,filter,backdrop-filter,-webkit-backdrop-filter;transition-timing-function:cubic-bezier(.4,0,.2,1);transition-duration:.15s}@font-face{font-family:OpenDyslexic;src:url(/fonts/OpenDyslexic-Regular.otf)}.before\:content-\[\'Open\'\]:before{--tw-content:"Open";content:var(--tw-content)}@keyframes yip{0%,to{transform:scale(1)}50%{transform:scale(1.01)}}.hover\:animate-yip:hover{animation:yip .1s ease-in-out}.hover\:text-alice-werefox-blue-dark:hover{--tw-text-opacity:1;color:rgb(51 0 255/var(--tw-text-opacity))}.hover\:ring-alice-werefox-blue:hover{--tw-ring-opacity:1;--tw-ring-color:rgb(27 41 224/var(--tw-ring-opacity))}.group[open] .group-open\:before\:content-\[\'Close\'\]:before{--tw-content:"Close";content:var(--tw-content)}:is(.dark .dark\:border-alice-werefox-red){--tw-border-opacity:1;border-color:rgb(201 52 57/var(--tw-border-opacity))}:is(.dark .dark\:bg-alice-werefox-grey){--tw-bg-opacity:1;background-color:rgb(36 36 36/var(--tw-bg-opacity))}:is(.dark .dark\:bg-alice-werefox-grey-dark){--tw-bg-opacity:1;background-color:rgb(18 18 18/var(--tw-bg-opacity))}:is(.dark .dark\:text-alice-werefox-red-light){--tw-text-opacity:1;color:rgb(224 133 135/var(--tw-text-opacity))}:is(.dark .dark\:ring-alice-werefox-red){--tw-ring-opacity:1;--tw-ring-color:rgb(201 52 57/var(--tw-ring-opacity))}:is(.dark .dark\:hover\:text-alice-werefox-blue-light:hover){--tw-text-opacity:1;color:rgb(145 151 243/var(--tw-text-opacity))}:is(.dark .dark\:hover\:ring-alice-werefox-blue:hover){--tw-ring-opacity:1;--tw-ring-color:rgb(27 41 224/var(--tw-ring-opacity))} \ No newline at end of file diff --git a/templates/index.html.hbs b/templates/index.html.hbs index babfafc..df43252 100644 --- a/templates/index.html.hbs +++ b/templates/index.html.hbs @@ -7,7 +7,7 @@ {{{style_include}}} - +
{{{test}}}
\ No newline at end of file diff --git a/void-be/src/lib.rs b/void-be/src/lib.rs index 0c02e43..07386f2 100644 --- a/void-be/src/lib.rs +++ b/void-be/src/lib.rs @@ -8,14 +8,24 @@ extern crate rocket; /// A module that handles the backend for the site. pub mod web_app_backend { + use std::path::{PathBuf, Path}; + use rocket::fs::FileServer; + use rocket::http::{Cookie, CookieJar}; + use rocket::response::Redirect; use rocket::{Build, Rocket}; use rocket_dyn_templates::{context, Template}; - use void_fe::void_app::{self, PoemRequest, VirtualDom}; + use void_fe::void_app::{self, PoemRequest, VirtualDom, HomeProps}; #[get("/")] - async fn index() -> Template { - let mut vdom = VirtualDom::new(void_app::HomePage); + async fn index(cookies: &CookieJar<'_>) -> Template { + let dark_mode = match cookies.get("dark-mode") { + Some(_) => true, + None => false, + }; + let mut vdom = VirtualDom::new_with_props(void_app::HomePage, HomeProps { + dark_mode: dark_mode, + }); let _ = vdom.rebuild(); let output = dioxus_ssr::render(&vdom); Template::render( @@ -23,17 +33,48 @@ pub mod web_app_backend { context! { app_title: "A Letter to the Void", style_include: "", - test: &output + test: &output, + dark_mode: match dark_mode { + true => "dark", + false => "" + }, }, ) } + #[get("/?set-dark-mode")] + async fn dark_mode_root(cookies: &CookieJar<'_>) -> Redirect { + match cookies.get("dark-mode") { + Some(_) => cookies.remove(Cookie::named("dark-mode")), + None => cookies.add(Cookie::new("dark-mode", "true")), + }; + // let path_str = String::from(Path::new("/").join(path).to_str().expect("valid path")); + // let angy = path_str.as_str().to_owned(); + Redirect::to("/") + } + + #[get("/poem/?set-dark-mode")] + async fn dark_mode(cookies: &CookieJar<'_>, entry: PathBuf) -> Redirect { + match cookies.get("dark-mode") { + Some(_) => cookies.remove(Cookie::named("dark-mode")), + None => cookies.add(Cookie::new("dark-mode", "true")), + }; + let path_str = String::from(Path::new("/poem/").join(entry).to_str().expect("valid path")); + let _angy = path_str.as_str().to_owned(); + Redirect::to(path_str.as_str().to_owned().clone()) + } + #[get("/poem/")] - async fn poem(entry: &str) -> Template { + async fn poem(cookies: &CookieJar<'_>, entry: &str) -> Template { + let dark_mode = match cookies.get("dark-mode") { + Some(_) => true, + None => false, + }; let mut vdom = VirtualDom::new_with_props( void_app::PoemPage, PoemRequest { slug: entry.to_string(), + dark_mode: Some(dark_mode), }, ); let _ = vdom.rebuild(); @@ -43,7 +84,11 @@ pub mod web_app_backend { context! { app_title: "A Letter to the Void", style_include: "", - test: &output + test: &output, + dark_mode: match dark_mode { + true => "dark", + false => "" + }, }, ) } @@ -54,7 +99,7 @@ pub mod web_app_backend { .mount("/images", FileServer::from("public/images")) .mount("/styles", FileServer::from("public/styles")) .mount("/fonts", FileServer::from("public/fonts")) - .mount("/", routes![index, poem]) + .mount("/", routes![dark_mode_root, index, dark_mode, poem]) .attach(Template::fairing()) } } diff --git a/void-fe/src/index.css b/void-fe/src/index.css index 89da347..cef83eb 100644 --- a/void-fe/src/index.css +++ b/void-fe/src/index.css @@ -3,6 +3,6 @@ @tailwind utilities; @font-face { - font-family: "DejaVuSansMono"; - src: url("/fonts/DejaVuSansMono.ttf"); + font-family: "OpenDyslexic"; + src: url("/fonts/OpenDyslexic-Regular.otf"); } diff --git a/void-fe/src/lib.rs b/void-fe/src/lib.rs index ce7b5be..ec9987e 100644 --- a/void-fe/src/lib.rs +++ b/void-fe/src/lib.rs @@ -20,6 +20,12 @@ pub mod void_app { #[derive(PartialEq, Props)] pub struct PoemRequest { pub slug: String, + pub dark_mode: Option, + } + + #[derive(PartialEq, Props)] + pub struct HomeProps { + pub dark_mode: bool, } #[derive(PartialEq, Props)] @@ -28,6 +34,7 @@ pub mod void_app { content: Option, creation_date: Option, slug: Option, + dark_mode: Option, } #[derive(RustEmbed)] @@ -57,16 +64,41 @@ pub mod void_app { } /// Renders the app and returns the rendered Element. - pub fn HomePage(cx: Scope) -> Element { + pub fn HomePage(cx: Scope) -> Element { + let dark_mode = cx.props.dark_mode.clone(); cx.render(rsx!{ div { class: "min-h-screen font-nerd bg-alice-werefox-grey-light dark:bg-alice-werefox-grey", div { class: "container space-y-4 mx-auto p-4", div { class: "p-4 ring-4 bg-alice-werefox-grey-lightest dark:bg-alice-werefox-grey-dark ring-alice-werefox-red-dark dark:ring-alice-werefox-red text-alice-werefox-red-dark dark:text-alice-werefox-red-light", - p { class: "text-lg text-center", - "A Letter to the Void" + p { class: "flex flex-row mx-auto max-w-full justify-center text-lg text-center", + "A Letter to the Void " + a { class: "max-h-sm", + href: "?set-dark-mode", + match dark_mode { + true => { + rsx! { + img { class: "", + src: "/images/white_square_button.png", + alt: "A white square button that can toggle dark mode.", + } + } + }, + false => { + rsx! { + img { class: "", + src: "/images/black_square_button.png", + alt: "A black square button that can toggle dark mode.", + } + } + }, + } + } } } PoemList {} + div { class: "p-4 ring-4 bg-alice-werefox-grey-lightest dark:bg-alice-werefox-grey-dark ring-alice-werefox-red-dark dark:ring-alice-werefox-red text-alice-werefox-red-dark dark:text-alice-werefox-red-light", + "This site uses Mutant Standard emoji, which are licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License" + } } } }) @@ -104,18 +136,20 @@ pub mod void_app { #[cfg(any(target_family = "unix", target_family = "windows"))] pub fn PoemPage(cx: Scope) -> Element { - let slug = cx.props.slug.clone(); + let slug = String::from(cx.props.slug.clone()); + let dark_mode = cx.props.dark_mode.clone().expect("Dark mode prop not passed."); cx.render(rsx!{ div { class: "min-h-screen font-nerd bg-alice-werefox-grey-light dark:bg-alice-werefox-grey", div { class: "container space-y-4 mx-auto p-4", - a { href: "/", - div { class: "p-4 ring-4 bg-alice-werefox-grey-lightest dark:bg-alice-werefox-grey-dark ring-alice-werefox-red-dark dark:ring-alice-werefox-red text-alice-werefox-red-dark dark:text-alice-werefox-red-light hover:text-alice-werefox-blue-dark dark:hover:text-alice-werefox-blue-light hover:ring-alice-werefox-blue dark:hover:ring-alice-werefox-blue hover:animate-yip transition", - p { class: "text-lg text-center", - "Take me back!" + a { href: "/", + div { class: "p-4 ring-4 bg-alice-werefox-grey-lightest dark:bg-alice-werefox-grey-dark ring-alice-werefox-red-dark dark:ring-alice-werefox-red text-alice-werefox-red-dark dark:text-alice-werefox-red-light hover:text-alice-werefox-blue-dark dark:hover:text-alice-werefox-blue-light hover:ring-alice-werefox-blue dark:hover:ring-alice-werefox-blue hover:animate-yip transition", + p { class: "text-lg text-center", + "Take me back!" + } } } + GetPoem { slug: slug, dark_mode: dark_mode } } - GetPoem { slug: slug } } } }) } @@ -127,6 +161,7 @@ pub mod void_app { .segment("slug") .expect("No slug specified."), ); + let dark_mode = cx.props.dark_mode.clone().expect("Dark mode prop not passed."); cx.render(rsx!{ div { class: "min-h-screen font-nerd bg-alice-werefox-grey-light dark:bg-alice-werefox-grey", div { class: "container space-y-4 mx-auto p-4", @@ -137,7 +172,7 @@ pub mod void_app { } } } - GetPoem { slug: slug } + GetPoem { slug: slug, dark_mode: dark_mode } } } }) @@ -174,8 +209,10 @@ pub mod void_app { } fn GetPoem(cx: Scope) -> Element { + let dark_mode = cx.props.dark_mode.clone().expect("Dark mode prop not passed."); + let slug = String::from(cx.props.slug.clone().expect("No slug specified.")); let filename = - String::from(String::from(cx.props.slug.clone().expect("No slug specified.")) + ".md"); + String::from(String::from(slug.clone()) + ".md"); let creation_date = String::from(String::from("
Written on: ") + filename.split("_").next().unwrap()); let poem_content = Poems::get(&filename).expect("Found poem {filename:?}"); @@ -189,30 +226,76 @@ pub mod void_app { let poem_content_to_html_string = markdown::to_html_with_options(poem_content.as_str(), &Options::gfm()).unwrap(); cx.render(rsx!{ - MakePoem{ title: poem_title_to_html_string, content: poem_content_to_html_string, creation_date: creation_date } } + MakePoem{ title: poem_title_to_html_string, content: poem_content_to_html_string, creation_date: creation_date, slug: slug, dark_mode: dark_mode } } ) } #[cfg(any(target_family = "unix", target_family = "windows"))] fn RenderPoemTitle(cx: Scope) -> Element { + let slug = cx.props.slug.clone().expect("Slug prop was not passed."); + let dark_mode = cx.props.dark_mode.clone().expect("Dark mode prop not passed."); let title = cx.props.title.clone().expect("No title specified."); cx.render(rsx!{ span { class: "mx-auto max-w-fit flex justify-center bg-alice-werefox-grey-lightest dark:bg-alice-werefox-grey-dark border-4 border-alice-werefox-red-dark dark:border-alice-werefox-red text-alice-werefox-red-dark dark:text-alice-werefox-red-light p-4", - "{title}" + "{title} " + a { class: "max-h-sm", + href: "/poem/{slug}?set-dark-mode", + match dark_mode { + true => { + rsx! { + img { class: "", + src: "/images/white_square_button.png", + alt: "A white square button that can toggle dark mode.", + } + } + }, + false => { + rsx! { + img { class: "", + src: "/images/black_square_button.png", + alt: "A black square button that can toggle dark mode.", + } + } + }, + } + } } }) } #[cfg(target_family = "wasm")] fn RenderPoemTitle(cx: Scope) -> Element { + let slug = cx.props.slug.clone().expect("Slug prop was not passed."); + let dark_mode = cx.props.dark_mode.clone().expect("Dark mode prop not passed."); let title = cx .props .title .clone() .expect("This poem has an empty title."); cx.render(rsx!{ - p { class: "mx-auto max-w-fit flex justify-center bg-alice-werefox-grey-lightest dark:bg-alice-werefox-grey-dark border-4 border-alice-werefox-red-dark dark:border-alice-werefox-red text-alice-werefox-red-dark dark:text-alice-werefox-red-light p-4", - dangerous_inner_html: "{title}", + p { class: "mx-auto max-w-fit flex flex-row justify-center bg-alice-werefox-grey-lightest dark:bg-alice-werefox-grey-dark border-4 border-alice-werefox-red-dark dark:border-alice-werefox-red text-alice-werefox-red-dark dark:text-alice-werefox-red-light p-4", + dangerous_inner_html: "{title} ", + a { class: "max-h-sm", + href: "/poem/{slug}?set-dark-mode", + match dark_mode { + true => { + rsx! { + img { class: "", + src: "/images/white_square_button.png", + alt: "A white square button that can toggle dark mode.", + } + } + }, + false => { + rsx! { + img { class: "", + src: "/images/black_square_button.png", + alt: "A black square button that can toggle dark mode.", + } + } + }, + } + } } }) } @@ -226,7 +309,8 @@ pub mod void_app { .clone() .expect("No creation date specified."); cx.render(rsx! { - div { class: "font-nerd flex flex-col space-y-4 mx-4 py-4", "{content}{creation_date}" } + div { class: "font-nerd flex flex-col space-y-4 mx-4 py-4", "{content}{creation_date} " + } }) } @@ -247,6 +331,8 @@ pub mod void_app { } fn MakePoem(cx: Scope) -> Element { + let slug = String::from(cx.props.slug.clone().expect("Slug prop was not passed.")); + let dark_mode = cx.props.dark_mode.clone().expect("Dark mode prop not passed."); let title = cx.props.title.clone().expect("No title specified."); let creation_date = cx .props @@ -256,10 +342,9 @@ pub mod void_app { let content = cx.props.content.clone().expect("No content specified."); cx.render(rsx!{ div { class: "flex-col space-y-4", - RenderPoemTitle { title: title.clone() } - details { class: "mx-auto max-w-fit space-y-4 bg-alice-werefox-grey-lightest dark:bg-alice-werefox-grey-dark border-4 border-alice-werefox-red-dark dark:border-alice-werefox-red text-alice-werefox-red-dark dark:text-alice-werefox-red-light p-4", - summary { class: "flex justify-center p-4 ring-4 bg-alice-werefox-grey-lightest dark:bg-alice-werefox-grey-dark ring-alice-werefox-red-dark dark:ring-alice-werefox-red text-alice-werefox-red-dark dark:text-alice-werefox-red-light hover:text-alice-werefox-blue-dark dark:hover:text-alice-werefox-blue-light hover:ring-alice-werefox-blue dark:hover:ring-alice-werefox-blue hover:animate-yip transition", - "Open" + RenderPoemTitle { title: title.clone(), slug: slug, dark_mode: dark_mode } + details { class: "group mx-auto max-w-fit space-y-4 bg-alice-werefox-grey-lightest dark:bg-alice-werefox-grey-dark border-4 border-alice-werefox-red-dark dark:border-alice-werefox-red text-alice-werefox-red-dark dark:text-alice-werefox-red-light p-4", + summary { class: "group-open:before:content-['Close'] before:content-['Open'] flex justify-center p-4 ring-4 bg-alice-werefox-grey-lightest dark:bg-alice-werefox-grey-dark ring-alice-werefox-red-dark dark:ring-alice-werefox-red text-alice-werefox-red-dark dark:text-alice-werefox-red-light hover:text-alice-werefox-blue-dark dark:hover:text-alice-werefox-blue-light hover:ring-alice-werefox-blue dark:hover:ring-alice-werefox-blue hover:animate-yip transition", } RenderPoemElement { content: content.clone(), creation_date: creation_date.clone() } } diff --git a/void-fe/tailwind.config.js b/void-fe/tailwind.config.js index 33be8a5..ae8a8e1 100644 --- a/void-fe/tailwind.config.js +++ b/void-fe/tailwind.config.js @@ -8,7 +8,7 @@ module.exports = { theme: { extend: { fontFamily: { - nerd: ["DejaVuSansMono"], + nerd: ["OpenDyslexic"], }, colors: { "ada-werefox-cyan": { @@ -105,5 +105,6 @@ module.exports = { }, }, }, + darkMode: 'class', plugins: [], };