diff --git a/ui/v2.5/src/components/Galleries/GalleryCard.tsx b/ui/v2.5/src/components/Galleries/GalleryCard.tsx index 238310d1f..e4e227f3e 100644 --- a/ui/v2.5/src/components/Galleries/GalleryCard.tsx +++ b/ui/v2.5/src/components/Galleries/GalleryCard.tsx @@ -16,6 +16,7 @@ import { StudioOverlay } from "../Shared/GridCard/StudioOverlay"; import { GalleryPreviewScrubber } from "./GalleryPreviewScrubber"; import cx from "classnames"; import { useHistory } from "react-router-dom"; +import { PatchComponent } from "src/patch"; interface IGalleryPreviewProps { gallery: GQL.SlimGalleryDataFragment; @@ -53,7 +54,7 @@ export const GalleryPreview: React.FC = ({ ); }; -interface IProps { +interface IGalleryCardProps { gallery: GQL.SlimGalleryDataFragment; cardWidth?: number; selecting?: boolean; @@ -62,148 +63,179 @@ interface IProps { onSelectedChanged?: (selected: boolean, shiftKey: boolean) => void; } -export const GalleryCard: React.FC = (props) => { - const history = useHistory(); +const GalleryCardPopovers = PatchComponent( + "GalleryCard.Popovers", + (props: IGalleryCardProps) => { + function maybeRenderScenePopoverButton() { + if (props.gallery.scenes.length === 0) return; - function maybeRenderScenePopoverButton() { - if (props.gallery.scenes.length === 0) return; + const popoverContent = props.gallery.scenes.map((scene) => ( + + )); - 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"}} + -
- -
-
+ + ); } - } - 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 - ) { + function maybeRenderTagPopoverButton() { + if (props.gallery.tags.length <= 0) return; + + const popoverContent = props.gallery.tags.map((tag) => ( + + )); + return ( - <> -
- - {maybeRenderImagesPopoverButton()} - {maybeRenderTagPopoverButton()} - {maybeRenderPerformerPopoverButton()} - {maybeRenderScenePopoverButton()} - {maybeRenderOrganized()} - - + + + ); } - } - return ( - - { - history.push(`/galleries/${props.gallery.id}/images/${i}`); - }} - /> - - + 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" + > +
+ +
+
+ ); } - overlays={} - details={ -
- {props.gallery.date} - -
+ } + + 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()} + + + ); } - popovers={maybeRenderPopoverButtonGroup()} - selected={props.selected} - selecting={props.selecting} - onSelectedChanged={props.onSelectedChanged} - /> - ); -}; + } + + return <>{maybeRenderPopoverButtonGroup()}; + } +); + +const GalleryCardDetails = PatchComponent( + "GalleryCard.Details", + (props: IGalleryCardProps) => { + return ( +
+ {props.gallery.date} + +
+ ); + } +); + +const GalleryCardOverlays = PatchComponent( + "GalleryCard.Overlays", + (props: IGalleryCardProps) => { + return ; + } +); + +const GalleryCardImage = PatchComponent( + "GalleryCard.Image", + (props: IGalleryCardProps) => { + const history = useHistory(); + + return ( + <> + { + history.push(`/galleries/${props.gallery.id}/images/${i}`); + }} + /> + + + ); + } +); + +export const GalleryCard = PatchComponent( + "GalleryCard", + (props: IGalleryCardProps) => { + return ( + } + overlays={} + details={} + popovers={} + selected={props.selected} + selecting={props.selecting} + onSelectedChanged={props.onSelectedChanged} + /> + ); + } +); diff --git a/ui/v2.5/src/docs/en/Manual/UIPluginApi.md b/ui/v2.5/src/docs/en/Manual/UIPluginApi.md index 18f4405a2..529451a25 100644 --- a/ui/v2.5/src/docs/en/Manual/UIPluginApi.md +++ b/ui/v2.5/src/docs/en/Manual/UIPluginApi.md @@ -154,6 +154,11 @@ Returns `void`. - `ExternalLinksButton` - `FolderSelect` - `FrontPage` +- `GalleryCard` +- `GalleryCard.Details` +- `GalleryCard.Image` +- `GalleryCard.Overlays` +- `GalleryCard.Popovers` - `GalleryIDSelect` - `GallerySelect` - `GallerySelect.sort` diff --git a/ui/v2.5/src/pluginApi.d.ts b/ui/v2.5/src/pluginApi.d.ts index cb2c05c02..3cb5e9400 100644 --- a/ui/v2.5/src/pluginApi.d.ts +++ b/ui/v2.5/src/pluginApi.d.ts @@ -715,6 +715,11 @@ declare namespace PluginApi { "ScenePage.TabContent": React.FC; ScenePlayer: React.FC; FrontPage: React.FC; + GalleryCard: React.FC; + "GalleryCard.Details": React.FC; + "GalleryCard.Image": React.FC; + "GalleryCard.Overlays": React.FC; + "GalleryCard.Popovers": React.FC; }; type PatchableComponentNames = keyof typeof components | string; namespace utils {