Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[docs] Add demo for buttons with label and icon #8922

Merged
merged 3 commits into from
Oct 31, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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