From f905ba8e892bcc38d46df6174bc722fdc11e8fa4 Mon Sep 17 00:00:00 2001 From: Thomas Nordquist Date: Tue, 15 Jan 2019 19:00:37 +0100 Subject: [PATCH] Clarify mouse interaction --- app/src/components/Tree/TreeNode.tsx | 39 ++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/app/src/components/Tree/TreeNode.tsx b/app/src/components/Tree/TreeNode.tsx index f82939c..7492334 100644 --- a/app/src/components/Tree/TreeNode.tsx +++ b/app/src/components/Tree/TreeNode.tsx @@ -3,6 +3,7 @@ import * as q from '../../../../backend/src/Model' import { Theme, withStyles } from '@material-ui/core/styles' +import LabelImportant from '@material-ui/icons/LabelImportant' import TreeNodeSubnodes from './TreeNodeSubnodes' import TreeNodeTitle from './TreeNodeTitle' import { bindActionCreators } from 'redux' @@ -29,6 +30,12 @@ const styles = (theme: Theme) => { 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 { private willUpdateTime: number = performance.now() private titleRef = React.createRef() + private topicSelectRef = React.createRef() private subnodesDidchange = () => { this.dirtySubnodes = true @@ -155,6 +163,8 @@ class TreeNode extends React.Component { className={`${classes.node} ${!this.props.isRoot ? classes.hover : ''}`} onClick={this.didClickNode} style={this.props.style} + onMouseOver={this.mouseOver} + onMouseOut={this.mouseOut} > { lastUpdate={this.props.treeNode.lastUpdate} /> +
+ +
{this.renderNodes()} ) } + 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) => { event.stopPropagation() this.toggle()