-
Notifications
You must be signed in to change notification settings - Fork 88
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
* feat: make update modal configurable * chore: add update modal story * chore: pass buttons dynamically to the update modal component * feat: show breaking changes warning on app start #2039 * fix: update modal component styling * feat: redirect to downloads page on button click * chore: suffix update modal component * fix: test snapshot * fix: lint
- Loading branch information
Showing
10 changed files
with
297 additions
and
146 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
97 changes: 0 additions & 97 deletions
97
packages/desktop/src/renderer/components/widgets/update/UpdateModal.tsx
This file was deleted.
Oops, something went wrong.
53 changes: 53 additions & 0 deletions
53
packages/desktop/src/renderer/components/widgets/update/UpdateModalComponent.stories.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
import React from 'react' | ||
import { ComponentStory, ComponentMeta } from '@storybook/react' | ||
|
||
import UpdateModal, { UpdateModalProps } from './UpdateModalComponent' | ||
|
||
import { withTheme } from '../../../storybook/decorators' | ||
import theme from '../../../theme' | ||
|
||
import Button from '@mui/material/Button' | ||
|
||
const Template: ComponentStory<typeof UpdateModal> = args => { | ||
return <UpdateModal {...args} /> | ||
} | ||
|
||
const args: UpdateModalProps = { | ||
open: true, | ||
handleClose: function (): void { | ||
console.log('modal closed') | ||
}, | ||
buttons: [ | ||
<Button | ||
variant='contained' | ||
size='large' | ||
color='primary' | ||
type='submit' | ||
onClick={() => { | ||
console.log('submit button clicked') | ||
}} | ||
style={{ | ||
height: 55, | ||
fontSize: '0.9rem', | ||
backgroundColor: theme.palette.colors.quietBlue, | ||
}} | ||
fullWidth | ||
> | ||
Update now | ||
</Button>, | ||
], | ||
title: 'Software update', | ||
message: 'An update is available for Quiet.', | ||
} | ||
|
||
export const Component = Template.bind({}) | ||
|
||
Component.args = args | ||
|
||
const component: ComponentMeta<typeof UpdateModal> = { | ||
title: 'Components/UpdateModalComponent', | ||
decorators: [withTheme], | ||
component: UpdateModal, | ||
} | ||
|
||
export default component |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
79 changes: 79 additions & 0 deletions
79
packages/desktop/src/renderer/components/widgets/update/UpdateModalComponent.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
import React, { ReactElement } from 'react' | ||
|
||
import { styled } from '@mui/material/styles' | ||
|
||
import Typography from '@mui/material/Typography' | ||
import Grid from '@mui/material/Grid' | ||
|
||
import Icon from '../../ui/Icon/Icon' | ||
import updateIcon from '../../../static/images/updateIcon.svg' | ||
import Modal from '../../ui/Modal/Modal' | ||
|
||
const PREFIX = 'UpdateModal' | ||
|
||
const classes = { | ||
info: `${PREFIX}info`, | ||
updateIcon: `${PREFIX}updateIcon`, | ||
title: `${PREFIX}title`, | ||
message: `${PREFIX}message`, | ||
} | ||
|
||
const StyledModalContent = styled(Grid)(({ theme }) => ({ | ||
backgroundColor: theme.palette.colors.white, | ||
border: 'none', | ||
|
||
[`& .${classes.info}`]: { | ||
marginTop: 38, | ||
}, | ||
|
||
[`& .${classes.updateIcon}`]: { | ||
width: 102, | ||
height: 102, | ||
}, | ||
|
||
[`& .${classes.title}`]: { | ||
marginTop: 24, | ||
marginBottom: 16, | ||
textAlign: 'center', | ||
}, | ||
|
||
[`& .${classes.message}`]: { | ||
marginBottom: 32, | ||
textAlign: 'center', | ||
}, | ||
})) | ||
|
||
export interface UpdateModalProps { | ||
open: boolean | ||
handleClose: () => void | ||
buttons: ReactElement[] | ||
title: string | ||
message: string | ||
} | ||
|
||
export const UpdateModalComponent: React.FC<UpdateModalProps> = ({ open, handleClose, buttons, title, message }) => { | ||
return ( | ||
<Modal open={open} handleClose={handleClose}> | ||
<StyledModalContent container direction='column' alignItems='center' justifyContent='center'> | ||
<Grid className={classes.info}> | ||
<Icon src={updateIcon} /> | ||
</Grid> | ||
<Grid className={classes.title}> | ||
<Typography variant='h3'>{title}</Typography> | ||
</Grid> | ||
<Grid className={classes.message}> | ||
<Typography variant='body2'>{message}</Typography> | ||
</Grid> | ||
<Grid container direction='column' alignItems='center' spacing={2}> | ||
{buttons.map((button, index) => ( | ||
<Grid item xs={4} key={index}> | ||
{button} | ||
</Grid> | ||
))} | ||
</Grid> | ||
</StyledModalContent> | ||
</Modal> | ||
) | ||
} | ||
|
||
export default UpdateModalComponent |
Oops, something went wrong.