Skip to content

Commit

Permalink
Merge pull request #639 from sudhanshutech/primary/actions
Browse files Browse the repository at this point in the history
Add primary actions component
  • Loading branch information
dragon-slayer875 authored Jun 5, 2024
2 parents 63e0b80 + 81dd82f commit a304901
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 2 deletions.
32 changes: 30 additions & 2 deletions src/custom/Modal/index.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { DialogProps, styled } from '@mui/material';
import React, { useRef, useState } from 'react';
import { Dialog, IconButton, Paper, Typography } from '../../base';
import { Box, Dialog, IconButton, Paper, Typography } from '../../base';
import { ContainedButton, OutlinedButton, TextButton } from '../../base/Button/Button';
import { iconLarge, iconMedium } from '../../constants/iconsSizes';
import { CloseIcon, InfoCircleIcon } from '../../icons';
Expand Down Expand Up @@ -172,7 +172,7 @@ export const ModalFooter: React.FC<ModalFooterProps> = ({ helpText, children, va
};

// ModalButtonPrimary
export const ModalButtonPrimary: React.FC = styled(ContainedButton)(({ theme }) => ({
export const ModalButtonPrimary = styled(ContainedButton)(({ theme }) => ({
backgroundColor: theme.palette.background.brand?.default,
color: theme.palette.text.constant?.white,
'&:hover': {
Expand Down Expand Up @@ -215,3 +215,31 @@ export const ModalButtonDanger = styled(ContainedButton)(({ theme }) => ({
background: theme.palette.background.error?.hover
}
}));

const ButtonContainer = styled(Box)(() => ({
width: '100%',
display: 'flex',
justifyContent: 'end',
gap: '1rem'
}));

interface PrimaryActionButtonsProps {
primaryText: string;
secondaryText: string;
primaryButtonProps?: React.ComponentProps<typeof ModalButtonPrimary>;
secondaryButtonProps?: React.ComponentProps<typeof ModalButtonSecondary>;
}

export const PrimaryActionButtons: React.FC<PrimaryActionButtonsProps> = ({
primaryText,
secondaryText,
primaryButtonProps,
secondaryButtonProps
}) => {
return (
<ButtonContainer>
<ModalButtonSecondary {...secondaryButtonProps}>{secondaryText}</ModalButtonSecondary>
<ModalButtonPrimary {...primaryButtonProps}>{primaryText}</ModalButtonPrimary>
</ButtonContainer>
);
};
1 change: 1 addition & 0 deletions src/custom/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ export {
ModalButtonSecondary,
ModalButtonTertiary,
ModalFooter,
PrimaryActionButtons,
useModal
} from './Modal';

Expand Down

0 comments on commit a304901

Please sign in to comment.