import { useId, type ReactNode } from 'react' import type { TourListItem } from '@trek/shared' import { fs } from '../shared/DialogShell' import { useTranslation } from '../../i18n' import { TourFactPills, TourGradeTile } from './tourParts' import { tourWebsitePresentation } from './tourPresentation' interface TourListRowProps { tour: TourListItem selected?: boolean disabled?: boolean onSelect: (tour: TourListItem, opener: HTMLElement) => void action?: ReactNode children?: ReactNode } /** A tour in a list, shaped like a place row: tile, name, its facts as pills and the day action on the right. */ export default function TourListRow({ tour, selected = false, disabled = false, onSelect, action, children }: TourListRowProps) { const { t } = useTranslation() const nameId = useId() const tone = selected ? 'bg-surface-selected' : disabled ? '' : 'hover:bg-surface-hover' const website = tourWebsitePresentation(tour.website) return (
  • { if (!disabled) onSelect(tour, event.currentTarget) }} onKeyDown={event => { if (disabled || event.target !== event.currentTarget) return if (event.key === 'Enter' || event.key === ' ') { event.preventDefault() onSelect(tour, event.currentTarget) } }} >
    {tour.name} {tour.description && (
    {tour.description}
    )} {website && (
    {website.provider ? `${website.provider} · ${website.domain}` : `${t('places.formWebsite')} · ${website.domain}`}
    )}
    {action && (
    event.stopPropagation()}> {action}
    )}
    {children}
  • ) }