Skip to content

Commit

Permalink
let's do crazy
Browse files Browse the repository at this point in the history
  • Loading branch information
oliviertassinari committed Dec 7, 2018
1 parent 485e4ba commit 802170a
Show file tree
Hide file tree
Showing 23 changed files with 259 additions and 189 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
112 changes: 112 additions & 0 deletions docs/src/pages/demos/dialogs/CustomizedDialog.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
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">
Cancel
</Button>
<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
145 changes: 0 additions & 145 deletions docs/src/pages/demos/dialogs/WithCloseButtonDialog.js

This file was deleted.

16 changes: 10 additions & 6 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 All @@ -80,12 +90,6 @@ Touching “Cancel” in a confirmation dialog, or pressing Back, cancels the ac

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

## Adding a close button

You can customize the `DialogTitle` to support a close button that will close the `Dialog` on click.

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

## Accessibility

Be sure to add `aria-labelledby="id..."`, referencing the modal title, to the `Dialog`. Additionally, you may give a description of your modal dialog with the `aria-describedby="id..."` property on the `Dialog`.
Expand Down
Loading

0 comments on commit 802170a

Please sign in to comment.