:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.
Python ab-testingai-analyticsanalyticscdpdata-warehouseexperimentsfeature-flagsjavascriptproduct-analyticspythonreactsession-replaysurveystypescriptweb-analytics
import { useState } from 'react'
import { LemonModal } from '@posthog/lemon-ui'
import { backendAssetUrl } from 'lib/utils/apiHost'
export interface StepScreenshotThumbnailProps {
mediaId: string
}
export function StepScreenshotThumbnail({ mediaId }: StepScreenshotThumbnailProps): JSX.Element | null {
const [hasError, setHasError] = useState(false)
const [showScreenshotModal, setShowScreenshotModal] = useState(false)
if (hasError) {
return null
}
return (
<>
<button
type="button"
className="block w-30 aspect-[4/3] overflow-hidden cursor-pointer bg-fill-tertiary border rounded transition-all hover:border-primary hover:ring-1 hover:ring-primary"
onClick={() => setShowScreenshotModal(true)}
>
<img
src={backendAssetUrl(`/uploaded_media/${mediaId}`)}
alt="Element screenshot"
className="w-full h-full object-cover"
title="Click to view screenshot"
onError={() => setHasError(true)}
/>
</button>
<LemonModal
isOpen={showScreenshotModal}
onClose={() => setShowScreenshotModal(false)}
title="Element screenshot"
width="auto"
>
<div className="flex flex-col items-center justify-center gap-4">
<img
src={backendAssetUrl(`/uploaded_media/${mediaId}`)}
alt="Element screenshot"
className="max-w-full max-h-[70vh]"
/>
</div>
</LemonModal>
</>
)
}