Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions src/components/ConfirmAction/ConfirmAction.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ export default {
cancelButton: { type: { name: 'string' } },
confirmButton: { type: { name: 'string' } },
confirmColorPalette: { options: ['primary', 'red'], control: { type: 'radio' } },
confirmButtonTextColor: {
control: { type: 'text' },
},
confirmLoading: { control: { type: 'boolean' } },
},
} as Meta<typeof ConfirmAction>;
Expand Down Expand Up @@ -50,6 +53,7 @@ WithRedButton.args = {
cancelButton: 'Cancel',
confirmButton: 'Delete',
confirmColorPalette: 'red',
confirmButtonTextColor: 'white',
};

export const WithLoadingConfirmationButton = Template.bind({});
Expand Down
12 changes: 10 additions & 2 deletions src/components/ConfirmAction/ConfirmAction.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import React, { ReactNode } from 'react';
import { BoemlyModal } from '../BoemlyModal';
import { Button, Flex, Text } from '@chakra-ui/react';
import { Button } from '../ui/button';
import { Flex, Text } from '@chakra-ui/react';

export interface ConfirmActionProps {
trigger: ReactNode;
Expand All @@ -12,6 +13,7 @@ export interface ConfirmActionProps {
title?: string;
text?: string;
confirmColorPalette?: 'primary' | 'red';
confirmButtonTextColor?: string;
confirmLoading?: boolean;
}
export const ConfirmAction: React.FC<ConfirmActionProps> = ({
Expand All @@ -24,6 +26,7 @@ export const ConfirmAction: React.FC<ConfirmActionProps> = ({
open,
onOpenChange,
confirmColorPalette = 'primary',
confirmButtonTextColor = 'black',
confirmLoading = false,
}: ConfirmActionProps) => (
<BoemlyModal
Expand All @@ -38,7 +41,12 @@ export const ConfirmAction: React.FC<ConfirmActionProps> = ({
<Button variant="ghost" onClick={onClose}>
{cancelButton}
</Button>
<Button colorPalette={confirmColorPalette} loading={confirmLoading} onClick={onConfirm}>
<Button
colorPalette={confirmColorPalette}
color={confirmButtonTextColor}
loading={confirmLoading}
onClick={onConfirm}
>
{confirmButton}
</Button>
</Flex>
Expand Down
Loading