aboutsummaryrefslogtreecommitdiff
path: root/src/client/views/nodes/generativeFill/GenerativeFillButtons.tsx
blob: fe22b273d9e8e0be674408212951c7ed44dfbe5b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
import './GenerativeFillButtons.scss';
import * as React from 'react';
import ReactLoading from 'react-loading';
import { Button, IconButton, Type } from 'browndash-components';
import { AiOutlineInfo } from 'react-icons/ai';
import { activeColor } from './generativeFillUtils/generativeFillConstants';

interface ButtonContainerProps {
    onClick: () => Promise<void>;
    loading: boolean;
    onReset: () => void;
}

export function EditButtons({ loading, onClick: getEdit, onReset }: ButtonContainerProps) {
    return (
        <div className="generativeFillBtnContainer">
            <Button text="RESET" type={Type.PRIM} color={activeColor} onClick={onReset} />
            {loading ? (
                <Button
                    text="GET EDITS"
                    type={Type.TERT}
                    color={activeColor}
                    icon={<ReactLoading type="spin" color="#ffffff" width={20} height={20} />}
                    iconPlacement="right"
                    onClick={() => {
                        if (!loading) getEdit();
                    }}
                />
            ) : (
                <Button
                    text="GET EDITS"
                    type={Type.TERT}
                    color={activeColor}
                    onClick={() => {
                        if (!loading) getEdit();
                    }}
                />
            )}
            <IconButton type={Type.SEC} color={activeColor} tooltip="Open Documentation" icon={<AiOutlineInfo size="16px" />} onClick={() => window.open('https://brown-dash.github.io/Dash-Documentation/features/generativeai/#editing', '_blank')} />
        </div>
    );
}

export function CutButtons({ loading, onClick: cutImage, onReset }: ButtonContainerProps) {
    return (
        <div className="generativeFillBtnContainer">
            <Button text="RESET" type={Type.PRIM} color={activeColor} onClick={onReset} />
            {loading ? (
                <Button
                    text="CUT IMAGE"
                    type={Type.TERT}
                    color={activeColor}
                    icon={<ReactLoading type="spin" color="#ffffff" width={20} height={20} />}
                    iconPlacement="right"
                    onClick={() => {
                        if (!loading) cutImage();
                    }}
                />
            ) : (
                <Button
                    text="CUT IMAGE"
                    type={Type.TERT}
                    color={activeColor}
                    onClick={() => {
                        if (!loading) cutImage();
                    }}
                />
            )}
            <IconButton type={Type.SEC} color={activeColor} tooltip="Open Documentation" icon={<AiOutlineInfo size="16px" />} onClick={() => window.open('https://brown-dash.github.io/Dash-Documentation/features/generativeai/#editing', '_blank')} />
        </div>
    );
}