stash/ui/v2.5/src/components/Shared/CountButton.tsx
WithoutPants ec6acab2f4
Details operation toolbar (#4714)
* Add scene detail header
* Make common count button and add view count
* Add titles to play count and o count buttons
* Move rating from edit panel
* Include frame rate in header
* Remove redundant title/studio
* Improve numeric rating presentation
* Add star where there is no rating header
* Set rating on blur when click to edit
* Add star to numeric rating on gallery wall card
* Apply click to rate on movie page
* Apply click to rate to performer page
* Apply click to rate to studio page
* Fix rating number presentation on list tables
* Add data-value attributes
2024-04-17 10:29:36 +10:00

74 lines
1.9 KiB
TypeScript

import { faEye } from "@fortawesome/free-solid-svg-icons";
import React from "react";
import { Button, ButtonGroup } from "react-bootstrap";
import { Icon } from "src/components/Shared/Icon";
import { SweatDrops } from "./SweatDrops";
import cx from "classnames";
import { useIntl } from "react-intl";
interface ICountButtonProps {
value: number;
icon: React.ReactNode;
onIncrement?: () => void;
onValueClicked?: () => void;
title?: string;
countTitle?: string;
}
export const CountButton: React.FC<ICountButtonProps> = ({
value,
icon,
onIncrement,
onValueClicked,
title,
countTitle,
}) => {
return (
<ButtonGroup
className={cx("count-button", { "increment-only": !onValueClicked })}
>
<Button
className="minimal count-icon"
variant="secondary"
onClick={() => onIncrement?.()}
title={title}
>
{icon}
</Button>
<Button
className="minimal count-value"
variant="secondary"
onClick={() => (onValueClicked ?? onIncrement)?.()}
title={!!onValueClicked ? countTitle : undefined}
>
<span>{value}</span>
</Button>
</ButtonGroup>
);
};
type CountButtonPropsNoIcon = Omit<ICountButtonProps, "icon">;
export const ViewCountButton: React.FC<CountButtonPropsNoIcon> = (props) => {
const intl = useIntl();
return (
<CountButton
{...props}
icon={<Icon icon={faEye} />}
title={intl.formatMessage({ id: "media_info.play_count" })}
countTitle={intl.formatMessage({ id: "actions.view_history" })}
/>
);
};
export const OCounterButton: React.FC<CountButtonPropsNoIcon> = (props) => {
const intl = useIntl();
return (
<CountButton
{...props}
icon={<SweatDrops />}
title={intl.formatMessage({ id: "o_count" })}
countTitle={intl.formatMessage({ id: "actions.view_history" })}
/>
);
};