* fix(BOOK-408): Updated logo aria label * fix(BOOK-408): Added title for links opening in new tab * fix(BOOK-408): Added translations handling for title Approved-by: Anton Gunnarsson Approved-by: Matilda Landström
52 lines
1.2 KiB
TypeScript
52 lines
1.2 KiB
TypeScript
"use client"
|
|
import { cx } from "class-variance-authority"
|
|
import NextLink from "next/link"
|
|
|
|
import ScandicLogoIcon from "@scandic-hotels/design-system/Icons/ScandicLogoIcon"
|
|
|
|
import useDropdownStore from "@/stores/main-menu"
|
|
|
|
import useLang from "@/hooks/useLang"
|
|
|
|
import styles from "./logoLink.module.css"
|
|
|
|
import { DropdownTypeEnum } from "@/types/components/dropdown/dropdown"
|
|
|
|
interface LogoLinkProps extends React.HTMLAttributes<HTMLAnchorElement> {
|
|
isInverted?: boolean
|
|
}
|
|
|
|
export function LogoLink({
|
|
isInverted = false,
|
|
"aria-label": ariaLabel,
|
|
...props
|
|
}: LogoLinkProps) {
|
|
const lang = useLang()
|
|
const { toggleDropdown, isHamburgerMenuOpen } = useDropdownStore()
|
|
|
|
function handleNavigate() {
|
|
if (isHamburgerMenuOpen) {
|
|
toggleDropdown(DropdownTypeEnum.HamburgerMenu)
|
|
}
|
|
}
|
|
|
|
return (
|
|
<NextLink
|
|
className={styles.logoLink}
|
|
href={`/${lang}`}
|
|
onClick={handleNavigate}
|
|
{...props}
|
|
>
|
|
<ScandicLogoIcon
|
|
className={cx(styles.logoIcon, {
|
|
[styles.inverted]: isInverted,
|
|
})}
|
|
width="103px"
|
|
height="22px"
|
|
// eslint-disable-next-line formatjs/no-literal-string-in-jsx
|
|
aria-label="Scandic"
|
|
/>
|
|
</NextLink>
|
|
)
|
|
}
|