diff options
| author | Dayana31 <[email protected]> | 2022-04-21 17:27:08 -0500 |
|---|---|---|
| committer | Dayana31 <[email protected]> | 2022-04-21 17:27:08 -0500 |
| commit | 67c50667678dd0ce4709b29a854f6a47093a1ac5 (patch) | |
| tree | b6f9f39092ad54bf6b815984d32b37d7c7ca67ab /front/odiparpack/app/components/Panel | |
| parent | 91140b24f0d49a9f89a080ee063e9eb023a4b73a (diff) | |
| parent | e13e630cd6e4fc0b1ff92098a28a770794c7bb9a (diff) | |
| download | DP1_project-67c50667678dd0ce4709b29a854f6a47093a1ac5.tar.gz DP1_project-67c50667678dd0ce4709b29a854f6a47093a1ac5.tar.bz2 DP1_project-67c50667678dd0ce4709b29a854f6a47093a1ac5.zip | |
Merge branch 'gabshr' into dayana
Diffstat (limited to 'front/odiparpack/app/components/Panel')
| -rw-r--r-- | front/odiparpack/app/components/Panel/FloatingPanel.js | 90 | ||||
| -rw-r--r-- | front/odiparpack/app/components/Panel/panel-jss.js | 95 |
2 files changed, 185 insertions, 0 deletions
diff --git a/front/odiparpack/app/components/Panel/FloatingPanel.js b/front/odiparpack/app/components/Panel/FloatingPanel.js new file mode 100644 index 0000000..675166a --- /dev/null +++ b/front/odiparpack/app/components/Panel/FloatingPanel.js @@ -0,0 +1,90 @@ +import React from 'react'; +import PropTypes from 'prop-types'; +import { withStyles } from '@material-ui/core/styles'; +import { isWidthDown } from '@material-ui/core/withWidth'; +import classNames from 'classnames'; +import CloseIcon from '@material-ui/icons/Close'; +import ExpandIcon from '@material-ui/icons/CallMade'; +import MinimizeIcon from '@material-ui/icons/CallReceived'; +import { withWidth, Tooltip, IconButton } from '@material-ui/core'; +import styles from './panel-jss'; + + +class FloatingPanel extends React.Component { + state = { + expanded: false + } + + toggleExpand() { + this.setState({ expanded: !this.state.expanded }); + } + + render() { + const { + classes, + openForm, + closeForm, + children, + branch, + title, + extraSize, + width + } = this.props; + const { expanded } = this.state; + return ( + <div> + <div className={ + classNames( + classes.formOverlay, + openForm && (isWidthDown('sm', width) || expanded) ? classes.showForm : classes.hideForm + )} + /> + <section className={ + classNames( + !openForm ? classes.hideForm : classes.showForm, + expanded ? classes.expanded : '', + classes.floatingForm, + classes.formTheme, + extraSize && classes.large + )} + > + <header> + { title } + <div className={classes.btnOpt}> + <Tooltip title={expanded ? 'Exit Full Screen' : 'Full Screen'}> + <IconButton className={classes.expandButton} onClick={() => this.toggleExpand()} aria-label="Expand"> + {expanded ? <MinimizeIcon /> : <ExpandIcon />} + </IconButton> + </Tooltip> + <Tooltip title="Close"> + <IconButton className={classes.closeButton} onClick={() => closeForm(branch)} aria-label="Close"> + <CloseIcon /> + </IconButton> + </Tooltip> + </div> + </header> + {children} + </section> + </div> + ); + } +} + +FloatingPanel.propTypes = { + classes: PropTypes.object.isRequired, + openForm: PropTypes.bool.isRequired, + closeForm: PropTypes.func.isRequired, + children: PropTypes.node.isRequired, + branch: PropTypes.string.isRequired, + width: PropTypes.string.isRequired, + title: PropTypes.string, + extraSize: PropTypes.bool, +}; + +FloatingPanel.defaultProps = { + title: 'Add New Item', + extraSize: false, +}; + +const FloatingPanelResponsive = withWidth()(FloatingPanel); +export default withStyles(styles)(FloatingPanelResponsive); diff --git a/front/odiparpack/app/components/Panel/panel-jss.js b/front/odiparpack/app/components/Panel/panel-jss.js new file mode 100644 index 0000000..d5d5e9c --- /dev/null +++ b/front/odiparpack/app/components/Panel/panel-jss.js @@ -0,0 +1,95 @@ +import { darken } from '@material-ui/core/styles/colorManipulator'; +const expand = { + bottom: 'auto', + right: 'auto', + left: '50%', + top: '50%', + transform: 'translateX(-50%) translateY(-50%)' +}; + +const styles = theme => ({ + formTheme: { + background: darken(theme.palette.primary.dark, 0.2), + boxShadow: theme.shadows[7] + }, + hideForm: { + display: 'none' + }, + showForm: { + display: 'block' + }, + btnOpt: {}, + expandButton: { + [theme.breakpoints.down('sm')]: { + display: 'none' + } + }, + floatingForm: { + position: 'fixed', + width: 500, + bottom: 10, + right: 10, + zIndex: 1300, + borderRadius: 3, + overflow: 'hidden', + [theme.breakpoints.down('sm')]: { + width: '95% !important', + ...expand + }, + '& header': { + color: theme.palette.common.white, + padding: '15px 20px', + '& $btnOpt': { + position: 'absolute', + right: 0, + top: 0, + '& > *': { + margin: '0 5px' + }, + '& $expandButton': { + transform: 'rotate(270deg)' + }, + '& svg': { + fill: theme.palette.common.white, + } + } + }, + }, + bodyForm: { + position: 'relative', + background: theme.palette.common.white, + padding: '15px 30px', + maxHeight: 900, + overflow: 'auto' + }, + buttonArea: { + background: theme.palette.grey[100], + position: 'relative', + bottom: 0, + left: 0, + width: '100%', + textAlign: 'right', + padding: '10px 30px', + '& button': { + marginRight: 5 + } + }, + expanded: { + ...expand + }, + formOverlay: { + position: 'fixed', + background: theme.palette.grey[900], + opacity: 0.7, + width: '100%', + height: '100%', + top: 0, + left: 0, + zIndex: 1300, + }, + large: { + width: 650 + } +}); + +export default styles; |
