Skip to content

Commit

Permalink
[docs] Add demo for buttons with label and icon (mui#8922)
Browse files Browse the repository at this point in the history
* Added demo for buttons with label and icon

* Fix ESLint issue

* Fix some ESLint error :
- missing flow annotation
- no-unused-var
  • Loading branch information
wongjiahau authored and the-noob committed Nov 17, 2017
1 parent b1554c9 commit 906c2ba
Show file tree
Hide file tree
Showing 3 changed files with 78 additions and 0 deletions.
66 changes: 66 additions & 0 deletions docs/src/pages/demos/buttons/IconLabelButtons.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
// @flow weak

import React from 'react';
import PropTypes from 'prop-types';
import Button from 'material-ui/Button';
import { withStyles } from 'material-ui/styles';
import Delete from 'material-ui-icons/Delete';
import Done from 'material-ui-icons/Done';
import FileUpload from 'material-ui-icons/FileUpload';
import KeyboardVoice from 'material-ui-icons/KeyboardVoice';
import Save from 'material-ui-icons/Save';
import Send from 'material-ui-icons/Send';

const styles = theme => ({
button: {
margin: theme.spacing.unit,
},
leftIcon: {
marginRight: theme.spacing.unit,
},
rightIcon: {
marginLeft: theme.spacing.unit,
},
});

function IconLabelButtons(props) {
const { classes } = props;
return (
<div>
<div>
<Button className={classes.button} raised color="accent">
Delete
<Delete className={props.classes.rightIcon} />
</Button>
<Button className={classes.button} raised color="primary">
Send
<Send className={props.classes.rightIcon} />
</Button>
<Button className={classes.button} raised color="default">
Upload
<FileUpload className={props.classes.rightIcon} />
</Button>
</div>
<div>
<Button className={classes.button} raised color="contrast">
<Done className={props.classes.leftIcon} />
Done
</Button>
<Button className={classes.button} raised disabled color="accent">
<KeyboardVoice className={props.classes.leftIcon} />
Talk
</Button>
<Button className={classes.button} raised dense>
<Save className={props.classes.leftIcon} />
Save
</Button>
</div>
</div>
);
}

IconLabelButtons.propTypes = {
classes: PropTypes.object.isRequired,
};

export default withStyles(styles)(IconLabelButtons);
5 changes: 5 additions & 0 deletions docs/src/pages/demos/buttons/buttons.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,11 @@ Icons are also appropriate for toggle buttons that allow a single choice to be s

{{demo='pages/demos/buttons/IconButtons.js'}}

### Buttons with icons and label
Sometimes you might want to have icons for certain button to enhance the UX of the application as humans recognize logos more than plain text. For example, if you have a delete button you can label it with a dustbin icon.

{{demo='pages/demos/buttons/IconLabelButtons.js'}}

## Complex Buttons

The Flat Buttons, Raised Buttons, Floating Action Buttons and Icon Buttons are built on top of the same component: the `ButtonBase`.
Expand Down
7 changes: 7 additions & 0 deletions pages/demos/buttons.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,13 @@ module.exports = require('fs')
raw: preval`
module.exports = require('fs')
.readFileSync(require.resolve('docs/src/pages/demos/buttons/IconButtons'), 'utf8')
`,
},
'pages/demos/buttons/IconLabelButtons.js': {
js: require('docs/src/pages/demos/buttons/IconLabelButtons').default,
raw: preval`
module.exports = require('fs')
.readFileSync(require.resolve('docs/src/pages/demos/buttons/IconLabelButtons'), 'utf8')
`,
},
'pages/demos/buttons/ButtonBases.js': {
Expand Down

0 comments on commit 906c2ba

Please sign in to comment.