feat(SW-2144): added back-to-top button on destination map views

Approved-by: Matilda Landström
This commit is contained in:
Erik Tiekstra
2025-05-28 08:54:27 +00:00
parent 42701739a0
commit bb5e7b65bb
9 changed files with 81 additions and 64 deletions

View File

@@ -1,38 +1,33 @@
.backToTopButton {
border-radius: var(--Corner-radius-rounded);
display: inline-flex;
padding: var(--Space-x1);
justify-content: center;
align-items: center;
gap: var(--Space-x05);
width: max-content;
color: var(--Component-Button-Brand-Secondary-On-fill-Default);
background-color: var(--Component-Button-Brand-Secondary-Fill-Inverted);
border: 2px solid var(--Component-Button-Brand-Secondary-Border-Default);
border-radius: var(--Corner-radius-Rounded);
box-shadow: 0px 0px 8px 3px rgba(0, 0, 0, 0.1);
cursor: pointer;
display: flex;
align-items: flex-end;
position: fixed;
bottom: 20px;
z-index: var(--back-to-top-button);
background-color: var(--Base-Surface-Primary-light-Normal);
color: var(--Base-Button-Secondary-On-Fill-Normal);
border: 2px solid var(--Base-Button-Secondary-On-Fill-Normal);
gap: var(--Spacing-x-half);
padding: var(--Spacing-x1);
text-align: center;
transition:
background-color 300ms ease,
color 300ms ease;
font-family: var(--typography-Body-Bold-fontFamily);
font-weight: 500;
font-size: var(--typography-Caption-Bold-fontSize);
line-height: var(--typography-Caption-Bold-lineHeight);
letter-spacing: 0.084px;
text-decoration: none;
}
position: sticky;
bottom: var(--Space-x2);
.backToTopButtonText {
display: none;
&:hover {
color: var(--Component-Button-Brand-Secondary-On-fill-Inverted);
background-color: var(
--Component-Button-Brand-Secondary-Fill-Hover-Inverted
);
}
}
.left {
left: 32px;
left: 0;
}
.right {
right: 32px;
left: 100%;
}
.center {
@@ -40,18 +35,14 @@
transform: translateX(-50%);
}
@media (min-width: 768px) {
.backToTopButtonText {
display: initial;
}
.backToTopButton:hover {
background-color: var(--Base-Button-Tertiary-Fill-Normal);
color: var(--Base-Button-Tertiary-On-Fill-Hover);
}
.backToTopButton:hover > svg * {
fill: var(--Base-Button-Tertiary-On-Fill-Hover);
}
.backToTopButton {
padding: calc(var(--Spacing-x1) + 2px) var(--Spacing-x2);
@media screen and (max-width: 767px) {
.text {
display: none;
}
}
@media screen and (min-width: 768px) {
.backToTopButton {
padding: 10px var(--Space-x2);
}
}

View File

@@ -0,0 +1,9 @@
import type { VariantProps } from "class-variance-authority"
import type { ComponentProps } from "react"
import type { Button } from "react-aria-components"
import type { backToTopButtonVariants } from "./variants"
export interface BackToTopButtonProps
extends ComponentProps<typeof Button>,
VariantProps<typeof backToTopButtonVariants> {}

View File

@@ -4,30 +4,32 @@ import { Button as ButtonRAC } from "react-aria-components"
import { useIntl } from "react-intl"
import { MaterialIcon } from "@scandic-hotels/design-system/Icons/MaterialIcon"
import { Typography } from "@scandic-hotels/design-system/Typography"
import { backToTopButtonVariants } from "./variants"
import styles from "./backToTopButton.module.css"
export function BackToTopButton({
onClick,
position,
}: {
onClick: () => void
position: "left" | "right" | "center"
}) {
import type { BackToTopButtonProps } from "./backToTopButton"
export function BackToTopButton({ position, ...props }: BackToTopButtonProps) {
const intl = useIntl()
return (
<ButtonRAC
className={backToTopButtonVariants({ position })}
onPress={onClick}
>
<MaterialIcon icon="arrow_upward" color="CurrentColor" />
<span className={styles.backToTopButtonText}>
{intl.formatMessage({
<Typography variant="Body/Supporting text (caption)/smBold">
<ButtonRAC
className={backToTopButtonVariants({ position })}
aria-label={intl.formatMessage({
defaultMessage: "Back to top",
})}
</span>
</ButtonRAC>
{...props}
>
<MaterialIcon icon="arrow_upward" color="CurrentColor" size={20} />
<span className={styles.text}>
{intl.formatMessage({
defaultMessage: "Back to top",
})}
</span>
</ButtonRAC>
</Typography>
)
}