Skip to content

Commit

Permalink
adds back to top button [Fixes #12194]
Browse files Browse the repository at this point in the history
  • Loading branch information
Alex Little committed May 6, 2024
1 parent 0606560 commit 5150a38
Show file tree
Hide file tree
Showing 2 changed files with 73 additions and 26 deletions.
76 changes: 50 additions & 26 deletions src/components/Footer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ import Translation from "@/components/Translation"

import { getLocaleTimestamp } from "@/lib/utils/time"

import { GoToTopButton } from "./GoToTopButton"

const socialLinks = [
{
icon: FaGithub,
Expand Down Expand Up @@ -336,34 +338,56 @@ const Footer = ({ lastDeployDate }: FooterProps) => {
alignItems="center"
flexWrap="wrap"
>
<GoToTopButton />

{lastDeployDate && (
<Text>
<Translation id="website-last-updated" />:{" "}
{getLocaleTimestamp(locale as Lang, lastDeployDate)}
</Text>
)}
<Box my={4}>
{socialLinks.map(({ to, ariaLabel, icon }) => (
<BaseLink
key={to}
href={to}
hideArrow
color="body.base"
aria-label={ariaLabel}
ms="4"
_focus={{ color: "primary.base" }}
<>
<Text
fontSize="sm"
fontStyle="italic"
color="body.medium"
m="auto"
display={{ base: "none", md: "block" }}
>
<Icon
as={icon}
_hover={{
transition:
"color 0.2s ease-in-out, transform 0.2s ease-in-out",
}}
fontSize="4xl"
/>
</BaseLink>
))}
</Box>
<Translation id="website-last-updated" />:{" "}
{getLocaleTimestamp(locale as Lang, lastDeployDate)}
</Text>

<Box my={4}>
{socialLinks.map(({ to, ariaLabel, icon }) => (
<BaseLink
key={to}
href={to}
hideArrow
color="body.base"
aria-label={ariaLabel}
ms="4"
_focus={{ color: "primary.base" }}
>
<Icon
as={icon}
_hover={{
transition:
"color 0.2s ease-in-out, transform 0.2s ease-in-out",
}}
fontSize="4xl"
/>
</BaseLink>
))}
</Box>

<Text
fontSize="sm"
fontStyle="italic"
color="body.medium"
m="auto"
display={{ base: "block", md: "none" }}
>
<Translation id="website-last-updated" />:
{getLocaleTimestamp(locale as Lang, lastDeployDate)}
</Text>
</>
)}
</Flex>
<SimpleGrid
gap={4}
Expand Down
23 changes: 23 additions & 0 deletions src/components/GoToTopButton.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import { memo } from "react"
import { IoChevronUpSharp } from "react-icons/io5"

import { Button } from "./Buttons"

const scrollToTop = () => {
window.scrollTo({ top: 0, behavior: "smooth" })
}

export const GoToTopButton = memo(() => {
return (
<Button
leftIcon={<IoChevronUpSharp />}
variant="outline"
isSecondary
onClick={scrollToTop}
>
Go to top
</Button>
)
})

GoToTopButton.displayName = "GoToTopButton"

0 comments on commit 5150a38

Please sign in to comment.