Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a back 'to top' button in the footer#2609 #2675

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions sanityv3/schemas/textSnippets.ts
Original file line number Diff line number Diff line change
Expand Up @@ -327,6 +327,11 @@ const snippets: textSnippet = {
defaultValue: 'Submit Form',
group: groups.pensionForm,
},
footer_to_top_button: {
title: 'To top button',
defaultValue: 'To top',
group: groups.others,
},
career_fair_form_organisation: {
title: 'Organisation',
defaultValue: 'School / Organisation',
Expand Down
16 changes: 13 additions & 3 deletions web/pageComponents/shared/Footer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ import { forwardRef } from 'react'
import { Facebook, Instagram, Linkedin, Twitter, Youtube } from '../../icons'
import type { FooterLinkData, SomeType, FooterColumns } from '../../types/index'
import { default as NextLink } from 'next/link'
import { useIntl } from 'react-intl'
import { LinkButton } from '@core/Button'

function getSomeSvg(someType: SomeType) {
const iconMap = {
Expand All @@ -12,9 +14,8 @@ function getSomeSvg(someType: SomeType) {
youtube: <Youtube width={24} />,
}

if (!(someType in iconMap)) console.warn('Unable to get social icon for footer: Unknown SoMe type passed')

return iconMap[someType] || null
if (!(someType in iconMap)) console.warn('Unable to get social icon for footer: Unknown SoMe type passed')
return iconMap[someType] || null
}

function getLink(linkData: FooterLinkData) {
Expand All @@ -27,6 +28,7 @@ type FooterProps = {
}

const Footer = forwardRef<HTMLDivElement, FooterProps>(function Footer({ footerData, ...rest }, ref) {
const intl = useIntl()
return (
<footer className="min-h-12 clear-both text-white-100 bg-slate-blue-95 py-4 px-0" ref={ref} {...rest}>
<div className="flex flex-row flex-wrap my-0 mx-auto justify-between px-layout-sm pb-2 max-w-screen-2xl max-md:flex-col">
Expand Down Expand Up @@ -60,6 +62,14 @@ const Footer = forwardRef<HTMLDivElement, FooterProps>(function Footer({ footerD
</div>
</section>
))}
<section
className="flex flex-col max-md:py-4 max-md:w-4/5">
<LinkButton
onClick={() => window.scrollTo({ top: 0, behavior: 'smooth' })}
className={`group text-sm px-0 py-2 text-white-100 underline underline-offset-8 hover:underline hover:text-moss-green-90`} >
{intl.formatMessage({ id: 'footer_to_top_button', defaultMessage: 'To top' })}
</LinkButton>
</section>
</div>
<div className="flex md:justify-center justify-start pl-4 pt-12 pb-3">
<span className="text-2xs text-white-100">Copyright {new Date().getFullYear()} Equinor ASA</span>
Expand Down
Loading