-
Notifications
You must be signed in to change notification settings - Fork 28
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add variant: 'dialog' and bindDialog
fix #90
- Loading branch information
1 parent
6533b92
commit e7ee393
Showing
10 changed files
with
232 additions
and
118 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
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
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,48 @@ | ||
import * as React from 'react' | ||
import Button from '@mui/material/Button' | ||
import Dialog from '@mui/material/Dialog' | ||
import DialogTitle from '@mui/material/DialogTitle' | ||
import DialogContent from '@mui/material/DialogContent' | ||
import DialogContentText from '@mui/material/DialogContentText' | ||
import DialogActions from '@mui/material/DialogActions' | ||
import { | ||
usePopupState, | ||
bindTrigger, | ||
bindDialog, | ||
} from 'material-ui-popup-state/hooks' | ||
|
||
const DialogPopupState = () => { | ||
const popupState = usePopupState({ | ||
variant: 'dialog', | ||
}) | ||
return ( | ||
<React.Fragment> | ||
<Button variant="contained" {...bindTrigger(popupState)}> | ||
Open Dialog | ||
</Button> | ||
<Dialog | ||
{...bindDialog(popupState)} | ||
aria-labelledby="alert-dialog-title" | ||
aria-describedby="alert-dialog-description" | ||
> | ||
<DialogTitle id="alert-dialog-title"> | ||
{"Use Google's location service?"} | ||
</DialogTitle> | ||
<DialogContent> | ||
<DialogContentText id="alert-dialog-description"> | ||
Let Google help apps determine location. This means sending | ||
anonymous location data to Google, even when no apps are running. | ||
</DialogContentText> | ||
</DialogContent> | ||
<DialogActions> | ||
<Button onClick={popupState.close}>Disagree</Button> | ||
<Button onClick={popupState.close} autoFocus> | ||
Agree | ||
</Button> | ||
</DialogActions> | ||
</Dialog> | ||
</React.Fragment> | ||
) | ||
} | ||
|
||
export default DialogPopupState |
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,43 @@ | ||
import * as React from 'react' | ||
import Button from '@mui/material/Button' | ||
import Dialog from '@mui/material/Dialog' | ||
import DialogTitle from '@mui/material/DialogTitle' | ||
import DialogContent from '@mui/material/DialogContent' | ||
import DialogContentText from '@mui/material/DialogContentText' | ||
import DialogActions from '@mui/material/DialogActions' | ||
import PopupState, { bindTrigger, bindDialog } from 'material-ui-popup-state' | ||
|
||
const DialogPopupState = () => ( | ||
<PopupState variant="dialog"> | ||
{(popupState) => ( | ||
<React.Fragment> | ||
<Button variant="contained" {...bindTrigger(popupState)}> | ||
Open Dialog | ||
</Button> | ||
<Dialog | ||
{...bindDialog(popupState)} | ||
aria-labelledby="alert-dialog-title" | ||
aria-describedby="alert-dialog-description" | ||
> | ||
<DialogTitle id="alert-dialog-title"> | ||
{"Use Google's location service?"} | ||
</DialogTitle> | ||
<DialogContent> | ||
<DialogContentText id="alert-dialog-description"> | ||
Let Google help apps determine location. This means sending | ||
anonymous location data to Google, even when no apps are running. | ||
</DialogContentText> | ||
</DialogContent> | ||
<DialogActions> | ||
<Button onClick={popupState.close}>Disagree</Button> | ||
<Button onClick={popupState.close} autoFocus> | ||
Agree | ||
</Button> | ||
</DialogActions> | ||
</Dialog> | ||
</React.Fragment> | ||
)} | ||
</PopupState> | ||
) | ||
|
||
export default DialogPopupState |
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
Oops, something went wrong.