mirror of
https://github.com/stashapp/stash.git
synced 2025-12-17 04:14:39 +03:00
Rating system patched components (#5912)
This commit is contained in:
@@ -4,6 +4,7 @@ import { Icon } from "../Icon";
|
|||||||
import { faPencil, faStar } from "@fortawesome/free-solid-svg-icons";
|
import { faPencil, faStar } from "@fortawesome/free-solid-svg-icons";
|
||||||
import { useFocusOnce } from "src/utils/focus";
|
import { useFocusOnce } from "src/utils/focus";
|
||||||
import { useStopWheelScroll } from "src/utils/form";
|
import { useStopWheelScroll } from "src/utils/form";
|
||||||
|
import { PatchComponent } from "src/patch";
|
||||||
|
|
||||||
export interface IRatingNumberProps {
|
export interface IRatingNumberProps {
|
||||||
value: number | null;
|
value: number | null;
|
||||||
@@ -14,9 +15,9 @@ export interface IRatingNumberProps {
|
|||||||
withoutContext?: boolean;
|
withoutContext?: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
export const RatingNumber: React.FC<IRatingNumberProps> = (
|
export const RatingNumber = PatchComponent(
|
||||||
props: IRatingNumberProps
|
"RatingNumber",
|
||||||
) => {
|
(props: IRatingNumberProps) => {
|
||||||
const [editing, setEditing] = useState(false);
|
const [editing, setEditing] = useState(false);
|
||||||
const [valueStage, setValueStage] = useState<number | null>(props.value);
|
const [valueStage, setValueStage] = useState<number | null>(props.value);
|
||||||
|
|
||||||
@@ -161,4 +162,5 @@ export const RatingNumber: React.FC<IRatingNumberProps> = (
|
|||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
};
|
}
|
||||||
|
);
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import React, { useState } from "react";
|
import { useState } from "react";
|
||||||
import { Button } from "react-bootstrap";
|
import { Button } from "react-bootstrap";
|
||||||
import { Icon } from "../Icon";
|
import { Icon } from "../Icon";
|
||||||
import { faStar as fasStar } from "@fortawesome/free-solid-svg-icons";
|
import { faStar as fasStar } from "@fortawesome/free-solid-svg-icons";
|
||||||
@@ -11,6 +11,7 @@ import {
|
|||||||
RatingSystemType,
|
RatingSystemType,
|
||||||
} from "src/utils/rating";
|
} from "src/utils/rating";
|
||||||
import { useIntl } from "react-intl";
|
import { useIntl } from "react-intl";
|
||||||
|
import { PatchComponent } from "src/patch";
|
||||||
|
|
||||||
export interface IRatingStarsProps {
|
export interface IRatingStarsProps {
|
||||||
value: number | null;
|
value: number | null;
|
||||||
@@ -20,9 +21,9 @@ export interface IRatingStarsProps {
|
|||||||
valueRequired?: boolean;
|
valueRequired?: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
export const RatingStars: React.FC<IRatingStarsProps> = (
|
export const RatingStars = PatchComponent(
|
||||||
props: IRatingStarsProps
|
"RatingStars",
|
||||||
) => {
|
(props: IRatingStarsProps) => {
|
||||||
const intl = useIntl();
|
const intl = useIntl();
|
||||||
const [hoverRating, setHoverRating] = useState<number | undefined>();
|
const [hoverRating, setHoverRating] = useState<number | undefined>();
|
||||||
const disabled = props.disabled || !props.onSetRating;
|
const disabled = props.disabled || !props.onSetRating;
|
||||||
@@ -250,4 +251,5 @@ export const RatingStars: React.FC<IRatingStarsProps> = (
|
|||||||
{maybeRenderStarRatingNumber()}
|
{maybeRenderStarRatingNumber()}
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
};
|
}
|
||||||
|
);
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ import {
|
|||||||
} from "src/utils/rating";
|
} from "src/utils/rating";
|
||||||
import { RatingNumber } from "./RatingNumber";
|
import { RatingNumber } from "./RatingNumber";
|
||||||
import { RatingStars } from "./RatingStars";
|
import { RatingStars } from "./RatingStars";
|
||||||
|
import { PatchComponent } from "src/patch";
|
||||||
|
|
||||||
export interface IRatingSystemProps {
|
export interface IRatingSystemProps {
|
||||||
value: number | null | undefined;
|
value: number | null | undefined;
|
||||||
@@ -19,9 +20,9 @@ export interface IRatingSystemProps {
|
|||||||
withoutContext?: boolean;
|
withoutContext?: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
export const RatingSystem: React.FC<IRatingSystemProps> = (
|
export const RatingSystem = PatchComponent(
|
||||||
props: IRatingSystemProps
|
"RatingSystem",
|
||||||
) => {
|
(props: IRatingSystemProps) => {
|
||||||
const { configuration: config } = React.useContext(ConfigurationContext);
|
const { configuration: config } = React.useContext(ConfigurationContext);
|
||||||
const ratingSystemOptions =
|
const ratingSystemOptions =
|
||||||
config?.ui.ratingSystemOptions ?? defaultRatingSystemOptions;
|
config?.ui.ratingSystemOptions ?? defaultRatingSystemOptions;
|
||||||
@@ -49,4 +50,5 @@ export const RatingSystem: React.FC<IRatingSystemProps> = (
|
|||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
};
|
}
|
||||||
|
);
|
||||||
|
|||||||
@@ -196,6 +196,9 @@ Returns `void`.
|
|||||||
- `PerformerImagesPanel`
|
- `PerformerImagesPanel`
|
||||||
- `PerformerScenesPanel`
|
- `PerformerScenesPanel`
|
||||||
- `PluginRoutes`
|
- `PluginRoutes`
|
||||||
|
- `RatingNumber`
|
||||||
|
- `RatingStars`
|
||||||
|
- `RatingSystem`
|
||||||
- `SceneCard`
|
- `SceneCard`
|
||||||
- `SceneCard.Details`
|
- `SceneCard.Details`
|
||||||
- `SceneCard.Image`
|
- `SceneCard.Image`
|
||||||
|
|||||||
3
ui/v2.5/src/pluginApi.d.ts
vendored
3
ui/v2.5/src/pluginApi.d.ts
vendored
@@ -727,6 +727,9 @@ declare namespace PluginApi {
|
|||||||
"GalleryCard.Image": React.FC<any>;
|
"GalleryCard.Image": React.FC<any>;
|
||||||
"GalleryCard.Overlays": React.FC<any>;
|
"GalleryCard.Overlays": React.FC<any>;
|
||||||
"GalleryCard.Popovers": React.FC<any>;
|
"GalleryCard.Popovers": React.FC<any>;
|
||||||
|
RatingNumber: React.FC<any>;
|
||||||
|
RatingStars: React.FC<any>;
|
||||||
|
RatingSystem: React.FC<any>;
|
||||||
};
|
};
|
||||||
type PatchableComponentNames = keyof typeof components | string;
|
type PatchableComponentNames = keyof typeof components | string;
|
||||||
namespace utils {
|
namespace utils {
|
||||||
|
|||||||
Reference in New Issue
Block a user