import React, { useState } from "react"; import { Button, ButtonGroup, Card, Form } from "react-bootstrap"; import { Link } from "react-router-dom"; import cx from "classnames"; import * as GQL from "src/core/generated-graphql"; import { useConfiguration } from "src/core/StashService"; import { useVideoHover } from "src/hooks"; import { Icon, TagLink, HoverPopover, SweatDrops } from "src/components/Shared"; import { TextUtils } from "src/utils"; interface ISceneCardProps { scene: GQL.SlimSceneDataFragment; selected: boolean | undefined; zoomIndex: number; onSelectedChanged: (selected: boolean, shiftKey: boolean) => void; } export const SceneCard: React.FC = ( props: ISceneCardProps ) => { const [previewPath, setPreviewPath] = useState(); const hoverHandler = useVideoHover({ resetOnMouseLeave: false, }); const config = useConfiguration(); const showStudioAsText = config?.data?.configuration.interface.showStudioAsText ?? false; function maybeRenderRatingBanner() { if (!props.scene.rating) { return; } return (
RATING: {props.scene.rating}
); } function maybeRenderSceneSpecsOverlay() { return (
{props.scene.file.height ? ( {" "} {TextUtils.resolution(props.scene.file.height)} ) : ( "" )} {(props.scene.file.duration ?? 0) >= 1 ? TextUtils.secondsToTimestamp(props.scene.file.duration ?? 0) : ""}
); } function maybeRenderSceneStudioOverlay() { if (!props.scene.studio) return; return (
{showStudioAsText ? ( props.scene.studio.name ) : ( {props.scene.studio.name} )}
); } function maybeRenderTagPopoverButton() { if (props.scene.tags.length <= 0) return; const popoverContent = props.scene.tags.map((tag) => ( )); return ( ); } function maybeRenderPerformerPopoverButton() { if (props.scene.performers.length <= 0) return; const popoverContent = props.scene.performers.map((performer) => (
{performer.name
)); return ( ); } function maybeRenderMoviePopoverButton() { if (props.scene.movies.length <= 0) return; const popoverContent = props.scene.movies.map((sceneMovie) => (
{sceneMovie.movie.name
)); return ( ); } function maybeRenderSceneMarkerPopoverButton() { if (props.scene.scene_markers.length <= 0) return; const popoverContent = props.scene.scene_markers.map((marker) => { const markerPopover = { ...marker, scene: { id: props.scene.id } }; return ; }); return ( ); } function maybeRenderOCounter() { if (props.scene.o_counter) { return (
); } } function maybeRenderPopoverButtonGroup() { if ( props.scene.tags.length > 0 || props.scene.performers.length > 0 || props.scene.movies.length > 0 || props.scene.scene_markers.length > 0 || props.scene?.o_counter ) { return ( <>
{maybeRenderTagPopoverButton()} {maybeRenderPerformerPopoverButton()} {maybeRenderMoviePopoverButton()} {maybeRenderSceneMarkerPopoverButton()} {maybeRenderOCounter()} ); } } function onMouseEnter() { if (!previewPath || previewPath === "") { setPreviewPath(props.scene.paths.preview || ""); } hoverHandler.onMouseEnter(); } function onMouseLeave() { hoverHandler.onMouseLeave(); setPreviewPath(""); } function isPortrait() { const { file } = props.scene; const width = file.width ? file.width : 0; const height = file.height ? file.height : 0; return height > width; } let shiftKey = false; return ( props.onSelectedChanged(!props.selected, shiftKey)} onClick={(event: React.MouseEvent) => { // eslint-disable-next-line prefer-destructuring shiftKey = event.shiftKey; event.stopPropagation(); }} /> {maybeRenderSceneStudioOverlay()} {maybeRenderRatingBanner()} {maybeRenderSceneSpecsOverlay()}
{props.scene.title ? props.scene.title : TextUtils.fileNameFromPath(props.scene.path)}
{props.scene.date}

{props.scene.details && TextUtils.truncate(props.scene.details, 100, "... (continued)")}

{maybeRenderPopoverButtonGroup()}
); };