Merged in fix/BOOK-408-alt-text-needs-to-be-updated- (pull request #3220)
* 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
This commit is contained in:
@@ -1,4 +1,7 @@
|
|||||||
|
"use client"
|
||||||
|
|
||||||
import NextLink from "next/link"
|
import NextLink from "next/link"
|
||||||
|
import { useIntl } from "react-intl"
|
||||||
|
|
||||||
import Chip from "@scandic-hotels/design-system/Chip"
|
import Chip from "@scandic-hotels/design-system/Chip"
|
||||||
import Image from "@scandic-hotels/design-system/Image"
|
import Image from "@scandic-hotels/design-system/Image"
|
||||||
@@ -29,6 +32,7 @@ export default function ContentCard({
|
|||||||
className = "",
|
className = "",
|
||||||
link,
|
link,
|
||||||
}: ContentCardProps) {
|
}: ContentCardProps) {
|
||||||
|
const intl = useIntl()
|
||||||
const card = (
|
const card = (
|
||||||
<article className={`${styles.card} ${className}`}>
|
<article className={`${styles.card} ${className}`}>
|
||||||
<div className={styles.imageContainer}>
|
<div className={styles.imageContainer}>
|
||||||
@@ -63,6 +67,10 @@ export default function ContentCard({
|
|||||||
...(link.openInNewTab && {
|
...(link.openInNewTab && {
|
||||||
target: "_blank",
|
target: "_blank",
|
||||||
rel: "noopener noreferrer",
|
rel: "noopener noreferrer",
|
||||||
|
title: intl.formatMessage({
|
||||||
|
id: "common.linkOpenInNewTab",
|
||||||
|
defaultMessage: "Opens in a new tab/window",
|
||||||
|
}),
|
||||||
}),
|
}),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -42,6 +42,10 @@ export default function FooterSecondaryNav({
|
|||||||
href={href.href}
|
href={href.href}
|
||||||
target="_blank"
|
target="_blank"
|
||||||
onClick={() => trackSocialMediaClick(href.title)}
|
onClick={() => trackSocialMediaClick(href.title)}
|
||||||
|
title={intl.formatMessage({
|
||||||
|
id: "common.linkOpenInNewTab",
|
||||||
|
defaultMessage: "Opens in a new tab/window",
|
||||||
|
})}
|
||||||
>
|
>
|
||||||
<Image
|
<Image
|
||||||
src={attributes.src}
|
src={attributes.src}
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
"use client"
|
"use client"
|
||||||
import { cx } from "class-variance-authority"
|
import { cx } from "class-variance-authority"
|
||||||
import NextLink from "next/link"
|
import NextLink from "next/link"
|
||||||
import { useIntl } from "react-intl"
|
|
||||||
|
|
||||||
import ScandicLogoIcon from "@scandic-hotels/design-system/Icons/ScandicLogoIcon"
|
import ScandicLogoIcon from "@scandic-hotels/design-system/Icons/ScandicLogoIcon"
|
||||||
|
|
||||||
@@ -23,7 +22,6 @@ export function LogoLink({
|
|||||||
...props
|
...props
|
||||||
}: LogoLinkProps) {
|
}: LogoLinkProps) {
|
||||||
const lang = useLang()
|
const lang = useLang()
|
||||||
const intl = useIntl()
|
|
||||||
const { toggleDropdown, isHamburgerMenuOpen } = useDropdownStore()
|
const { toggleDropdown, isHamburgerMenuOpen } = useDropdownStore()
|
||||||
|
|
||||||
function handleNavigate() {
|
function handleNavigate() {
|
||||||
@@ -37,13 +35,6 @@ export function LogoLink({
|
|||||||
className={styles.logoLink}
|
className={styles.logoLink}
|
||||||
href={`/${lang}`}
|
href={`/${lang}`}
|
||||||
onClick={handleNavigate}
|
onClick={handleNavigate}
|
||||||
aria-label={
|
|
||||||
ariaLabel ??
|
|
||||||
intl.formatMessage({
|
|
||||||
id: "header.backToScandicHotelsCom",
|
|
||||||
defaultMessage: "Back to scandichotels.com",
|
|
||||||
})
|
|
||||||
}
|
|
||||||
{...props}
|
{...props}
|
||||||
>
|
>
|
||||||
<ScandicLogoIcon
|
<ScandicLogoIcon
|
||||||
@@ -52,6 +43,8 @@ export function LogoLink({
|
|||||||
})}
|
})}
|
||||||
width="103px"
|
width="103px"
|
||||||
height="22px"
|
height="22px"
|
||||||
|
// eslint-disable-next-line formatjs/no-literal-string-in-jsx
|
||||||
|
aria-label="Scandic"
|
||||||
/>
|
/>
|
||||||
</NextLink>
|
</NextLink>
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ import { type ComponentProps, type PropsWithChildren } from 'react'
|
|||||||
import { variants } from './variants'
|
import { variants } from './variants'
|
||||||
|
|
||||||
import type { VariantProps } from 'class-variance-authority'
|
import type { VariantProps } from 'class-variance-authority'
|
||||||
|
import { useIntl } from 'react-intl'
|
||||||
|
|
||||||
export interface ButtonLinkProps
|
export interface ButtonLinkProps
|
||||||
extends PropsWithChildren,
|
extends PropsWithChildren,
|
||||||
@@ -33,12 +34,19 @@ export default function ButtonLink({
|
|||||||
className,
|
className,
|
||||||
})
|
})
|
||||||
|
|
||||||
|
const intl = useIntl()
|
||||||
|
const newTabText = intl.formatMessage({
|
||||||
|
id: 'common.linkOpenInNewTab',
|
||||||
|
defaultMessage: 'Opens in a new tab/window',
|
||||||
|
})
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Link
|
<Link
|
||||||
className={classNames}
|
className={classNames}
|
||||||
href={href}
|
href={href}
|
||||||
target={target}
|
target={target}
|
||||||
onClick={onClick}
|
onClick={onClick}
|
||||||
|
title={target === '_blank' ? newTabText : ''}
|
||||||
{...props}
|
{...props}
|
||||||
/>
|
/>
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ import { useMemo } from 'react'
|
|||||||
import { linkVariants } from './variants'
|
import { linkVariants } from './variants'
|
||||||
|
|
||||||
import type { LinkProps } from './link'
|
import type { LinkProps } from './link'
|
||||||
|
import { useIntl } from 'react-intl'
|
||||||
|
|
||||||
export { LinkProps }
|
export { LinkProps }
|
||||||
|
|
||||||
@@ -36,6 +37,7 @@ export default function Link({
|
|||||||
}: LinkProps) {
|
}: LinkProps) {
|
||||||
const currentPageSlug = usePathname()
|
const currentPageSlug = usePathname()
|
||||||
const searchParams = useSearchParams()
|
const searchParams = useSearchParams()
|
||||||
|
const intl = useIntl()
|
||||||
let isActive = active || currentPageSlug === href
|
let isActive = active || currentPageSlug === href
|
||||||
|
|
||||||
if (partialMatch && !isActive) {
|
if (partialMatch && !isActive) {
|
||||||
@@ -78,6 +80,13 @@ export default function Link({
|
|||||||
const linkProps = {
|
const linkProps = {
|
||||||
href: fullUrl,
|
href: fullUrl,
|
||||||
className: classNames,
|
className: classNames,
|
||||||
|
title:
|
||||||
|
props.target === '_blank'
|
||||||
|
? intl.formatMessage({
|
||||||
|
id: 'common.linkOpenInNewTab',
|
||||||
|
defaultMessage: 'Opens in a new tab/window',
|
||||||
|
})
|
||||||
|
: '',
|
||||||
}
|
}
|
||||||
|
|
||||||
return isExternal ? (
|
return isExternal ? (
|
||||||
|
|||||||
@@ -1,9 +1,12 @@
|
|||||||
|
'use client'
|
||||||
|
|
||||||
import { cx } from 'class-variance-authority'
|
import { cx } from 'class-variance-authority'
|
||||||
import NextLink from 'next/link'
|
import NextLink from 'next/link'
|
||||||
import { TextLinkProps } from './types'
|
import { TextLinkProps } from './types'
|
||||||
import { variants } from './variants'
|
import { variants } from './variants'
|
||||||
|
|
||||||
import styles from './textLink.module.css'
|
import styles from './textLink.module.css'
|
||||||
|
import { useIntl } from 'react-intl'
|
||||||
|
|
||||||
export function TextLink({
|
export function TextLink({
|
||||||
theme,
|
theme,
|
||||||
@@ -14,6 +17,7 @@ export function TextLink({
|
|||||||
typography,
|
typography,
|
||||||
...props
|
...props
|
||||||
}: TextLinkProps) {
|
}: TextLinkProps) {
|
||||||
|
const intl = useIntl()
|
||||||
const classNames = variants({
|
const classNames = variants({
|
||||||
theme,
|
theme,
|
||||||
typography,
|
typography,
|
||||||
@@ -29,6 +33,14 @@ export function TextLink({
|
|||||||
[styles.disabled]: isDisabled,
|
[styles.disabled]: isDisabled,
|
||||||
[styles.inline]: isInline,
|
[styles.inline]: isInline,
|
||||||
})}
|
})}
|
||||||
|
title={
|
||||||
|
props.target === '_blank'
|
||||||
|
? intl.formatMessage({
|
||||||
|
id: 'common.linkOpenInNewTab',
|
||||||
|
defaultMessage: 'Opens in a new tab/window',
|
||||||
|
})
|
||||||
|
: ''
|
||||||
|
}
|
||||||
/>
|
/>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user