Skip to content

Commit

Permalink
feat: add component modal title
Browse files Browse the repository at this point in the history
  • Loading branch information
ialexanderbrito committed Jan 10, 2023
1 parent 62cc6ac commit 67d07b0
Show file tree
Hide file tree
Showing 2 changed files with 55 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/components/ModalTitle/ModalTitle.module.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
.title {
background: var(--background);
}

.dark {
background: #312e38;
}

.light {
background: #f4ede8;
}
44 changes: 44 additions & 0 deletions src/components/ModalTitle/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
import { IoClose } from 'react-icons/io5';

import { DialogTitle, IconButton } from '@mui/material';
import cx from 'classnames';
import { DialogTitleProps } from 'types/ComponentsProps';

import { useTheme } from 'contexts/Theme';

import styles from './ModalTitle.module.scss';

export function ModalTitle({ children, onClose, ...props }: DialogTitleProps) {
const { theme } = useTheme();

return (
<div data-theme={theme}>
<DialogTitle
sx={{ m: 0, p: 2 }}
{...props}
className={cx(
styles.title,
theme === 'dark' ? styles.dark : styles.light,
)}
>
{children}
{onClose ? (
<IconButton
aria-label="close"
onClick={onClose}
sx={{
position: 'absolute',
right: 8,
top: 8,
}}
>
<IoClose
color={theme === 'dark' ? '#f4ede8' : '#312e38'}
size={24}
/>
</IconButton>
) : null}
</DialogTitle>
</div>
);
}

0 comments on commit 67d07b0

Please sign in to comment.