Skip to content
Snippets Groups Projects
Commit e3ae4806 authored by vkovtun's avatar vkovtun
Browse files

SSDM-13579: Improved buttons hiding functionality on resize to the left toolbar.

parent b9d35e84
No related branches found
No related tags found
1 merge request!40SSDM-13578 : 2PT : Database and V3 Implementation - include the new AFS "free"...
...@@ -31,6 +31,8 @@ import logger from "@src/js/common/logger.js"; ...@@ -31,6 +31,8 @@ import logger from "@src/js/common/logger.js";
import autoBind from "auto-bind"; import autoBind from "auto-bind";
import IconButton from "@material-ui/core/IconButton"; import IconButton from "@material-ui/core/IconButton";
import { debounce } from "@material-ui/core"; import { debounce } from "@material-ui/core";
import Container from "@src/js/components/common/form/Container.jsx";
import Popover from "@material-ui/core/Popover";
const color = 'secondary' const color = 'secondary'
const iconButtonSize = 'medium' const iconButtonSize = 'medium'
...@@ -49,7 +51,17 @@ const styles = theme => ({ ...@@ -49,7 +51,17 @@ const styles = theme => ({
marginRight: 0 marginRight: 0
} }
}, },
toggleButton: {} toggleButton: {},
collapsedButtonsContainer: {
display: 'flex',
flexDirection: 'column',
'&>button': {
marginBottom: theme.spacing(1)
},
'&>button:nth-last-child(1)': {
marginBottom: 0
}
},
}) })
class LeftToolbar extends React.Component { class LeftToolbar extends React.Component {
...@@ -59,7 +71,8 @@ class LeftToolbar extends React.Component { ...@@ -59,7 +71,8 @@ class LeftToolbar extends React.Component {
autoBind(this) autoBind(this)
this.state = { this.state = {
width: 0 width: 0,
hiddenButtonsPopup: null
} }
this.controller = this.props.controller this.controller = this.props.controller
...@@ -84,7 +97,7 @@ class LeftToolbar extends React.Component { ...@@ -84,7 +97,7 @@ class LeftToolbar extends React.Component {
renderSelectionContextToolbar() { renderSelectionContextToolbar() {
const { classes, buttonSize } = this.props const { classes, buttonSize } = this.props
const { width } = this.state const { width, hiddenButtonsPopup } = this.state
const ellipsisButtonSize = 24 const ellipsisButtonSize = 24
const buttonsCount = 5 const buttonsCount = 5
...@@ -147,31 +160,71 @@ class LeftToolbar extends React.Component { ...@@ -147,31 +160,71 @@ class LeftToolbar extends React.Component {
] ]
const ellipsisButton = ( const ellipsisButton = (
<IconButton <IconButton
key="ellipsis" key='ellipsis'
classes={{ root: classes.button }} classes={{ root: classes.button }}
color={color} color={color}
size={iconButtonSize} size={iconButtonSize}
variant="outlined" variant='outlined'
onClick={this.handleOpen}
> >
<MoreIcon /> <MoreIcon />
</IconButton> </IconButton>
); )
const popover = (
<Popover
open={Boolean(hiddenButtonsPopup)}
anchorEl={hiddenButtonsPopup}
onClose={this.handleClose}
anchorOrigin={{
vertical: 'bottom',
horizontal: 'left'
}}
transformOrigin={{
vertical: 'top',
horizontal: 'left'
}}
>
<Container square={true}>{this.renderCollapsedButtons(buttons.slice(visibleButtonsCount))}</Container>
</Popover>
)
return ( return (
<div className={classes.buttons}> <div className={classes.buttons}>
{hideButtons {hideButtons
? [...buttons.slice(0, visibleButtonsCount), ellipsisButton] ? [...buttons.slice(0, visibleButtonsCount), ellipsisButton, popover]
: buttons} : buttons}
</div> </div>
); );
} }
renderCollapsedButtons(buttons) {
const { classes } = this.props
return (
<div className={classes.collapsedButtonsContainer}>
{buttons}
</div>
)
}
onResize({ width }) { onResize({ width }) {
if (width !== this.state.width) { if (width !== this.state.width) {
this.setState({ width }) this.setState({ width, hiddenButtonsPopup: null })
} }
} }
handleOpen(event) {
this.setState({
hiddenButtonsPopup: event.currentTarget
})
}
handleClose() {
this.setState({
hiddenButtonsPopup: null
})
}
render() { render() {
logger.log(logger.DEBUG, 'LeftToolbar.render') logger.log(logger.DEBUG, 'LeftToolbar.render')
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment