mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-12-05 02:14:05 +00:00
ba70ad28b8
Arabic runs the app right to left, but margins, paddings, insets, text alignment, borders and corner radii were written for the left side, so icons sat against the wrong edge of their labels, indents and badges pointed the wrong way and amount columns aligned left. They now use the logical forms (ms-, ps-, start-, text-start, marginInlineStart, insetInlineEnd and their CSS equivalents), which are the very same sides in a left to right language. Geometry stays physical on purpose: maps, positions measured from the pointer or a bounding box, time axes, sliders, transforms and print output. Amounts drawn as several spans keep their order in a right to left row, the time picker keeps hours before minutes, and two switches whose thumb slid out of its track in Arabic now move the right way. lint:rtl counts what is still physical per file against a baseline that may only shrink (1512 uses in 370 files before, 319 in 113 now), and CI runs it, so new code reaches for the logical forms.
81 lines
3.1 KiB
TypeScript
81 lines
3.1 KiB
TypeScript
import { Image, Play } from 'lucide-react'
|
|
import type { JourneyPhoto } from '../../store/journeyStore'
|
|
import { photoUrl, posterlessVideo } from '../../pages/journeyDetail/JourneyDetailPage.helpers'
|
|
|
|
export function PhotoImg({ photo, className, style }: { photo: JourneyPhoto; className?: string; style?: React.CSSProperties }) {
|
|
const src = photoUrl(photo, 'thumbnail')
|
|
const isVideo = photo.media_type === 'video'
|
|
|
|
return (
|
|
<div
|
|
className={`relative overflow-hidden ${isVideo ? 'bg-black' : ''} ${className || ''}`}
|
|
style={style}
|
|
>
|
|
{/* A clip without a poster keeps the black tile and the play badge; asking
|
|
for its thumbnail would only draw the broken-image glyph over them. */}
|
|
{!posterlessVideo(photo) && (
|
|
<img
|
|
src={src}
|
|
alt=""
|
|
className={`w-full h-full ${isVideo ? 'object-contain' : 'object-cover'}`}
|
|
loading="lazy"
|
|
/>
|
|
)}
|
|
|
|
{isVideo && (
|
|
<div className="absolute inset-0 flex items-center justify-center pointer-events-none">
|
|
<span className="w-11 h-11 rounded-full bg-black/60 backdrop-blur-sm flex items-center justify-center text-white">
|
|
<Play size={20} className="ml-0.5" fill="currentColor" />
|
|
</span>
|
|
</div>
|
|
)}
|
|
</div>
|
|
)
|
|
}
|
|
|
|
export function PhotoGrid({ photos, onClick }: { photos: JourneyPhoto[]; onClick: (idx: number) => void }) {
|
|
const count = photos.length
|
|
if (count === 0) return null
|
|
|
|
if (count === 1) {
|
|
return (
|
|
<button type="button" className="block w-full overflow-hidden cursor-pointer" onClick={() => onClick(0)}>
|
|
<PhotoImg photo={photos[0]} className="w-full h-72 object-cover" />
|
|
</button>
|
|
)
|
|
}
|
|
|
|
if (count === 2) {
|
|
return (
|
|
<div className="grid grid-cols-2 gap-0.5 overflow-hidden">
|
|
{photos.slice(0, 2).map((p, i) => (
|
|
<button key={p.id} type="button" className="block w-full h-52 overflow-hidden cursor-pointer" onClick={() => onClick(i)}>
|
|
<PhotoImg photo={p} className="w-full h-full object-cover" />
|
|
</button>
|
|
))}
|
|
</div>
|
|
)
|
|
}
|
|
|
|
return (
|
|
<div className="overflow-hidden flex" style={{ height: 300, gap: 2 }}>
|
|
<button type="button" className="flex-1 min-w-0 cursor-pointer" onClick={() => onClick(0)}>
|
|
<PhotoImg photo={photos[0]} className="w-full h-full object-cover" />
|
|
</button>
|
|
<div className="flex-1 min-w-0 flex flex-col" style={{ gap: 2 }}>
|
|
<button type="button" className="flex-1 min-h-0 cursor-pointer" onClick={() => onClick(1)}>
|
|
<PhotoImg photo={photos[1]} className="w-full h-full object-cover" />
|
|
</button>
|
|
<button type="button" className="flex-1 min-h-0 relative cursor-pointer" onClick={() => onClick(2)}>
|
|
<PhotoImg photo={photos[2]} className="w-full h-full object-cover" />
|
|
{count > 3 && (
|
|
<div className="absolute bottom-2 end-2 bg-black/60 backdrop-blur text-white rounded-full px-2 py-0.5 text-[10px] font-semibold flex items-center gap-1">
|
|
<Image size={10} />
|
|
+{count - 3}
|
|
</div>
|
|
)}
|
|
</button>
|
|
</div>
|
|
</div>
|
|
)
|
|
} |