Working tree is now the canonical repo. Off-chain play-money + trustless on-chain (FPMM AMM + CLOB via UMA settlement), AI market factory, creator/social/distribution, mobile shell + push, one-command demo + deploy-kit. Secrets excluded (see ENV-AND-KEYS.md). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
59 lines
1.4 KiB
TypeScript
59 lines
1.4 KiB
TypeScript
import { Image } from '@tiptap/extension-image'
|
|
import clsx from 'clsx'
|
|
import { useState } from 'react'
|
|
import { createPortal } from 'react-dom'
|
|
|
|
export const BasicImage = Image.extend({
|
|
renderReact: (attrs: any) => (
|
|
<img loading="lazy" {...attrs} alt={attrs.alt ?? ''} />
|
|
),
|
|
})
|
|
|
|
export const DisplayImage = Image.extend({
|
|
renderReact: (attrs: any) => <ExpandingImage {...attrs} />,
|
|
})
|
|
|
|
export const MediumDisplayImage = Image.extend({
|
|
renderReact: (attrs: any) => <ExpandingImage size={'md'} {...attrs} />,
|
|
})
|
|
|
|
function ExpandingImage(props: {
|
|
src: string
|
|
alt?: string
|
|
title?: string
|
|
size?: 'md'
|
|
}) {
|
|
const [expanded, setExpanded] = useState(false)
|
|
const { size, alt, ...rest } = props
|
|
|
|
return (
|
|
<>
|
|
<img
|
|
loading="lazy"
|
|
alt={alt ?? ''}
|
|
{...rest}
|
|
onClick={() => setExpanded(true)}
|
|
className={clsx(
|
|
'cursor-pointer object-contain',
|
|
size === 'md' ? 'max-h-[400px]' : 'h-[128px]'
|
|
)}
|
|
height={size === 'md' ? 400 : 128}
|
|
/>
|
|
{expanded &&
|
|
createPortal(
|
|
<div
|
|
className="fixed inset-0 z-50 flex items-center justify-center bg-black/60"
|
|
onClick={() => setExpanded(false)}
|
|
>
|
|
<img
|
|
alt={alt ?? ''}
|
|
{...rest}
|
|
className="max-h-full cursor-pointer object-contain"
|
|
/>
|
|
</div>,
|
|
document.body
|
|
)}
|
|
</>
|
|
)
|
|
}
|