Skip to content

Commit

Permalink
Merge pull request #1048 from KaiVolland/treenode-extraclass
Browse files Browse the repository at this point in the history
Adds leaf/folder css-class to TreeNode
  • Loading branch information
KaiVolland committed Feb 22, 2019
2 parents 3aeca7b + 3131bd9 commit 9834bc7
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions src/LayerTreeNode/LayerTreeNode.jsx
Expand Up @@ -17,6 +17,7 @@ class LayerTreeNode extends React.PureComponent {
* @type {Object}
*/
static propTypes = {
children: PropTypes.array,
inResolutionRange: PropTypes.bool
}

Expand All @@ -37,16 +38,22 @@ class LayerTreeNode extends React.PureComponent {
render() {
const {
inResolutionRange,
children,
...passThroughProps
} = this.props;

const addClassName = (inResolutionRange ? 'within' : 'out-off') + '-range';
const isFolder = Array.isArray(children) && children.length > 0;
let addClassName = (inResolutionRange ? 'within' : 'out-off') + '-range';
addClassName += isFolder ? ' tree-folder' : ' tree-leaf';
const finalClassname = `${CSS_PREFIX}layertree-node ${addClassName}`;

return(
<TreeNode
className={finalClassname}
{...passThroughProps}
/>
>
{children}
</TreeNode>
);
}

Expand Down

0 comments on commit 9834bc7

Please sign in to comment.