Clarify mouse interaction

This commit is contained in:
Thomas Nordquist
2019-01-15 19:00:37 +01:00
parent c6a0a15d95
commit f905ba8e89

View File

@@ -3,6 +3,7 @@ import * as q from '../../../../backend/src/Model'
import { Theme, withStyles } from '@material-ui/core/styles' import { Theme, withStyles } from '@material-ui/core/styles'
import LabelImportant from '@material-ui/icons/LabelImportant'
import TreeNodeSubnodes from './TreeNodeSubnodes' import TreeNodeSubnodes from './TreeNodeSubnodes'
import TreeNodeTitle from './TreeNodeTitle' import TreeNodeTitle from './TreeNodeTitle'
import { bindActionCreators } from 'redux' import { bindActionCreators } from 'redux'
@@ -29,6 +30,12 @@ const styles = (theme: Theme) => {
backgroundColor: 'rgba(80, 80, 80, 0.35)', backgroundColor: 'rgba(80, 80, 80, 0.35)',
}, },
}, },
topicSelect: {
float: 'right' as 'right',
opacity: 0,
cursor: 'pointer',
marginTop: '-1px',
},
} }
} }
@@ -61,6 +68,7 @@ class TreeNode extends React.Component<Props, State> {
private willUpdateTime: number = performance.now() private willUpdateTime: number = performance.now()
private titleRef = React.createRef<HTMLDivElement>() private titleRef = React.createRef<HTMLDivElement>()
private topicSelectRef = React.createRef<HTMLDivElement>()
private subnodesDidchange = () => { private subnodesDidchange = () => {
this.dirtySubnodes = true this.dirtySubnodes = true
@@ -155,6 +163,8 @@ class TreeNode extends React.Component<Props, State> {
className={`${classes.node} ${!this.props.isRoot ? classes.hover : ''}`} className={`${classes.node} ${!this.props.isRoot ? classes.hover : ''}`}
onClick={this.didClickNode} onClick={this.didClickNode}
style={this.props.style} style={this.props.style}
onMouseOver={this.mouseOver}
onMouseOut={this.mouseOut}
> >
<span ref={this.titleRef} style={animation}> <span ref={this.titleRef} style={animation}>
<TreeNodeTitle <TreeNodeTitle
@@ -164,11 +174,40 @@ class TreeNode extends React.Component<Props, State> {
lastUpdate={this.props.treeNode.lastUpdate} lastUpdate={this.props.treeNode.lastUpdate}
/> />
</span> </span>
<div
className={this.props.classes.topicSelect}
ref={this.topicSelectRef}
onClick={this.didSelectNode}
title="Select topic"
>
<LabelImportant style={{ fontSize: '14px' }} />
</div>
{this.renderNodes()} {this.renderNodes()}
</div> </div>
) )
} }
private mouseOver = (event: React.MouseEvent) => {
event.stopPropagation()
if (this.topicSelectRef.current) {
this.topicSelectRef.current.style.opacity = '1'
}
}
private mouseOut = (event: React.MouseEvent) => {
event.stopPropagation()
if (this.topicSelectRef.current) {
this.topicSelectRef.current.style.opacity = '0'
}
}
private didSelectNode = (event: React.MouseEvent) => {
event.stopPropagation()
if (this.topicSelectRef.current) {
this.topicSelectRef.current.style.opacity = '1'
}
this.props.actions.selectTopic(this.props.treeNode)
}
private didClickNode = (event: React.MouseEvent) => { private didClickNode = (event: React.MouseEvent) => {
event.stopPropagation() event.stopPropagation()
this.toggle() this.toggle()