Skip to content

Commit

Permalink
feat: Added Close Icon to Release Notes Modal
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelkoelle committed May 17, 2021
1 parent f1fe69f commit 9fa9044
Show file tree
Hide file tree
Showing 2 changed files with 55 additions and 3 deletions.
52 changes: 52 additions & 0 deletions app/modals/DialogTitleWithCloseIcon.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
/* eslint-disable react/jsx-props-no-spreading */
import {
createStyles,
DialogTitle,
IconButton,
Theme,
withStyles,
WithStyles,
} from '@material-ui/core';
import CloseIcon from '@material-ui/icons/Close';
import React from 'react';

const styles = (theme: Theme) =>
createStyles({
root: {
margin: 0,
padding: theme.spacing(2),
},
closeButton: {
position: 'absolute',
right: theme.spacing(1),
top: theme.spacing(1),
color: theme.palette.grey[500],
},
});

export interface DialogTitleProps extends WithStyles<typeof styles> {
children: React.ReactNode;
onClose: () => void;
}

const DialogTitleWithCloseIcon = withStyles(styles)(
(props: DialogTitleProps) => {
const { children, classes, onClose, ...other } = props;
return (
<DialogTitle disableTypography className={classes.root} {...other}>
{children}
{onClose ? (
<IconButton
aria-label="close"
className={classes.closeButton}
onClick={onClose}
>
<CloseIcon />
</IconButton>
) : null}
</DialogTitle>
);
}
);

export default DialogTitleWithCloseIcon;
6 changes: 3 additions & 3 deletions app/modals/ReleaseNotesModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@ import {
CircularProgress,
Dialog,
DialogContent,
DialogTitle,
Grid,
Typography,
useTheme,
} from '@material-ui/core';
import { remote } from 'electron';
import { UpdateCheckResult, UpdateInfo } from 'electron-updater';
import React, { FC, useEffect, useState } from 'react';
import DialogTitleWithCloseIcon from './DialogTitleWithCloseIcon';
import { ModalProps } from './ModalProvider';

type ReleaseNotesModalProps = ModalProps;
Expand Down Expand Up @@ -75,9 +75,9 @@ const ReleaseNotesModal: FC<ReleaseNotesModalProps> = ({ ...props }) => {
// Update Info received
content = (
<>
<DialogTitle disableTypography>
<DialogTitleWithCloseIcon onClose={close}>
<Typography variant="h5">{`Version ${updateInfo?.version}`}</Typography>
</DialogTitle>
</DialogTitleWithCloseIcon>
<DialogContent dividers>
<div
dangerouslySetInnerHTML={{
Expand Down

0 comments on commit 9fa9044

Please sign in to comment.