Skip to content

Commit

Permalink
[Dialog] Prepare deprecation of withMobileDialog
Browse files Browse the repository at this point in the history
  • Loading branch information
oliviertassinari committed Jun 21, 2019
1 parent bd65310 commit b683999
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 23 deletions.
15 changes: 5 additions & 10 deletions docs/src/pages/components/dialogs/ResponsiveDialog.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
import React from 'react';
import PropTypes from 'prop-types';
import Button from '@material-ui/core/Button';
import Dialog from '@material-ui/core/Dialog';
import DialogActions from '@material-ui/core/DialogActions';
import DialogContent from '@material-ui/core/DialogContent';
import DialogContentText from '@material-ui/core/DialogContentText';
import DialogTitle from '@material-ui/core/DialogTitle';
import withMobileDialog from '@material-ui/core/withMobileDialog';
import useMediaQuery from '@material-ui/core/useMediaQuery';
import { useTheme } from '@material-ui/core/styles';

function ResponsiveDialog(props) {
const { fullScreen } = props;
export default function ResponsiveDialog() {
const [open, setOpen] = React.useState(false);
const theme = useTheme();
const fullScreen = useMediaQuery(theme.breakpoints.down('sm'));

function handleClickOpen() {
setOpen(true);
Expand Down Expand Up @@ -50,9 +51,3 @@ function ResponsiveDialog(props) {
</div>
);
}

ResponsiveDialog.propTypes = {
fullScreen: PropTypes.bool.isRequired,
};

export default withMobileDialog()(ResponsiveDialog);
17 changes: 5 additions & 12 deletions docs/src/pages/components/dialogs/ResponsiveDialog.tsx
Original file line number Diff line number Diff line change
@@ -1,18 +1,17 @@
import React from 'react';
import PropTypes from 'prop-types';
import Button from '@material-ui/core/Button';
import Dialog from '@material-ui/core/Dialog';
import DialogActions from '@material-ui/core/DialogActions';
import DialogContent from '@material-ui/core/DialogContent';
import DialogContentText from '@material-ui/core/DialogContentText';
import DialogTitle from '@material-ui/core/DialogTitle';
import withMobileDialog, { WithMobileDialog } from '@material-ui/core/withMobileDialog';
import useMediaQuery from '@material-ui/core/useMediaQuery';
import { useTheme } from '@material-ui/core/styles';

export type ResponsiveDialogProps = WithMobileDialog;

function ResponsiveDialog(props: ResponsiveDialogProps) {
const { fullScreen } = props;
export default function ResponsiveDialog() {
const [open, setOpen] = React.useState(false);
const theme = useTheme();
const fullScreen = useMediaQuery(theme.breakpoints.down('sm'));

function handleClickOpen() {
setOpen(true);
Expand Down Expand Up @@ -52,9 +51,3 @@ function ResponsiveDialog(props: ResponsiveDialogProps) {
</div>
);
}

ResponsiveDialog.propTypes = {
fullScreen: PropTypes.bool.isRequired,
};

export default withMobileDialog()(ResponsiveDialog);
13 changes: 12 additions & 1 deletion docs/src/pages/components/dialogs/dialogs.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,18 @@ When the `fullWidth` property is true, the dialog will adapt based on the `maxWi

## Responsive full-screen

You may make a dialog responsively full screen using `withMobileDialog`. By default, `withMobileDialog()(Dialog)` responsively full screens *at or below* the `sm` [screen size](/customization/breakpoints/). You can choose your own breakpoint for example `xs` by passing the `breakpoint` argument: `withMobileDialog({breakpoint: 'xs'})(Dialog)`.
You may make a dialog responsively full screen using [`useMediaQuery`](/components/use-media-query/#usemediaquery).

```jsx
import useMediaQuery from '@material-ui/core/useMediaQuery';

function MyComponent() {
const theme = useTheme();
const fullScreen = useMediaQuery(theme.breakpoints.down('sm'));

return <Dialog fullScreen={fullScreen} />
}
```

{{"demo": "pages/components/dialogs/ResponsiveDialog.js"}}

Expand Down

0 comments on commit b683999

Please sign in to comment.