Skip to content

Commit a304901

Browse files
Merge pull request #639 from sudhanshutech/primary/actions
Add primary actions component
2 parents 63e0b80 + 81dd82f commit a304901

File tree

2 files changed

+31
-2
lines changed

2 files changed

+31
-2
lines changed

src/custom/Modal/index.tsx

Lines changed: 30 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { DialogProps, styled } from '@mui/material';
22
import React, { useRef, useState } from 'react';
3-
import { Dialog, IconButton, Paper, Typography } from '../../base';
3+
import { Box, Dialog, IconButton, Paper, Typography } from '../../base';
44
import { ContainedButton, OutlinedButton, TextButton } from '../../base/Button/Button';
55
import { iconLarge, iconMedium } from '../../constants/iconsSizes';
66
import { CloseIcon, InfoCircleIcon } from '../../icons';
@@ -172,7 +172,7 @@ export const ModalFooter: React.FC<ModalFooterProps> = ({ helpText, children, va
172172
};
173173

174174
// ModalButtonPrimary
175-
export const ModalButtonPrimary: React.FC = styled(ContainedButton)(({ theme }) => ({
175+
export const ModalButtonPrimary = styled(ContainedButton)(({ theme }) => ({
176176
backgroundColor: theme.palette.background.brand?.default,
177177
color: theme.palette.text.constant?.white,
178178
'&:hover': {
@@ -215,3 +215,31 @@ export const ModalButtonDanger = styled(ContainedButton)(({ theme }) => ({
215215
background: theme.palette.background.error?.hover
216216
}
217217
}));
218+
219+
const ButtonContainer = styled(Box)(() => ({
220+
width: '100%',
221+
display: 'flex',
222+
justifyContent: 'end',
223+
gap: '1rem'
224+
}));
225+
226+
interface PrimaryActionButtonsProps {
227+
primaryText: string;
228+
secondaryText: string;
229+
primaryButtonProps?: React.ComponentProps<typeof ModalButtonPrimary>;
230+
secondaryButtonProps?: React.ComponentProps<typeof ModalButtonSecondary>;
231+
}
232+
233+
export const PrimaryActionButtons: React.FC<PrimaryActionButtonsProps> = ({
234+
primaryText,
235+
secondaryText,
236+
primaryButtonProps,
237+
secondaryButtonProps
238+
}) => {
239+
return (
240+
<ButtonContainer>
241+
<ModalButtonSecondary {...secondaryButtonProps}>{secondaryText}</ModalButtonSecondary>
242+
<ModalButtonPrimary {...primaryButtonProps}>{primaryText}</ModalButtonPrimary>
243+
</ButtonContainer>
244+
);
245+
};

src/custom/index.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@ export {
8484
ModalButtonSecondary,
8585
ModalButtonTertiary,
8686
ModalFooter,
87+
PrimaryActionButtons,
8788
useModal
8889
} from './Modal';
8990

0 commit comments

Comments
 (0)