mirror of
https://github.com/prometheus/prometheus.git
synced 2024-12-25 13:44:05 -08:00
Add "Scroll to Top" component
Signed-off-by: Julius Volz <julius.volz@gmail.com>
This commit is contained in:
parent
6ff7857313
commit
e29ad4a83b
|
@ -7,6 +7,7 @@ import PrometheusLogo from "./images/prometheus-logo.svg";
|
|||
|
||||
import {
|
||||
ActionIcon,
|
||||
Affix,
|
||||
AppShell,
|
||||
Box,
|
||||
Burger,
|
||||
|
@ -16,12 +17,14 @@ import {
|
|||
Menu,
|
||||
Skeleton,
|
||||
Text,
|
||||
Transition,
|
||||
createTheme,
|
||||
rem,
|
||||
} from "@mantine/core";
|
||||
import { useDisclosure } from "@mantine/hooks";
|
||||
import { useDisclosure, useWindowScroll } from "@mantine/hooks";
|
||||
import {
|
||||
IconAdjustments,
|
||||
IconArrowUp,
|
||||
IconBellFilled,
|
||||
IconChevronDown,
|
||||
IconChevronRight,
|
||||
|
@ -169,6 +172,7 @@ const navLinkIconSize = 15;
|
|||
const navLinkXPadding = "md";
|
||||
|
||||
function App() {
|
||||
const [scroll, scrollTo] = useWindowScroll();
|
||||
const [opened, { toggle }] = useDisclosure();
|
||||
const { agentMode } = useContext(SettingsContext);
|
||||
|
||||
|
@ -373,6 +377,23 @@ function App() {
|
|||
</Routes>
|
||||
</Suspense>
|
||||
</ErrorBoundary>
|
||||
<Affix position={{ bottom: 20, right: 20 }}>
|
||||
<Transition transition="slide-up" mounted={scroll.y > 0}>
|
||||
{(transitionStyles) => (
|
||||
<Button
|
||||
leftSection={
|
||||
<IconArrowUp
|
||||
style={{ width: rem(16), height: rem(16) }}
|
||||
/>
|
||||
}
|
||||
style={transitionStyles}
|
||||
onClick={() => scrollTo({ y: 0 })}
|
||||
>
|
||||
Scroll to top
|
||||
</Button>
|
||||
)}
|
||||
</Transition>
|
||||
</Affix>
|
||||
</AppShell.Main>
|
||||
</AppShell>
|
||||
{/* <ReactQueryDevtools initialIsOpen={false} /> */}
|
||||
|
|
Loading…
Reference in a new issue