mirror of https://github.com/morpheus65535/bazarr
37 lines
1004 B
TypeScript
37 lines
1004 B
TypeScript
import { Selector } from "@/components";
|
|
import { useModal, withModal } from "@/modules/modals";
|
|
import { submodProcessColor } from "@/utilities";
|
|
import { FunctionComponent, useCallback, useState } from "react";
|
|
import { Button } from "react-bootstrap";
|
|
import { useProcess } from "./ToolContext";
|
|
import { colorOptions } from "./tools";
|
|
|
|
const ColorTool: FunctionComponent = () => {
|
|
const [selection, setSelection] = useState<Nullable<string>>(null);
|
|
|
|
const Modal = useModal();
|
|
|
|
const process = useProcess();
|
|
|
|
const submit = useCallback(() => {
|
|
if (selection) {
|
|
const action = submodProcessColor(selection);
|
|
process(action);
|
|
}
|
|
}, [process, selection]);
|
|
|
|
const footer = (
|
|
<Button disabled={selection === null} onClick={submit}>
|
|
Save
|
|
</Button>
|
|
);
|
|
|
|
return (
|
|
<Modal title="Choose Color" footer={footer}>
|
|
<Selector options={colorOptions} onChange={setSelection}></Selector>
|
|
</Modal>
|
|
);
|
|
};
|
|
|
|
export default withModal(ColorTool, "color-tool");
|