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

Added demo of transitionFab #9028

Closed
wants to merge 1 commit into from
Closed
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
62 changes: 62 additions & 0 deletions docs/src/pages/demos/buttons/TransitionFab.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
// @flow weak

import React from 'react';
import PropTypes from 'prop-types';
import { withStyles } from 'material-ui/styles';
import Button from 'material-ui/Button';
import AddIcon from 'material-ui-icons/Add';
import ModeEditIcon from 'material-ui-icons/ModeEdit';
import CloseIcon from 'material-ui-icons/Close';
import AccountCircle from 'material-ui-icons/AccountCircle';

const styles = theme => ({
button: {
margin: theme.spacing.unit,
display: 'block',
},
});

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

toggleOpen = () => {
const { open } = this.state;
this.setState({ open: !open });
};

render() {
const { classes } = this.props;
const { open } = this.state;
return (
<div>
{open && (
<div className={classes.fabcontainer}>
<Button fab color="accent" aria-label="edit" className={classes.button}>
<ModeEditIcon />
</Button>
<Button fab color="accent" aria-label="edit" className={classes.button}>
<AccountCircle />
</Button>
</div>
)}
<Button
fab
color="primary"
aria-label="add"
className={classes.button}
onClick={this.toggleOpen}
>
{open ? <CloseIcon /> : <AddIcon />}
</Button>
</div>
);
}
}

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

export default withStyles(styles)(TransitionFab);
6 changes: 6 additions & 0 deletions docs/src/pages/demos/buttons/buttons.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,12 @@ Sometimes you might want to have icons for certain button to enhance the UX of t

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

### TransitionFab Buttons

A FAB that reveals other fabs when clicked, and hides them when clicked again.

{{demo='pages/demos/buttons/TransitionFab.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 @@ -43,6 +43,13 @@ module.exports = require('fs')
raw: preval`
module.exports = require('fs')
.readFileSync(require.resolve('docs/src/pages/demos/buttons/IconLabelButtons'), 'utf8')
`,
},
'pages/demos/buttons/TransitionFab.js': {
js: require('docs/src/pages/demos/buttons/TransitionFab').default,
raw: preval`
module.exports = require('fs')
.readFileSync(require.resolve('docs/src/pages/demos/buttons/TransitionFab'), 'utf8')
`,
},
'pages/demos/buttons/ButtonBases.js': {
Expand Down