import { Button, ButtonGroup, OverlayTrigger, Tooltip } from "react-bootstrap"; import React, { useEffect, useState } from "react"; import * as GQL from "src/core/generated-graphql"; import { GridCard, calculateCardWidth } from "../Shared/GridCard/GridCard"; import { HoverPopover } from "../Shared/HoverPopover"; import { Icon } from "../Shared/Icon"; import { SceneLink, TagLink } from "../Shared/TagLink"; import { TruncatedText } from "../Shared/TruncatedText"; import { PerformerPopoverButton } from "../Shared/PerformerPopoverButton"; import { PopoverCountButton } from "../Shared/PopoverCountButton"; import NavUtils from "src/utils/navigation"; import { RatingBanner } from "../Shared/RatingBanner"; import { faBox, faPlayCircle, faTag } from "@fortawesome/free-solid-svg-icons"; import { galleryTitle } from "src/core/galleries"; import ScreenUtils from "src/utils/screen"; import { StudioOverlay } from "../Shared/GridCard/StudioOverlay"; import { GalleryPreviewScrubber } from "./GalleryPreviewScrubber"; import cx from "classnames"; import { useHistory } from "react-router-dom"; interface IGalleryPreviewProps { gallery: GQL.SlimGalleryDataFragment; onScrubberClick?: (index: number) => void; } export const GalleryPreview: React.FC = ({ gallery, onScrubberClick, }) => { const [imgSrc, setImgSrc] = useState( gallery.paths.cover ?? undefined ); return (
{!!imgSrc && ( {gallery.title )} {gallery.image_count > 0 && ( )}
); }; interface IProps { gallery: GQL.SlimGalleryDataFragment; containerWidth?: number; selecting?: boolean; selected?: boolean | undefined; zoomIndex?: number; onSelectedChanged?: (selected: boolean, shiftKey: boolean) => void; } export const GalleryCard: React.FC = (props) => { const history = useHistory(); const [cardWidth, setCardWidth] = useState(); useEffect(() => { if ( !props.containerWidth || props.zoomIndex === undefined || ScreenUtils.isMobile() ) return; let zoomValue = props.zoomIndex; let preferredCardWidth: number; switch (zoomValue) { case 0: preferredCardWidth = 240; break; case 1: preferredCardWidth = 340; break; case 2: preferredCardWidth = 480; break; case 3: preferredCardWidth = 640; } let fittedCardWidth = calculateCardWidth( props.containerWidth, preferredCardWidth! ); setCardWidth(fittedCardWidth); }, [props, props.containerWidth, props.zoomIndex]); function maybeRenderScenePopoverButton() { if (props.gallery.scenes.length === 0) return; const popoverContent = props.gallery.scenes.map((scene) => ( )); return ( ); } function maybeRenderTagPopoverButton() { if (props.gallery.tags.length <= 0) return; const popoverContent = props.gallery.tags.map((tag) => ( )); return ( ); } function maybeRenderPerformerPopoverButton() { if (props.gallery.performers.length <= 0) return; return ; } function maybeRenderImagesPopoverButton() { if (!props.gallery.image_count) return; return ( ); } function maybeRenderOrganized() { if (props.gallery.organized) { return ( {"Organized"}} placement="bottom" >
); } } function maybeRenderPopoverButtonGroup() { if ( props.gallery.scenes.length > 0 || props.gallery.performers.length > 0 || props.gallery.tags.length > 0 || props.gallery.organized || props.gallery.image_count > 0 ) { return ( <>
{maybeRenderImagesPopoverButton()} {maybeRenderTagPopoverButton()} {maybeRenderPerformerPopoverButton()} {maybeRenderScenePopoverButton()} {maybeRenderOrganized()} ); } } return ( { history.push(`/galleries/${props.gallery.id}/images/${i}`); }} /> } overlays={} details={
{props.gallery.date}
} popovers={maybeRenderPopoverButtonGroup()} selected={props.selected} selecting={props.selecting} onSelectedChanged={props.onSelectedChanged} /> ); };