Files
web/packages/design-system/lib/components/HotelCard/HotelCardDialogImage/index.tsx
Joakim Jäderberg 80c3327419 Merged in fix/linting (pull request #2708)
Fix/linting

* fix import issues and add lint check no-extraneous-dependencies
* fix use type HotelType instead of string

Approved-by: Anton Gunnarsson
2025-08-27 09:22:37 +00:00

48 lines
1.1 KiB
TypeScript

import Image from '../../Image'
import { hotelCardDialogImageVariants } from './variants'
import { TripAdvisorChip } from '../../TripAdvisorChip'
import styles from './hotelCardDialogImage.module.css'
export type HotelCardDialogImageProps = {
firstImage?: string
altText?: string
rating?: { tripAdvisor?: number | null }
imageError: boolean
setImageError: (error: boolean) => void
position: 'top' | 'left'
}
export function HotelCardDialogImage({
firstImage,
altText,
rating,
imageError,
setImageError,
position,
}: HotelCardDialogImageProps) {
const classNames = hotelCardDialogImageVariants({ position })
return (
<div className={classNames}>
{!firstImage || imageError ? (
<div className={styles.imagePlaceholder} />
) : (
<Image
src={firstImage}
alt={altText || ''}
fill
onError={() => setImageError(true)}
/>
)}
{rating?.tripAdvisor && (
<TripAdvisorChip
rating={rating.tripAdvisor}
variant={position === 'top' ? 'small' : 'default'}
/>
)}
</div>
)
}