Skip to content

Instantly share code, notes, and snippets.

@eggei
Last active January 15, 2021 20:14
Show Gist options
  • Save eggei/49fe7ef470fd4855a022543b782d9d54 to your computer and use it in GitHub Desktop.
Save eggei/49fe7ef470fd4855a022543b782d9d54 to your computer and use it in GitHub Desktop.
Abstraction or no abstraction?
/* MUI interface for modals */
<Dialog
open={openSaveDialog}
onClose={toggle}
aria-labelledby="form-dialog-title"
maxWidth="sm"
fullWidth
>
<DialogTitle>{title}</DialogTitle>
<DialogContent>{content}</DialogContent>
<DialogActions>
<Button onClick={toggle}>Cancel</Button>
<Button type="submit">Save</Button>
</DialogActions>
</Dialog>
/* This is how we could abstract it and wrap it with some default configs */
<Modal
id="id"
fullWidth
open={openSaveDialog}
onClose={toggle}
modalTitle={title}
modalContent={content}
actionButtons={[
{
label: 'Cancel',
onClick: toggle,
},
{ label: 'Save', type: 'submit' },
]}
/>
@eggei
Copy link
Author

eggei commented Jan 15, 2021

Can anyone see any advantage in having MUI Dialog interface wrapped as shown in the latter abstraction?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment