feat: replace in-footer scroll-to-top link with fixed floating button

This commit is contained in:
xfy 2026-06-04 17:55:26 +08:00
parent 0dbd07198b
commit 245fd83ec8
2 changed files with 23 additions and 23 deletions

View File

@ -66,8 +66,8 @@ pub fn Footer() -> Element {
} }
}); });
let link_class = use_memo(move || { let btn_class = use_memo(move || {
let base = "p-2 rounded-full cursor-pointer hover:opacity-80 transition-all duration-300 text-gray-600 dark:text-gray-300"; let base = "fixed bottom-16 right-8 z-50 w-10 h-10 rounded-full bg-gray-100 dark:bg-[#2d2e30] shadow-md flex items-center justify-center cursor-pointer transition-all duration-300 text-gray-600 dark:text-gray-300 hover:text-gray-900 dark:hover:text-white";
if visible() { if visible() {
format!("{} opacity-100 translate-y-0", base) format!("{} opacity-100 translate-y-0", base)
} else { } else {
@ -79,8 +79,10 @@ pub fn Footer() -> Element {
footer { class: "w-full border-t border-gray-200 dark:border-[#333] mt-auto", footer { class: "w-full border-t border-gray-200 dark:border-[#333] mt-auto",
div { class: "max-w-3xl mx-auto px-6 py-5 flex items-center justify-between text-sm text-gray-400 dark:text-[#9b9c9d]", div { class: "max-w-3xl mx-auto px-6 py-5 flex items-center justify-between text-sm text-gray-400 dark:text-[#9b9c9d]",
span { "© 2026 Yggdrasil Blog" } span { "© 2026 Yggdrasil Blog" }
}
}
a { a {
class: "{link_class}", class: "{btn_class}",
href: "#top", href: "#top",
aria_label: "go to top", aria_label: "go to top",
title: "Go to Top (Alt + G)", title: "Go to Top (Alt + G)",
@ -102,8 +104,6 @@ pub fn Footer() -> Element {
} }
} }
} }
}
}
fn scroll_to_top() { fn scroll_to_top() {
#[cfg(target_arch = "wasm32")] #[cfg(target_arch = "wasm32")]