feat(SW-337): logic for accesible dialog title text for lightbox
This commit is contained in:
@@ -7,10 +7,16 @@ import styles from "./previewImages.module.css"
|
|||||||
|
|
||||||
import type { PreviewImagesProps } from "@/types/components/hotelPage/previewImages"
|
import type { PreviewImagesProps } from "@/types/components/hotelPage/previewImages"
|
||||||
|
|
||||||
export default async function PreviewImages({ images }: PreviewImagesProps) {
|
export default async function PreviewImages({
|
||||||
|
images,
|
||||||
|
hotelName,
|
||||||
|
}: PreviewImagesProps) {
|
||||||
const intl = await getIntl()
|
const intl = await getIntl()
|
||||||
|
const imageGalleryText = intl.formatMessage({ id: "Image gallery" })
|
||||||
|
const dialogTitle = `${hotelName} - ${imageGalleryText}`
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Lightbox images={images}>
|
<Lightbox images={images} dialogTitle={dialogTitle}>
|
||||||
<div className={styles.imageWrapper}>
|
<div className={styles.imageWrapper}>
|
||||||
{images.slice(0, 3).map((image, index) => (
|
{images.slice(0, 3).map((image, index) => (
|
||||||
<Image
|
<Image
|
||||||
|
|||||||
@@ -33,7 +33,7 @@ export default async function HotelPage() {
|
|||||||
return (
|
return (
|
||||||
<div className={styles.pageContainer}>
|
<div className={styles.pageContainer}>
|
||||||
<div className={styles.hotelImages}>
|
<div className={styles.hotelImages}>
|
||||||
<PreviewImages images={hotelImages} />
|
<PreviewImages images={hotelImages} hotelName={hotelName} />
|
||||||
</div>
|
</div>
|
||||||
<TabNavigation />
|
<TabNavigation />
|
||||||
<main className={styles.mainSection}>
|
<main className={styles.mainSection}>
|
||||||
|
|||||||
@@ -16,6 +16,7 @@ import type { GalleryProps } from "@/types/components/lightbox/lightbox"
|
|||||||
|
|
||||||
export default function Gallery({
|
export default function Gallery({
|
||||||
images,
|
images,
|
||||||
|
dialogTitle,
|
||||||
onClose,
|
onClose,
|
||||||
onSelectImage,
|
onSelectImage,
|
||||||
onImageClick,
|
onImageClick,
|
||||||
@@ -58,7 +59,7 @@ export default function Gallery({
|
|||||||
<div className={styles.desktopGallery}>
|
<div className={styles.desktopGallery}>
|
||||||
<VisuallyHidden asChild>
|
<VisuallyHidden asChild>
|
||||||
<DialogTitle asChild>
|
<DialogTitle asChild>
|
||||||
<VisuallyHidden>Image Gallery</VisuallyHidden>
|
<VisuallyHidden>{dialogTitle}</VisuallyHidden>
|
||||||
</DialogTitle>
|
</DialogTitle>
|
||||||
</VisuallyHidden>
|
</VisuallyHidden>
|
||||||
<div className={styles.galleryHeader}>
|
<div className={styles.galleryHeader}>
|
||||||
|
|||||||
@@ -10,7 +10,11 @@ import styles from "./Lightbox.module.css"
|
|||||||
|
|
||||||
import type { LightboxProps } from "@/types/components/lightbox/lightbox"
|
import type { LightboxProps } from "@/types/components/lightbox/lightbox"
|
||||||
|
|
||||||
export default function Lightbox({ images, children }: LightboxProps) {
|
export default function Lightbox({
|
||||||
|
images,
|
||||||
|
children,
|
||||||
|
dialogTitle,
|
||||||
|
}: LightboxProps) {
|
||||||
const [isOpen, setIsOpen] = useState(false)
|
const [isOpen, setIsOpen] = useState(false)
|
||||||
const [selectedImageIndex, setSelectedImageIndex] = useState(0)
|
const [selectedImageIndex, setSelectedImageIndex] = useState(0)
|
||||||
const [isFullView, setIsFullView] = useState(false)
|
const [isFullView, setIsFullView] = useState(false)
|
||||||
@@ -93,6 +97,7 @@ export default function Lightbox({ images, children }: LightboxProps) {
|
|||||||
) : (
|
) : (
|
||||||
<Gallery
|
<Gallery
|
||||||
images={images}
|
images={images}
|
||||||
|
dialogTitle={dialogTitle}
|
||||||
onClose={() => setIsOpen(false)}
|
onClose={() => setIsOpen(false)}
|
||||||
onSelectImage={(image) => {
|
onSelectImage={(image) => {
|
||||||
setSelectedImageIndex(
|
setSelectedImageIndex(
|
||||||
|
|||||||
@@ -79,6 +79,7 @@
|
|||||||
"Hotel surroundings": "Hotel omgivelser",
|
"Hotel surroundings": "Hotel omgivelser",
|
||||||
"How do you want to sleep?": "Hvordan vil du sove?",
|
"How do you want to sleep?": "Hvordan vil du sove?",
|
||||||
"How it works": "Hvordan det virker",
|
"How it works": "Hvordan det virker",
|
||||||
|
"Image gallery": "Billedgalleri",
|
||||||
"Join Scandic Friends": "Tilmeld dig Scandic Friends",
|
"Join Scandic Friends": "Tilmeld dig Scandic Friends",
|
||||||
"km to city center": "km til byens centrum",
|
"km to city center": "km til byens centrum",
|
||||||
"Language": "Sprog",
|
"Language": "Sprog",
|
||||||
|
|||||||
@@ -77,6 +77,7 @@
|
|||||||
"Hotel surroundings": "Umgebung des Hotels",
|
"Hotel surroundings": "Umgebung des Hotels",
|
||||||
"How do you want to sleep?": "Wie möchtest du schlafen?",
|
"How do you want to sleep?": "Wie möchtest du schlafen?",
|
||||||
"How it works": "Wie es funktioniert",
|
"How it works": "Wie es funktioniert",
|
||||||
|
"Image gallery": "Bildergalerie",
|
||||||
"Join Scandic Friends": "Treten Sie Scandic Friends bei",
|
"Join Scandic Friends": "Treten Sie Scandic Friends bei",
|
||||||
"km to city center": "km bis zum Stadtzentrum",
|
"km to city center": "km bis zum Stadtzentrum",
|
||||||
"Language": "Sprache",
|
"Language": "Sprache",
|
||||||
|
|||||||
@@ -83,6 +83,7 @@
|
|||||||
"hotelPages.rooms.roomCard.seeRoomDetails": "See room details",
|
"hotelPages.rooms.roomCard.seeRoomDetails": "See room details",
|
||||||
"How do you want to sleep?": "How do you want to sleep?",
|
"How do you want to sleep?": "How do you want to sleep?",
|
||||||
"How it works": "How it works",
|
"How it works": "How it works",
|
||||||
|
"Image gallery": "Image gallery",
|
||||||
"Join Scandic Friends": "Join Scandic Friends",
|
"Join Scandic Friends": "Join Scandic Friends",
|
||||||
"km to city center": "km to city center",
|
"km to city center": "km to city center",
|
||||||
"Language": "Language",
|
"Language": "Language",
|
||||||
|
|||||||
@@ -78,6 +78,7 @@
|
|||||||
"Hotel surroundings": "Hotellin ympäristö",
|
"Hotel surroundings": "Hotellin ympäristö",
|
||||||
"How do you want to sleep?": "Kuinka haluat nukkua?",
|
"How do you want to sleep?": "Kuinka haluat nukkua?",
|
||||||
"How it works": "Kuinka se toimii",
|
"How it works": "Kuinka se toimii",
|
||||||
|
"Image gallery": "Kuvagalleria",
|
||||||
"Join Scandic Friends": "Liity jäseneksi",
|
"Join Scandic Friends": "Liity jäseneksi",
|
||||||
"km to city center": "km keskustaan",
|
"km to city center": "km keskustaan",
|
||||||
"Language": "Kieli",
|
"Language": "Kieli",
|
||||||
|
|||||||
@@ -78,6 +78,7 @@
|
|||||||
"Hotel surroundings": "Hotellomgivelser",
|
"Hotel surroundings": "Hotellomgivelser",
|
||||||
"How do you want to sleep?": "Hvordan vil du sove?",
|
"How do you want to sleep?": "Hvordan vil du sove?",
|
||||||
"How it works": "Hvordan det fungerer",
|
"How it works": "Hvordan det fungerer",
|
||||||
|
"Image gallery": "Bildegalleri",
|
||||||
"Join Scandic Friends": "Bli med i Scandic Friends",
|
"Join Scandic Friends": "Bli med i Scandic Friends",
|
||||||
"km to city center": "km til sentrum",
|
"km to city center": "km til sentrum",
|
||||||
"Language": "Språk",
|
"Language": "Språk",
|
||||||
|
|||||||
@@ -80,6 +80,7 @@
|
|||||||
"hotelPages.rooms.roomCard.persons": "personer",
|
"hotelPages.rooms.roomCard.persons": "personer",
|
||||||
"How do you want to sleep?": "Hur vill du sova?",
|
"How do you want to sleep?": "Hur vill du sova?",
|
||||||
"How it works": "Hur det fungerar",
|
"How it works": "Hur det fungerar",
|
||||||
|
"Image gallery": "Bildgalleri",
|
||||||
"Join Scandic Friends": "Gå med i Scandic Friends",
|
"Join Scandic Friends": "Gå med i Scandic Friends",
|
||||||
"km to city center": "km till stadens centrum",
|
"km to city center": "km till stadens centrum",
|
||||||
"Language": "Språk",
|
"Language": "Språk",
|
||||||
|
|||||||
@@ -2,4 +2,5 @@ import type { ImageItem } from "@/types/components/lightbox/lightbox"
|
|||||||
|
|
||||||
export type PreviewImagesProps = {
|
export type PreviewImagesProps = {
|
||||||
images: ImageItem[]
|
images: ImageItem[]
|
||||||
|
hotelName: string
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,11 +6,13 @@ export interface ImageItem {
|
|||||||
|
|
||||||
export interface LightboxProps {
|
export interface LightboxProps {
|
||||||
images: ImageItem[]
|
images: ImageItem[]
|
||||||
|
dialogTitle: string /* Accessible title for dialog screen readers */
|
||||||
children: React.ReactNode
|
children: React.ReactNode
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface GalleryProps {
|
export interface GalleryProps {
|
||||||
images: ImageItem[]
|
images: ImageItem[]
|
||||||
|
dialogTitle: string
|
||||||
onClose: () => void
|
onClose: () => void
|
||||||
onSelectImage: (image: ImageItem) => void
|
onSelectImage: (image: ImageItem) => void
|
||||||
onImageClick: () => void
|
onImageClick: () => void
|
||||||
|
|||||||
Reference in New Issue
Block a user