From 2bed0c7f03ee481e06fa8ba2792666c765d82c09 Mon Sep 17 00:00:00 2001 From: Lim Chee Aun Date: Tue, 10 Jan 2023 10:44:16 +0800 Subject: [PATCH] Add Experimental scroll to top button for status page --- src/pages/status.css | 8 ++++++++ src/pages/status.jsx | 30 +++++++++++++++++++++++++++++- 2 files changed, 37 insertions(+), 1 deletion(-) diff --git a/src/pages/status.css b/src/pages/status.css index fe827489..032862f3 100644 --- a/src/pages/status.css +++ b/src/pages/status.css @@ -31,3 +31,11 @@ .hero-heading .insignificant { font-weight: normal; } + +.ancestors-indicator { + font-size: 70% !important; +} +.ancestors-indicator[hidden] { + opacity: 0; + pointer-events: none; +} diff --git a/src/pages/status.jsx b/src/pages/status.jsx index abfd9a4c..4ebf2c98 100644 --- a/src/pages/status.jsx +++ b/src/pages/status.jsx @@ -17,6 +17,7 @@ import shortenNumber from '../utils/shorten-number'; import states, { saveStatus } from '../utils/states'; import store from '../utils/store'; import useDebouncedCallback from '../utils/useDebouncedCallback'; +import useScroll from '../utils/useScroll'; import useTitle from '../utils/useTitle'; const LIMIT = 40; @@ -278,6 +279,7 @@ function StatusPage({ id }) { const hasManyStatuses = statuses.length > LIMIT; const hasDescendants = statuses.some((s) => s.descendant); + const ancestors = statuses.filter((s) => s.ancestor); const [heroInView, setHeroInView] = useState(true); const onView = useDebouncedCallback(setHeroInView, 100); @@ -292,6 +294,10 @@ function StatusPage({ id }) { location.hash = closeLink; }); + const { nearReachTop } = useScroll({ + scrollableElement: scrollableRef.current, + }); + return (
@@ -345,7 +351,29 @@ function StatusPage({ id }) { ) : ( - 'Status' + <> + Status{' '} + + )}