This repository was archived by the owner on May 14, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 115
Hover stylings #54
Open
mclin
wants to merge
5
commits into
alexkuz:master
Choose a base branch
from
dremio:hover_stylings
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Hover stylings #54
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
9ed0639
Allow overriding of root styling via prop
d90ce85
add react-dom as peer-dependency
4ea38f6
add hover param to node stylings
2942a13
remove react-dom peer-dep, remove getting styling from props, make mo…
fd41e02
remove constructor for JSONValueNode
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -92,9 +92,11 @@ export default class JSONNestedNode extends React.Component { | |
// calculate individual node expansion if necessary | ||
const expanded = props.shouldExpandNode && !props.isCircular ? | ||
props.shouldExpandNode(props.keyPath, props.data, props.level) : false; | ||
|
||
this.state = { | ||
expanded, | ||
createdChildNodes: false | ||
createdChildNodes: false, | ||
hover: false | ||
}; | ||
} | ||
|
||
|
@@ -114,7 +116,7 @@ export default class JSONNestedNode extends React.Component { | |
labelRenderer, | ||
expandable | ||
} = this.props; | ||
const expanded = this.state.expanded; | ||
const { expanded, hover } = this.state; | ||
const renderedChildren = expanded || (hideRoot && this.props.level === 0) ? | ||
renderChildNodes({ ...this.props, level: this.props.level + 1 }) : null; | ||
|
||
|
@@ -129,7 +131,7 @@ export default class JSONNestedNode extends React.Component { | |
itemType, | ||
createItemString(data, collectionLimit) | ||
); | ||
const stylingArgs = [keyPath, nodeType, expanded, expandable]; | ||
const stylingArgs = [keyPath, nodeType, expanded, expandable, hover]; | ||
|
||
return hideRoot ? ( | ||
<li {...styling('rootNode', ...stylingArgs)}> | ||
|
@@ -138,7 +140,11 @@ export default class JSONNestedNode extends React.Component { | |
</ul> | ||
</li> | ||
) : ( | ||
<li {...styling('nestedNode', ...stylingArgs)}> | ||
<li | ||
{...styling('nestedNode', ...stylingArgs)} | ||
onMouseOver={this.handleMouseOver} | ||
onMouseOut={this.handleMouseOut} | ||
> | ||
{expandable && | ||
<JSONArrow | ||
styling={styling} | ||
|
@@ -167,4 +173,11 @@ export default class JSONNestedNode extends React.Component { | |
} | ||
|
||
handleClick = () => this.setState({ expanded: !this.state.expanded }); | ||
|
||
handleMouseOver = (e) => { | ||
e.stopPropagation(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why do we need to stop propagation? |
||
this.setState({ hover: true }); | ||
}; | ||
|
||
handleMouseOut = () => this.setState({ hover: false }); | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe mouseEnter/mouseLeave are more appropriate here?