mirror of
https://github.com/stashapp/stash.git
synced 2025-12-17 12:24:38 +03:00
65 lines
1.6 KiB
TypeScript
65 lines
1.6 KiB
TypeScript
import React from "react";
|
|
import { Button, Spinner } from "react-bootstrap";
|
|
import { Icon, HoverPopover, SweatDrops } from "src/components/Shared";
|
|
|
|
export interface IOCounterButtonProps {
|
|
loading: boolean;
|
|
value: number;
|
|
onIncrement: () => void;
|
|
onDecrement: () => void;
|
|
onReset: () => void;
|
|
onMenuOpened?: () => void;
|
|
onMenuClosed?: () => void;
|
|
}
|
|
|
|
export const OCounterButton: React.FC<IOCounterButtonProps> = (
|
|
props: IOCounterButtonProps
|
|
) => {
|
|
if (props.loading) return <Spinner animation="border" role="status" />;
|
|
|
|
const renderButton = () => (
|
|
<Button className="minimal" onClick={props.onIncrement} variant="secondary">
|
|
<SweatDrops />
|
|
<span className="ml-2">{props.value}</span>
|
|
</Button>
|
|
);
|
|
|
|
if (props.value) {
|
|
return (
|
|
<HoverPopover
|
|
content={
|
|
<div>
|
|
<div>
|
|
<Button
|
|
className="minimal"
|
|
onClick={props.onDecrement}
|
|
variant="secondary"
|
|
>
|
|
<Icon icon="minus" />
|
|
<span>Decrement</span>
|
|
</Button>
|
|
</div>
|
|
<div>
|
|
<Button
|
|
className="minimal"
|
|
onClick={props.onReset}
|
|
variant="secondary"
|
|
>
|
|
<Icon icon="ban" />
|
|
<span>Reset</span>
|
|
</Button>
|
|
</div>
|
|
</div>
|
|
}
|
|
enterDelay={1000}
|
|
placement="bottom"
|
|
onOpen={props.onMenuOpened}
|
|
onClose={props.onMenuClosed}
|
|
>
|
|
{renderButton()}
|
|
</HoverPopover>
|
|
);
|
|
}
|
|
return renderButton();
|
|
};
|