Skip to content

Commit

Permalink
[Dialog] Add dialog with close button to demos (#13845)
Browse files Browse the repository at this point in the history
* Add dialog with close button to demos

* let's do crazy
  • Loading branch information
rfbotto authored and oliviertassinari committed Dec 7, 2018
1 parent a1e4d4b commit 29eae3a
Show file tree
Hide file tree
Showing 22 changed files with 260 additions and 35 deletions.
6 changes: 6 additions & 0 deletions docs/src/pages/demos/badges/badges.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,10 @@ The visibility of badges can be controlled using the `invisible` property.

## Customized Badge

If you have been reading the [overrides documentation page](/customization/overrides/)
but you are not confident jumping in,
here is one example of how you can change the badge position.

⚠️ While the material design specification encourages theming, this example is off the beaten path.

{{"demo": "pages/demos/badges/CustomizedBadge.js"}}
2 changes: 2 additions & 0 deletions docs/src/pages/demos/buttons/buttons.md
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,8 @@ but you are not confident jumping in,
here are examples of how you can change the main color of a Button using classes,
and using a theme; and of a Bootstrap style Button.

⚠️ While the material design specification encourages theming, these examples are off the beaten path.

{{"demo": "pages/demos/buttons/CustomizedButtons.js"}}

## Complex Buttons
Expand Down
4 changes: 3 additions & 1 deletion docs/src/pages/demos/dialogs/AlertDialog.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,9 @@ class AlertDialog extends React.Component {
render() {
return (
<div>
<Button onClick={this.handleClickOpen}>Open alert dialog</Button>
<Button variant="outlined" color="primary" onClick={this.handleClickOpen}>
Open alert dialog
</Button>
<Dialog
open={this.state.open}
onClose={this.handleClose}
Expand Down
4 changes: 3 additions & 1 deletion docs/src/pages/demos/dialogs/AlertDialogSlide.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,9 @@ class AlertDialogSlide extends React.Component {
render() {
return (
<div>
<Button onClick={this.handleClickOpen}>Slide in alert dialog</Button>
<Button variant="outlined" color="primary" onClick={this.handleClickOpen}>
Slide in alert dialog
</Button>
<Dialog
open={this.state.open}
TransitionComponent={Transition}
Expand Down
109 changes: 109 additions & 0 deletions docs/src/pages/demos/dialogs/CustomizedDialog.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
import React from 'react';
import { withStyles } from '@material-ui/core/styles';
import Button from '@material-ui/core/Button';
import Dialog from '@material-ui/core/Dialog';
import MuiDialogTitle from '@material-ui/core/DialogTitle';
import MuiDialogContent from '@material-ui/core/DialogContent';
import MuiDialogActions from '@material-ui/core/DialogActions';
import IconButton from '@material-ui/core/IconButton';
import CloseIcon from '@material-ui/icons/Close';
import Typography from '@material-ui/core/Typography';

const DialogTitle = withStyles(theme => ({
root: {
borderBottom: `1px solid ${theme.palette.divider}`,
margin: 0,
padding: theme.spacing.unit * 2,
},
closeButton: {
position: 'absolute',
right: theme.spacing.unit,
top: theme.spacing.unit,
color: theme.palette.grey[500],
},
}))(props => {
const { children, classes, onClose } = props;
return (
<MuiDialogTitle disableTypography className={classes.root}>
<Typography variant="h6">{children}</Typography>
{onClose ? (
<IconButton aria-label="Close" className={classes.closeButton} onClick={onClose}>
<CloseIcon />
</IconButton>
) : null}
</MuiDialogTitle>
);
});

const DialogContent = withStyles(theme => ({
root: {
margin: 0,
padding: theme.spacing.unit * 2,
},
}))(MuiDialogContent);

const DialogActions = withStyles(theme => ({
root: {
borderTop: `1px solid ${theme.palette.divider}`,
margin: 0,
padding: theme.spacing.unit,
},
}))(MuiDialogActions);

class CustomizedDialogDemo extends React.Component {
state = {
open: false,
};

handleClickOpen = () => {
this.setState({
open: true,
});
};

handleClose = () => {
this.setState({ open: false });
};

render() {
return (
<div>
<Button variant="outlined" color="secondary" onClick={this.handleClickOpen}>
Open dialog
</Button>
<Dialog
onClose={this.handleClose}
aria-labelledby="customized-dialog-title"
open={this.state.open}
>
<DialogTitle id="customized-dialog-title" onClose={this.handleClose}>
Modal title
</DialogTitle>
<DialogContent>
<Typography gutterBottom>
Cras mattis consectetur purus sit amet fermentum. Cras justo odio, dapibus ac
facilisis in, egestas eget quam. Morbi leo risus, porta ac consectetur ac, vestibulum
at eros.
</Typography>
<Typography gutterBottom>
Praesent commodo cursus magna, vel scelerisque nisl consectetur et. Vivamus sagittis
lacus vel augue laoreet rutrum faucibus dolor auctor.
</Typography>
<Typography gutterBottom>
Aenean lacinia bibendum nulla sed consectetur. Praesent commodo cursus magna, vel
scelerisque nisl consectetur et. Donec sed odio dui. Donec ullamcorper nulla non metus
auctor fringilla.
</Typography>
</DialogContent>
<DialogActions>
<Button onClick={this.handleClose} color="primary">
Save changes
</Button>
</DialogActions>
</Dialog>
</div>
);
}
}

export default CustomizedDialogDemo;
4 changes: 3 additions & 1 deletion docs/src/pages/demos/dialogs/FormDialog.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,9 @@ export default class FormDialog extends React.Component {
render() {
return (
<div>
<Button onClick={this.handleClickOpen}>Open form dialog</Button>
<Button variant="outlined" color="primary" onClick={this.handleClickOpen}>
Open form dialog
</Button>
<Dialog
open={this.state.open}
onClose={this.handleClose}
Expand Down
4 changes: 3 additions & 1 deletion docs/src/pages/demos/dialogs/FullScreenDialog.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,9 @@ class FullScreenDialog extends React.Component {
const { classes } = this.props;
return (
<div>
<Button onClick={this.handleClickOpen}>Open full-screen dialog</Button>
<Button variant="outlined" color="primary" onClick={this.handleClickOpen}>
Open full-screen dialog
</Button>
<Dialog
fullScreen
open={this.state.open}
Expand Down
4 changes: 3 additions & 1 deletion docs/src/pages/demos/dialogs/MaxWidthDialog.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,9 @@ class MaxWidthDialog extends React.Component {

return (
<React.Fragment>
<Button onClick={this.handleClickOpen}>Open max-width dialog</Button>
<Button variant="outlined" color="primary" onClick={this.handleClickOpen}>
Open max-width dialog
</Button>
<Dialog
fullWidth={this.state.fullWidth}
maxWidth={this.state.maxWidth}
Expand Down
4 changes: 3 additions & 1 deletion docs/src/pages/demos/dialogs/ResponsiveDialog.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,9 @@ class ResponsiveDialog extends React.Component {

return (
<div>
<Button onClick={this.handleClickOpen}>Open responsive dialog</Button>
<Button variant="outlined" color="primary" onClick={this.handleClickOpen}>
Open responsive dialog
</Button>
<Dialog
fullScreen={fullScreen}
open={this.state.open}
Expand Down
4 changes: 3 additions & 1 deletion docs/src/pages/demos/dialogs/SimpleDialog.js
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,9 @@ class SimpleDialogDemo extends React.Component {
<div>
<Typography variant="subtitle1">Selected: {this.state.selectedValue}</Typography>
<br />
<Button onClick={this.handleClickOpen}>Open simple dialog</Button>
<Button variant="outlined" color="primary" onClick={this.handleClickOpen}>
Open simple dialog
</Button>
<SimpleDialogWrapped
selectedValue={this.state.selectedValue}
open={this.state.open}
Expand Down
10 changes: 10 additions & 0 deletions docs/src/pages/demos/dialogs/dialogs.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,16 @@ For example, if your site prompts for potential subscribers to fill in their ema

{{"demo": "pages/demos/dialogs/FormDialog.js"}}

## Customized dialog

If you have been reading the [overrides documentation page](/customization/overrides/)
but you are not confident jumping in,
here is one example of how you can customize the `DialogTitle` to support a close button.

⚠️ While the material design specification encourages theming, this example is off the beaten path.

{{"demo": "pages/demos/dialogs/CustomizedDialog.js"}}

## Full-screen dialogs

{{"demo": "pages/demos/dialogs/FullScreenDialog.js"}}
Expand Down
10 changes: 7 additions & 3 deletions docs/src/pages/demos/menus/menus.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,16 @@ The primary responsibility of the `MenuList` component is to handle the focus.

## Customized MenuItem

The `MenuItem` is a wrapper around `ListItem` with some additional styles.
You can use the same list composition features with the `MenuItem` component:
If you have been reading the [overrides documentation page](/customization/overrides/)
but you are not confident jumping in,
here is one example of how you can customize the `MenuItem`.

⚠️ While the material design specification encourages theming, this example is off the beaten path.

{{"demo": "pages/demos/menus/ListItemComposition.js"}}

If text in a simple menu wraps to a second line, use a simple dialog instead. Simple dialogs can have rows with varying heights.
The `MenuItem` is a wrapper around `ListItem` with some additional styles.
You can use the same list composition features with the `MenuItem` component:

## Max height menus

Expand Down
5 changes: 5 additions & 0 deletions docs/src/pages/demos/progress/progress.md
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,13 @@ function Progress(props) {

## Customized Progress

If you have been reading the [overrides documentation page](/customization/overrides/)
but you are not confident jumping in,
here is one example of how you can customize the components.
The last demo demonstrates how you can build a Facebook like spinner.

⚠️ While the material design specification encourages theming, these examples are off the beaten path.

{{"demo": "pages/demos/progress/CustomizedProgress.js"}}

## Delaying appearance
Expand Down
2 changes: 2 additions & 0 deletions docs/src/pages/demos/selection-controls/selection-controls.md
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,8 @@ However, we encourage you to use a [Checkbox](#checkboxes) instead.
If you have been reading the [overrides documentation page](/customization/overrides/)
but you are not confident jumping in, here's an example of how you can change the color of a Switch, and an iOS style Switch.

⚠️ While the material design specification encourages theming, these examples are off the beaten path.

{{"demo": "pages/demos/selection-controls/CustomizedSwitches.js"}}

## Label placement
Expand Down
2 changes: 2 additions & 0 deletions docs/src/pages/demos/snackbars/snackbars.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ If you have been reading the [overrides documentation page](/customization/overr
but you are not confident jumping in,
here are examples of how you can change the look of a Snackbar.

⚠️ While the material design specification encourages theming, these examples are off the beaten path.

{{"demo": "pages/demos/snackbars/CustomizedSnackbars.js"}}

## Positioned
Expand Down
6 changes: 6 additions & 0 deletions docs/src/pages/demos/steppers/steppers.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,14 @@ Labels can be placed below the step icon by setting the `alternativeLabel` prope

## Customized Stepper

If you have been reading the [overrides documentation page](/customization/overrides/)
but you are not confident jumping in,
here are examples of how you can change the look of a stepper.

This component uses a customized `StepConnector` element that changes border color based on the `active` and `completed` state.

⚠️ While the material design specification encourages theming, these examples are off the beaten path.

{{"demo": "pages/demos/steppers/CustomizedStepper.js"}}

## Mobile Stepper
Expand Down
6 changes: 5 additions & 1 deletion docs/src/pages/demos/tables/tables.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,11 @@ The Table has been given a fixed width to demonstrate horizontal scrolling. In o

## Customized Tables

You can customize the look and feel of the table by overriding the styles of the `TableCell` component.
If you have been reading the [overrides documentation page](/customization/overrides/)
but you are not confident jumping in,
here are examples of how you can change the look of a `TableCell`.

⚠️ While the material design specification encourages theming, this example is off the beaten path.

{{"demo": "pages/demos/tables/CustomizedTable.js"}}

Expand Down
4 changes: 3 additions & 1 deletion docs/src/pages/demos/tabs/tabs.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,9 @@ Left and right scroll buttons will never be presented. All scrolling must be in
## Customized Tabs

If you have read the [overrides documentation page](/customization/overrides/)
but aren't confident jumping in, here's an example of how you can change the main color of the Tabs. The following demo matches the [Ant Design UI](https://ant.design/components/tabs/).
but aren't confident jumping in, here's an example of how you can change the main color of the Tabs.

⚠️ While the material design specification encourages theming, this example is off the beaten path.

{{"demo": "pages/demos/tabs/CustomizedTabs.js"}}

Expand Down
2 changes: 2 additions & 0 deletions docs/src/pages/demos/text-fields/text-fields.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@ The component takes care of the most used properties, then it's up to the user t
If you have been reading the [overrides documentation page](/customization/overrides/)
but you are not confident jumping in, here's an example of how you can change the main color of an Input.

⚠️ While the material design specification encourages theming, these examples are off the beaten path.

{{"demo": "pages/demos/text-fields/CustomizedInputs.js"}}

## Input Adornments
Expand Down
Loading

0 comments on commit 29eae3a

Please sign in to comment.