From 9cb902978b97374d2000644e1b7e8f4fec0c4a50 Mon Sep 17 00:00:00 2001 From: Ada Werefox Date: Mon, 17 Apr 2023 12:34:20 -0500 Subject: [PATCH] Updated implementation of theme configuration from user preferences, applied to title. --- public/styles/tailwind.min.css | 2 +- void-fe/src/components/void_buttons.rs | 12 ++- void-fe/src/components/void_content.rs | 2 +- void-fe/src/components/void_footer.rs | 4 +- void-fe/src/components/void_page.rs | 2 +- void-fe/src/components/void_poem.rs | 2 +- void-fe/src/components/void_title.rs | 4 +- void-fe/src/lib.rs | 20 +++- void-fe/src/utils/user_prefs.rs | 127 +++++++++++++++++-------- 9 files changed, 117 insertions(+), 58 deletions(-) diff --git a/public/styles/tailwind.min.css b/public/styles/tailwind.min.css index b241fc2..9e98ad8 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-auto{margin-left:auto;margin-right:auto}.ml-2{margin-left:.5rem}.mr-2{margin-right:.5rem}.flex{display:flex}.grid{display:grid}.hidden{display:none}.max-w-fit{max-width:-moz-fit-content;max-width:fit-content}.max-w-full{max-width:100%}.grid-flow-row{grid-auto-flow:row}.flex-row{flex-direction:row}.flex-col{flex-direction:column}.justify-center{justify-content:center}.gap-y-4{row-gap:1rem}.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))}.bg-alice-werefox-grey-dark{--tw-bg-opacity:1;background-color:rgb(18 18 18/var(--tw-bg-opacity))}.bg-alice-werefox-grey-lightest{--tw-bg-opacity:1;background-color:rgb(238 238 238/var(--tw-bg-opacity))}.p-2{padding:.5rem}.p-4{padding:1rem}.py-4{padding-top:1rem;padding-bottom:1rem}.text-center{text-align:center}.align-middle{vertical-align:middle}.font-nerd{font-family:DejaVuSansMono}.font-open{font-family:OpenDyslexic}.text-xl{font-size:1.25rem;line-height:1.75rem}.text-alice-werefox-grey-dark{--tw-text-opacity:1;color:rgb(18 18 18/var(--tw-text-opacity))}.text-alice-werefox-grey-light{--tw-text-opacity:1;color:rgb(204 204 204/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{--tw-ring-opacity:1;--tw-ring-color:rgb(201 52 57/var(--tw-ring-opacity))}.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)}@font-face{font-family:DejaVuSansMono;src:url(/fonts/DejaVuSansMono.ttf)}.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\:text-alice-werefox-blue-light:hover{--tw-text-opacity:1;color:rgb(145 151 243/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)}@media (prefers-color-scheme:dark){.dark\:bg-alice-werefox-grey-dark{--tw-bg-opacity:1;background-color:rgb(18 18 18/var(--tw-bg-opacity))}.dark\:text-alice-werefox-grey-light{--tw-text-opacity:1;color:rgb(204 204 204/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))}}@media (min-width:768px){.md\:grid-flow-col{grid-auto-flow:column}} \ 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-auto{margin-left:auto;margin-right:auto}.ml-2{margin-left:.5rem}.mr-2{margin-right:.5rem}.flex{display:flex}.grid{display:grid}.hidden{display:none}.min-h-screen{min-height:100vh}.max-w-fit{max-width:-moz-fit-content;max-width:fit-content}.max-w-full{max-width:100%}.grid-flow-row{grid-auto-flow:row}.flex-row{flex-direction:row}.flex-col{flex-direction:column}.justify-center{justify-content:center}.gap-y-4{row-gap:1rem}.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))}.bg-alice-werefox-grey{--tw-bg-opacity:1;background-color:rgb(36 36 36/var(--tw-bg-opacity))}.bg-alice-werefox-grey-dark{--tw-bg-opacity:1;background-color:rgb(18 18 18/var(--tw-bg-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-2{padding:.5rem}.p-4{padding:1rem}.py-4{padding-top:1rem;padding-bottom:1rem}.text-center{text-align:center}.align-middle{vertical-align:middle}.font-nerd{font-family:DejaVuSansMono}.font-open{font-family:OpenDyslexic}.text-lg{font-size:1.125rem}.text-lg,.text-xl{line-height:1.75rem}.text-xl{font-size:1.25rem}.text-alice-werefox-grey-dark{--tw-text-opacity:1;color:rgb(18 18 18/var(--tw-text-opacity))}.text-alice-werefox-grey-light{--tw-text-opacity:1;color:rgb(204 204 204/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{--tw-ring-opacity:1;--tw-ring-color:rgb(201 52 57/var(--tw-ring-opacity))}.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)}@font-face{font-family:DejaVuSansMono;src:url(/fonts/DejaVuSansMono.ttf)}.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\:text-alice-werefox-blue-light:hover{--tw-text-opacity:1;color:rgb(145 151 243/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)}@media (prefers-color-scheme:dark){.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-grey-light{--tw-text-opacity:1;color:rgb(204 204 204/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))}}@media (min-width:768px){.md\:grid-flow-col{grid-auto-flow:column}.md\:pl-8{padding-left:2rem}.md\:pr-8{padding-right:2rem}} \ No newline at end of file diff --git a/void-fe/src/components/void_buttons.rs b/void-fe/src/components/void_buttons.rs index 363b94e..2f5df72 100644 --- a/void-fe/src/components/void_buttons.rs +++ b/void-fe/src/components/void_buttons.rs @@ -7,7 +7,8 @@ use dioxus_router::Link; pub fn BackToHomePage(cx: Scope) -> Element { #[cfg(any(target_family = "windows", target_family = "unix"))] return cx.render(rsx!{ - a {href: "/", + a { class: "flex justify-center p-4 text-xl text-center ring-2", + href: "/", p { "Back to the homepage" } @@ -15,7 +16,8 @@ pub fn BackToHomePage(cx: Scope) -> Element { }); #[cfg(target_family = "wasm")] return cx.render(rsx!{ - Link { to: "/", + Link { class: "flex justify-center p-4 text-xl text-center ring-2", + to: "/", p { "Back to the homepage" } @@ -30,13 +32,15 @@ pub fn NavigationButton(cx: Scope) -> Element { let slug_ref = slug.as_str(); #[cfg(any(target_family = "windows", target_family = "unix"))] return cx.render(rsx!{ - a { href: "{slug_ref}", + a { class: "flex mx-auto max-w-full justify-center p-4 ml-2 mr-2 text-xl text-center ring-2", + href: "{slug_ref}", "{title_ref}" } }); #[cfg(target_family = "wasm")] return cx.render(rsx!{ - Link { to: "{slug_ref}", + Link { class: "flex mx-auto max-w-full justify-center p-4 ml-2 mr-2 text-xl text-center ring-2", + to: "{slug_ref}", div { dangerous_inner_html: "{title_ref}", } diff --git a/void-fe/src/components/void_content.rs b/void-fe/src/components/void_content.rs index 5f0c109..4c17227 100644 --- a/void-fe/src/components/void_content.rs +++ b/void-fe/src/components/void_content.rs @@ -6,7 +6,7 @@ pub fn RenderContent(cx: Scope) -> Element { let content = &cx.props.content; #[cfg(any(target_family = "windows", target_family = "unix"))] return cx.render(rsx!{ - div { class: "flex p-4 ml-2 mr-2 ring-4", + div { class: "flex p-4 md:pl-8 md:pr-8 ml-2 mr-2 text-lg text-center ring-4", "{content}", } }); diff --git a/void-fe/src/components/void_footer.rs b/void-fe/src/components/void_footer.rs index 27a1842..e657110 100644 --- a/void-fe/src/components/void_footer.rs +++ b/void-fe/src/components/void_footer.rs @@ -9,9 +9,9 @@ pub fn Footer(cx: Scope) -> Element { fn MutantStandardFooter(cx: Scope) -> Element { cx.render(rsx!{ - div { + div { class: "p-4 flex flex-col space-y-4 mx-auto max-w-full justify-center ring-4", NavigationButton { title: "⚙️".to_string(), slug: "/settings".to_string() } - div { + div { class: "flex mx-auto max-w-full justify-center text-md text-center", "This site uses Mutant Standard emoji, which are licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License" } } diff --git a/void-fe/src/components/void_page.rs b/void-fe/src/components/void_page.rs index 2f252c2..fb81a19 100644 --- a/void-fe/src/components/void_page.rs +++ b/void-fe/src/components/void_page.rs @@ -4,7 +4,7 @@ use dioxus::prelude::*; pub fn PageBase<'a>(cx: Scope<'a, PageChildren<'a>>) -> Element { cx.render(rsx!{ // div { class: "bg-alice-werefox-grey-lightest ring-alice-werefox-red-dark text-alice-werefox-grey-dark dark:bg-alice-werefox-grey-dark dark:ring-alice-werefox-red dark:text-alice-werefox-grey-light let button_classes hover:text-alice-werefox-blue-dark hover:ring-alice-werefox-blue dark:hover:text-alice-werefox-blue-light dark:hover:ring-alice-werefox-blue hover:animate-yip transition", hidden: true } - div { + div { class: "min-h-screen", div { class: "container space-y-4 mx-auto p-4", &cx.props.children } diff --git a/void-fe/src/components/void_poem.rs b/void-fe/src/components/void_poem.rs index d299fee..807743b 100644 --- a/void-fe/src/components/void_poem.rs +++ b/void-fe/src/components/void_poem.rs @@ -48,7 +48,7 @@ pub fn PoemContent(cx: Scope) -> Element { #[cfg(any(target_family = "unix", target_family = "windows"))] return cx.render(rsx! { div { class: "flex p-2 mx-auto max-w-full justify-center", - details { class: "group p-4 max-w-fit space-y-4", + details { class: "group p-4 max-w-fit space-y-4 ring-4", summary { class: "group-open:before:content-['Close'] before:content-['Open'] flex justify-center p-2 ring-2", } div { class: "font-nerd flex flex-col space-y-4 py-4", "{content}{creation_date}" diff --git a/void-fe/src/components/void_title.rs b/void-fe/src/components/void_title.rs index 752c5bc..773e685 100644 --- a/void-fe/src/components/void_title.rs +++ b/void-fe/src/components/void_title.rs @@ -1,12 +1,14 @@ use crate::utils::prop_structs::TitleProps; +use super::super::utils::user_prefs::ThemedComponent; use dioxus::prelude::*; pub fn Title(cx: Scope) -> Element { let user_prefs = cx.props.user_prefs.clone(); + let title_classes = user_prefs.get_theme_classes(ThemedComponent::Card); let title = cx.props.title.clone(); let is_html = cx.props.is_html; cx.render(rsx!{ - div { class: "p-4 ring-4", + div { class: "p-4 ring-4 {title_classes}", span { class: "flex flex-row mx-auto max-w-full justify-center text-xl text-center", TitleHtml { title: title, is_html: is_html, user_prefs: user_prefs } } diff --git a/void-fe/src/lib.rs b/void-fe/src/lib.rs index bef6bf7..9fbe3c2 100644 --- a/void-fe/src/lib.rs +++ b/void-fe/src/lib.rs @@ -64,10 +64,20 @@ pub mod void_app { /// Renders the app and returns the rendered Element. pub fn HomePage(cx: Scope) -> Element { let user_prefs = cx.props.clone(); - let (user_theme, user_font) = user_prefs.get_prefs(false); + let (user_theme, user_font) = user_prefs.get_prefs(ThemedComponent::Page); let title = "A Letter to the Void".to_string(); cx.render(rsx!{ - // div { class: "bg-alice-werefox-grey-lightest ring-alice-werefox-red-dark text-alice-werefox-grey-dark dark:bg-alice-werefox-grey-dark dark:ring-alice-werefox-red dark:text-alice-werefox-grey-light let button_classes hover:text-alice-werefox-blue-dark hover:ring-alice-werefox-blue dark:hover:text-alice-werefox-blue-light dark:hover:ring-alice-werefox-blue hover:animate-yip transition", hidden: true } + // class: "bg-alice-werefox-grey-light dark:bg-alice-werefox-grey" + // class: "bg-alice-werefox-grey" + // class: "bg-alice-werefox-grey-lightest ring-alice-werefox-red-dark text-alice-werefox-grey-dark" + // class: "dark:bg-alice-werefox-grey-dark dark:ring-alice-werefox-red dark:text-alice-werefox-grey-light" + // class: "bg-alice-werefox-grey-dark ring-alice-werefox-red text-alice-werefox-grey-light" + // class: "bg-alice-werefox-grey-lightest ring-alice-werefox-red-dark text-alice-werefox-grey-dark" + // class: "hover:text-alice-werefox-blue-dark" + // class: "hover:ring-alice-werefox-blue dark:bg-alice-werefox-grey-dark dark:ring-alice-werefox-red" + // class: "bg-alice-werefox-grey-dark ring-alice-werefox-red" + // class: "dark:text-alice-werefox-grey-light dark:hover:text-alice-werefox-blue-light dark:hover:ring-alice-werefox-blue" + // class: "text-alice-werefox-grey-light hover:text-alice-werefox-blue-light hover:ring-alice-werefox-blue" div { class: "{user_theme} {user_font}", PageBase { Title { title: title, is_html: false, user_prefs: user_prefs } @@ -86,7 +96,7 @@ pub mod void_app { /// Renders the app and returns the rendered Element. pub fn PoemListPage(cx: Scope) -> Element { let user_prefs = cx.props.clone(); - let (user_theme, user_font) = user_prefs.get_prefs(false); + let (user_theme, user_font) = user_prefs.get_prefs(ThemedComponent::Page); cx.render(rsx! { div { class: "{user_theme} {user_font}", PageBase { @@ -102,7 +112,7 @@ pub mod void_app { pub fn PoemPage(cx: Scope) -> Element { let user_prefs = cx.props.user_prefs.clone(); - let (user_theme, user_font) = user_prefs.get_prefs(false); + let (user_theme, user_font) = user_prefs.get_prefs(ThemedComponent::Page); #[cfg(any(target_family = "unix", target_family = "windows"))] let slug = cx.props.slug.clone(); #[cfg(target_family = "wasm")] @@ -131,7 +141,7 @@ pub mod void_app { pub fn SettingsPage(cx: Scope) -> Element { let user_prefs = cx.props.clone(); - let (user_theme, user_font) = user_prefs.get_prefs(false); + let (user_theme, user_font) = user_prefs.get_prefs(ThemedComponent::Page); cx.render(rsx! { div { class: "{user_theme} {user_font}", PageBase { diff --git a/void-fe/src/utils/user_prefs.rs b/void-fe/src/utils/user_prefs.rs index d1d2cb5..d674d67 100644 --- a/void-fe/src/utils/user_prefs.rs +++ b/void-fe/src/utils/user_prefs.rs @@ -19,19 +19,95 @@ pub enum FontPref { OpenDyslexic, } +pub enum ThemedComponent { + Page, + Card, + Button, +} + impl UserPrefs { + // TailwindCSS has a difficult time determining which classes we'll need for our site, + // the easiest way to fix this is to simply list all of them our in commented out class + // attributes, so all of these we *will* use, and TailwindCSS will know to compile them. + // class: "bg-alice-werefox-grey-light dark:bg-alice-werefox-grey" + // class: "bg-alice-werefox-grey" + // class: "bg-alice-werefox-grey-lightest ring-alice-werefox-red-dark text-alice-werefox-grey-dark" + // class: "dark:bg-alice-werefox-grey-dark dark:ring-alice-werefox-red dark:text-alice-werefox-grey-light" + // class: "bg-alice-werefox-grey-dark ring-alice-werefox-red text-alice-werefox-grey-light" + // class: "bg-alice-werefox-grey-lightest ring-alice-werefox-red-dark text-alice-werefox-grey-dark" + // class: "hover:text-alice-werefox-blue-dark" + // class: "hover:ring-alice-werefox-blue dark:bg-alice-werefox-grey-dark dark:ring-alice-werefox-red" + // class: "bg-alice-werefox-grey-dark ring-alice-werefox-red" + // class: "dark:text-alice-werefox-grey-light dark:hover:text-alice-werefox-blue-light dark:hover:ring-alice-werefox-blue" + // class: "text-alice-werefox-grey-light hover:text-alice-werefox-blue-light hover:ring-alice-werefox-blue" + + const PAGE_CLASSES: &str = "bg-alice-werefox-grey-light dark:bg-alice-werefox-grey"; + const CARD_CLASSES: &str = "bg-alice-werefox-grey-lightest ring-alice-werefox-red-dark text-alice-werefox-grey-dark dark:bg-alice-werefox-grey-dark dark:ring-alice-werefox-red dark:text-alice-werefox-grey-light"; + const BUTTON_CLASSES: &str = "bg-alice-werefox-grey-lightest ring-alice-werefox-red-dark text-alice-werefox-grey-dark hover:text-alice-werefox-blue-dark hover:ring-alice-werefox-blue dark:bg-alice-werefox-grey-dark dark:ring-alice-werefox-red dark:text-alice-werefox-grey-light dark:hover:text-alice-werefox-blue-light dark:hover:ring-alice-werefox-blue"; + pub fn new(theme: ThemePref, font: FontPref) -> UserPrefs { - UserPrefs { - theme, - font, + UserPrefs { theme, font } + } + + // I'm really about to write a ceil() function because I refuse to force devs to use Nightly + fn ceil(n: usize) -> usize { + if n.rem_euclid(2) == 0 { + n / 2 + } else { + n - 1 / 2 } } - pub fn get_theme(&self, is_button: bool) -> String { + pub fn get_theme_classes(&self, component: ThemedComponent) -> String { match &self.theme { - ThemePref::Light => Self::light_theme_classes(is_button), - ThemePref::Dark => Self::dark_theme_classes(is_button), - ThemePref::Auto => Self::auto_theme_classes(is_button), + ThemePref::Light => match component { + ThemedComponent::Page => Self::PAGE_CLASSES + .split_at(Self::ceil(Self::PAGE_CLASSES.len() / 2)) + .0 + .to_string(), + ThemedComponent::Card => Self::CARD_CLASSES + .split_at(Self::ceil(Self::CARD_CLASSES.len() / 2)) + .0 + .to_string(), + ThemedComponent::Button => Self::BUTTON_CLASSES + .split_at(Self::ceil(Self::BUTTON_CLASSES.len() / 2)) + .0 + .to_string(), + }, + ThemePref::Dark => match component { + ThemedComponent::Page => { + let remove_dark_tags = Self::PAGE_CLASSES.split("dark:").collect::(); + let split_whitespace = remove_dark_tags.as_str().split(" "); + let split_whitespace_length = split_whitespace.clone().count(); + split_whitespace + .skip(Self::ceil(split_whitespace_length / 2)) + .map(|e| format!("{e} ")) + .collect::() + } + ThemedComponent::Card => { + let remove_dark_tags = Self::CARD_CLASSES.split("dark:").collect::(); + let split_whitespace = remove_dark_tags.as_str().split(" "); + let split_whitespace_length = split_whitespace.clone().count(); + split_whitespace + .skip(Self::ceil(split_whitespace_length / 2)) + .map(|e| format!("{e} ")) + .collect::() + } + ThemedComponent::Button => { + let remove_dark_tags = Self::BUTTON_CLASSES.split("dark:").collect::(); + let split_whitespace = remove_dark_tags.as_str().split(" "); + let split_whitespace_length = split_whitespace.clone().count(); + split_whitespace + .skip(Self::ceil(split_whitespace_length / 2)) + .map(|e| format!("{e} ")) + .collect::() + } + }, + ThemePref::Auto => match component { + ThemedComponent::Page => Self::PAGE_CLASSES.to_string(), + ThemedComponent::Card => Self::CARD_CLASSES.to_string(), + ThemedComponent::Button => Self::BUTTON_CLASSES.to_string(), + }, } } @@ -50,8 +126,8 @@ impl UserPrefs { self.font = font; } - pub fn get_prefs(&self, is_button: bool) -> (String, String) { - let theme = self.get_theme(is_button).clone(); + pub fn get_prefs(&self, component: ThemedComponent) -> (String, String) { + let theme = self.get_theme_classes(component).clone(); let font = self.get_font().clone(); (theme, font) } @@ -60,37 +136,4 @@ impl UserPrefs { self.theme = prefs.theme; self.font = prefs.font; } - - fn light_theme_classes(is_button: bool) -> String { - let base_classes = "bg-alice-werefox-grey-lightest ring-alice-werefox-red-dark text-alice-werefox-grey-dark" - .to_string(); - let button_classes = "hover:text-alice-werefox-blue-dark hover:ring-alice-werefox-blue hover:animate-yip transition".to_string(); - if is_button { - return format!("{base_classes} {button_classes}"); - } - base_classes - } - fn dark_theme_classes(is_button: bool) -> String { - let base_classes = - "bg-alice-werefox-grey-dark ring-alice-werefox-red text-alice-werefox-grey-light" - .to_string(); - let button_classes = "hover:text-alice-werefox-blue-light hover:ring-alice-werefox-blue hover:animate-yip transition".to_string(); - if is_button { - return format!("{base_classes} {button_classes}"); - } - base_classes - } - fn auto_theme_classes(is_button: bool) -> String { - format!( - "{} {}", - Self::light_theme_classes(is_button) - .split(" ") - .map(|c| if c == "transition" { "".to_string() } else { format!("{c} ") }) - .collect::(), - Self::dark_theme_classes(is_button) - .split(" ") - .map(|c| format!(" dark:{c}")) - .collect::() - ) - } }