import React, { MouseEvent } from "react"; import { Button, ButtonGroup } from "react-bootstrap"; import cx from "classnames"; import * as GQL from "src/core/generated-graphql"; import { Icon, TagLink, HoverPopover, SweatDrops } from "src/components/Shared"; import { TextUtils } from "src/utils"; import { PerformerPopoverButton } from "../Shared/PerformerPopoverButton"; import { GridCard } from "../Shared/GridCard"; import { RatingBanner } from "../Shared/RatingBanner"; interface IImageCardProps { image: GQL.SlimImageDataFragment; selecting?: boolean; selected: boolean | undefined; zoomIndex: number; onSelectedChanged: (selected: boolean, shiftKey: boolean) => void; onPreview?: (ev: MouseEvent) => void; } export const ImageCard: React.FC = ( props: IImageCardProps ) => { function maybeRenderTagPopoverButton() { if (props.image.tags.length <= 0) return; const popoverContent = props.image.tags.map((tag) => ( )); return ( ); } function maybeRenderPerformerPopoverButton() { if (props.image.performers.length <= 0) return; return ; } function maybeRenderOCounter() { if (props.image.o_counter) { return (
); } } function maybeRenderOrganized() { if (props.image.organized) { return (
); } } function maybeRenderPopoverButtonGroup() { if ( props.image.tags.length > 0 || props.image.performers.length > 0 || props.image.o_counter || props.image.organized ) { return ( <>
{maybeRenderTagPopoverButton()} {maybeRenderPerformerPopoverButton()} {maybeRenderOCounter()} {maybeRenderOrganized()} ); } } function isPortrait() { const { file } = props.image; const width = file.width ? file.width : 0; const height = file.height ? file.height : 0; return height > width; } return (
{props.image.title {props.onPreview ? (
) : undefined}
} popovers={maybeRenderPopoverButtonGroup()} selected={props.selected} selecting={props.selecting} onSelectedChanged={props.onSelectedChanged} /> ); };