File size: 1,344 Bytes
8a37e0a | 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 | import type { ChakraProps, ThemeTypings } from '@invoke-ai/ui-library';
import { Button, IconButton } from '@invoke-ai/ui-library';
import type { ReactElement, ReactNode } from 'react';
import { memo } from 'react';
type Props = {
label: string;
tooltip: ReactNode;
icon?: ReactElement;
onClick?: () => void;
isDisabled?: boolean;
colorScheme: ThemeTypings['colorSchemes'];
asIconButton?: boolean;
isLoading?: boolean;
loadingText?: string;
sx?: ChakraProps['sx'];
};
const QueueButton = ({
label,
tooltip,
icon,
onClick,
isDisabled,
colorScheme,
asIconButton,
isLoading,
loadingText,
sx,
}: Props) => {
if (asIconButton) {
return (
<IconButton
aria-label={label}
tooltip={tooltip}
icon={icon}
onClick={onClick}
isDisabled={isDisabled}
colorScheme={colorScheme}
isLoading={isLoading}
sx={sx}
data-testid={label}
/>
);
}
return (
<Button
aria-label={label}
tooltip={tooltip}
leftIcon={icon}
onClick={onClick}
isDisabled={isDisabled}
colorScheme={colorScheme}
isLoading={isLoading}
loadingText={loadingText ?? label}
flexGrow={1}
sx={sx}
data-testid={label}
>
{label}
</Button>
);
};
export default memo(QueueButton);
|