diff --git a/ui/v2.5/src/components/Shared/Alert.tsx b/ui/v2.5/src/components/Shared/Alert.tsx index c4ada36f3..1a6023bb0 100644 --- a/ui/v2.5/src/components/Shared/Alert.tsx +++ b/ui/v2.5/src/components/Shared/Alert.tsx @@ -1,6 +1,6 @@ -import React from "react"; import { Button, Modal } from "react-bootstrap"; import { FormattedMessage } from "react-intl"; +import { PatchComponent } from "src/patch"; export interface IAlertModalProps { text: JSX.Element | string; @@ -11,25 +11,28 @@ export interface IAlertModalProps { onCancel: () => void; } -export const AlertModal: React.FC = ({ - text, - show, - confirmVariant = "danger", - confirmButtonText, - onConfirm, - onCancel, -}) => { - return ( - - {text} - - - - - - ); -}; +export const AlertModal: React.FC = PatchComponent( + "AlertModal", + ({ + text, + show, + confirmVariant = "danger", + confirmButtonText, + onConfirm, + onCancel, + }) => { + return ( + + {text} + + + + + + ); + } +); diff --git a/ui/v2.5/src/components/Shared/DetailsPage/BackgroundImage.tsx b/ui/v2.5/src/components/Shared/DetailsPage/BackgroundImage.tsx index cd5f3ae27..58e262614 100644 --- a/ui/v2.5/src/components/Shared/DetailsPage/BackgroundImage.tsx +++ b/ui/v2.5/src/components/Shared/DetailsPage/BackgroundImage.tsx @@ -1,10 +1,11 @@ import React from "react"; +import { PatchComponent } from "src/patch"; export const BackgroundImage: React.FC<{ imagePath: string | undefined; show: boolean; alt?: string; -}> = ({ imagePath, show, alt }) => { +}> = PatchComponent("BackgroundImage", ({ imagePath, show, alt }) => { if (imagePath && show) { const imageURL = new URL(imagePath); let isDefaultImage = imageURL.searchParams.get("default"); @@ -21,4 +22,4 @@ export const BackgroundImage: React.FC<{ } return null; -}; +}); diff --git a/ui/v2.5/src/components/Shared/SweatDrops.tsx b/ui/v2.5/src/components/Shared/SweatDrops.tsx index 594d1acf1..9be80cd57 100644 --- a/ui/v2.5/src/components/Shared/SweatDrops.tsx +++ b/ui/v2.5/src/components/Shared/SweatDrops.tsx @@ -1,6 +1,7 @@ import React from "react"; +import { PatchComponent } from "src/patch"; -export const SweatDrops: React.FC = () => ( +export const SweatDrops: React.FC = PatchComponent("SweatDrops", () => ( ( -); +)); diff --git a/ui/v2.5/src/components/Shared/TruncatedText.tsx b/ui/v2.5/src/components/Shared/TruncatedText.tsx index c06686eff..8eebb9592 100644 --- a/ui/v2.5/src/components/Shared/TruncatedText.tsx +++ b/ui/v2.5/src/components/Shared/TruncatedText.tsx @@ -3,6 +3,7 @@ import { Overlay, Tooltip } from "react-bootstrap"; import { Placement } from "react-bootstrap/Overlay"; import cx from "classnames"; import { useDebounce } from "src/hooks/debounce"; +import { PatchComponent } from "src/patch"; const CLASSNAME = "TruncatedText"; const CLASSNAME_TOOLTIP = `${CLASSNAME}-tooltip`; @@ -15,57 +16,54 @@ interface ITruncatedTextProps { className?: string; } -export const TruncatedText: React.FC = ({ - text, - className, - lineCount = 1, - placement = "bottom", - delay = 1000, -}) => { - const [showTooltip, setShowTooltip] = useState(false); - const target = useRef(null); +export const TruncatedText: React.FC = PatchComponent( + "TruncatedText", + ({ text, className, lineCount = 1, placement = "bottom", delay = 1000 }) => { + const [showTooltip, setShowTooltip] = useState(false); + const target = useRef(null); - const startShowingTooltip = useDebounce(() => setShowTooltip(true), delay); + const startShowingTooltip = useDebounce(() => setShowTooltip(true), delay); - if (!text) return <>; + if (!text) return <>; - const handleFocus = (element: HTMLElement) => { - // Check if visible size is smaller than the content size - if ( - element.offsetWidth < element.scrollWidth || - element.offsetHeight + 10 < element.scrollHeight - ) - startShowingTooltip(); - }; + const handleFocus = (element: HTMLElement) => { + // Check if visible size is smaller than the content size + if ( + element.offsetWidth < element.scrollWidth || + element.offsetHeight + 10 < element.scrollHeight + ) + startShowingTooltip(); + }; - const handleBlur = () => { - startShowingTooltip.cancel(); - setShowTooltip(false); - }; + const handleBlur = () => { + startShowingTooltip.cancel(); + setShowTooltip(false); + }; - const overlay = ( - - + const overlay = ( + + + {text} + + + ); + + return ( +
handleFocus(e.currentTarget)} + onFocus={(e) => handleFocus(e.currentTarget)} + onMouseLeave={handleBlur} + onBlur={handleBlur} + > {text} - - - ); - - return ( -
handleFocus(e.currentTarget)} - onFocus={(e) => handleFocus(e.currentTarget)} - onMouseLeave={handleBlur} - onBlur={handleBlur} - > - {text} - {overlay} -
- ); -}; + {overlay} +
+ ); + } +); export const TruncatedInlineText: React.FC = ({ text, diff --git a/ui/v2.5/src/docs/en/Manual/UIPluginApi.md b/ui/v2.5/src/docs/en/Manual/UIPluginApi.md index c42a498a9..c09428abe 100644 --- a/ui/v2.5/src/docs/en/Manual/UIPluginApi.md +++ b/ui/v2.5/src/docs/en/Manual/UIPluginApi.md @@ -143,7 +143,9 @@ Returns `void`. #### Patchable components and functions +- `AlertModal` - `App` +- `BackgroundImage` - `BooleanSetting` - `ChangeButtonSetting` - `CompressedPerformerDetailsPanel` @@ -219,6 +221,7 @@ Returns `void`. - `StudioIDSelect` - `StudioSelect` - `StudioSelect.sort` +- `SweatDrops` - `TabTitleCounter` - `TagCard` - `TagCard.Details` @@ -231,6 +234,7 @@ Returns `void`. - `TagIDSelect` - `TagSelect` - `TagSelect.sort` +- `TruncatedText` - `PluginSettings` - `Setting` - `SettingGroup` diff --git a/ui/v2.5/src/pluginApi.d.ts b/ui/v2.5/src/pluginApi.d.ts index 8a9fd7152..3dfd9a6f1 100644 --- a/ui/v2.5/src/pluginApi.d.ts +++ b/ui/v2.5/src/pluginApi.d.ts @@ -727,6 +727,10 @@ declare namespace PluginApi { "GalleryCard.Image": React.FC; "GalleryCard.Overlays": React.FC; "GalleryCard.Popovers": React.FC; + TruncatedText: React.FC; + SweatDrops: React.FC; + AlertModal: React.FC; + BackgroundImage: React.FC; RatingNumber: React.FC; RatingStars: React.FC; RatingSystem: React.FC;