Skip to content

Commit

Permalink
Updates on highlighting items in sidebar nav (#54)
Browse files Browse the repository at this point in the history
* Updates on highlighting items in sidebar nav

* Cleanup
  • Loading branch information
bedakb authored Jan 29, 2020
1 parent 7b611bd commit 19c1533
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 11 deletions.
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions src/sidebar/sidebar.less
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
cursor: pointer;

&:hover {
color: @gray-darkest;
color: @primary-color-variant;
}
}

Expand All @@ -59,4 +59,4 @@
word-break: keep-all;
}
}
}
}
10 changes: 8 additions & 2 deletions src/tree/node.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ interface Props {
const EXPANDED_CLASS = 'expanded';
const COLLAPSED_CLASS = 'collapsed';
const NO_CHILD_CLASS = 'no-child';
const LEAF_CLASS = 'leaf';
const HIGHLIGHTED_CLASS = 'highlighted';
const LEVEL_CLASS_PREFIX = 'level-';

Expand All @@ -35,10 +36,11 @@ class Node extends React.Component<Props, {}> {
role="listitem"
onClick={this.handleClick}
data-qa={`node-${this.props.node.id}`}
className={`node ${this.getHightlightedCLass()} ${LEVEL_CLASS_PREFIX + this.getLevel()}`}
className={`node ${this.getHightlightedCLass()} ${this.getLeafClass()} ${LEVEL_CLASS_PREFIX +
this.getLevel()}`}
>
<div className="node-content">
<span className={this.getClasses()} data-qa={`node--icon-${this.props.node.id}`} />
<span className={`node-icon ${this.getClasses()}`} data-qa={`node--icon-${this.props.node.id}`} />
<span className="node-label">{this.props.node.label}</span>
{this.isChildrenVisible() && <ul className="nodes">{this.getChildNodes()}</ul>}
</div>
Expand All @@ -50,6 +52,10 @@ class Node extends React.Component<Props, {}> {
return this.isHighlighted() ? HIGHLIGHTED_CLASS : '';
}

private getLeafClass() {
return !this.props.node.children ? LEAF_CLASS : '';
}

private getChildNodes() {
return this.props.node.children!.map((node) => (
<Node node={node} key={node.id} level={this.getNextLevel()} onNodeClick={this.props.onNodeClick} />
Expand Down
24 changes: 18 additions & 6 deletions src/tree/tree.less
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,6 @@
.level-1 {
padding-top: 5px;
padding-bottom: 5px;

&.highlighted > .node-content > .node-label {
color: @gray-darkest;
}
}

.nodes {
Expand All @@ -21,14 +17,30 @@
cursor: pointer;

&:hover {
.node-label {
.node-label, .node-icon {
color: @primary-color;
}
}

&.highlighted {
color: @primary-color;
font-weight: bold;

.node-content {
.node-label {
color: @gray-darkest;
}
.node-icon {
color: @primary-color-darker;
}
}

&.leaf {
.node-content {
.node-label, .node-icon {
color: @primary-color-darker;
}
}
}
}
}

Expand Down

0 comments on commit 19c1533

Please sign in to comment.