links: image thumbnail fills entire grid item

fixes urbit/landscape#1313
This commit is contained in:
James Acklin 2022-04-07 10:35:45 -04:00
parent 116b0c540a
commit c623bc6c36
3 changed files with 29 additions and 6 deletions

View File

@ -34,11 +34,12 @@ export interface LinkBlockItemProps {
node: GraphNode;
size?: CenterProps['height'];
border?: CenterProps['border'];
objectFit?: string;
summary?: boolean;
}
export function LinkBlockItem(props: LinkBlockItemProps & CenterProps) {
const { node, summary, size, m, border = 1, ...rest } = props;
const { node, summary, size, m, border = 1, objectFit, ...rest } = props;
const { post, children } = node;
const { contents, index, author } = post;
@ -90,7 +91,12 @@ export function LinkBlockItem(props: LinkBlockItemProps & CenterProps) {
/>
)
) : isImage ? (
<RemoteContentImageEmbed url={url} />
<RemoteContentImageEmbed
url={url}
tall
stretch
objectFit={objectFit ? objectFit : "cover"}
/>
) : isAudio ? (
<AudioPlayer title={title} url={url} />
) : isOembed ? (

View File

@ -28,6 +28,16 @@ export function LinkDetail(props: LinkDetailProps) {
/* @ts-ignore indio props?? */
<Row height="100%" width="100%" flexDirection={['column', 'column', 'row']} {...rest}>
<LinkBlockItem minWidth="0" minHeight="0" height={['50%', '50%', '100%']} width={['100%', '100%', 'calc(100% - 350px)']} flexGrow={0} border={0} node={node} />
<LinkBlockItem
minWidth="0"
minHeight="0"
height={["50%", "50%", "100%"]}
width={["100%", "100%", "calc(100% - 350px)"]}
flexGrow={0}
border={0}
node={node}
objectFit="contain"
/>
<Col
minHeight="0"
flexShrink={1}

View File

@ -44,13 +44,14 @@ function onStopProp<T extends HTMLElement>(e: MouseEvent<T>) {
type ImageProps = PropFunc<typeof BaseImage> & {
objectFit?: string;
stretch?: boolean;
};
const Image = styled.img(system({ objectFit: true }), ...allSystemStyle);
export function RemoteContentImageEmbed(
props: ImageProps & RemoteContentEmbedProps
) {
const { url, ...rest } = props;
const { url, stretch, ...rest } = props;
const [noCors, setNoCors] = useState(false);
const { hovering, bind } = useHovering();
// maybe images aren't set up for CORS embeds
@ -59,7 +60,13 @@ export function RemoteContentImageEmbed(
}, []);
return (
<Box height="100%" width="100%" position="relative" {...bind} {...rest}>
<Box
height={stretch ? "100%" : "192px"}
width={stretch ? "100%" : "192px"}
position="relative"
{...bind}
{...rest}
>
<BaseAnchor
position="absolute"
top={2}
@ -84,8 +91,8 @@ export function RemoteContentImageEmbed(
referrerPolicy="no-referrer"
flexShrink={0}
src={url}
height="192px"
maxWidth="192px"
height={stretch ? "100%" : "192px"}
maxWidth={stretch ? "100%" : "192px"}
width="100%"
objectFit="cover"
borderRadius={2}