Skip to content
This repository has been archived by the owner on Nov 6, 2020. It is now read-only.

Commit

Permalink
feat(node): add className prop to node
Browse files Browse the repository at this point in the history
  • Loading branch information
Mohammer5 authored and varl committed Nov 25, 2019
1 parent 40d86a0 commit 1468e35
Showing 1 changed file with 15 additions and 8 deletions.
23 changes: 15 additions & 8 deletions src/Node.js
Original file line number Diff line number Diff line change
Expand Up @@ -111,15 +111,20 @@ Content.propTypes = {
*
* @see Live demo: {@link /demo/?path=/story/node--multiple-roots|Storybook}
*/
export const Node = ({ open, component, children, onOpen, onClose }) => {
export const Node = ({
open,
className,
component,
children,
onOpen,
onClose,
}) => {
const hasLeaves = !!React.Children.toArray(children).filter(i => i).length
const className = cx('tree', {
open,
'has-leaves': hasLeaves,
})

return (
<div className={className}>
<div
className={cx('tree', className, { open, 'has-leaves': hasLeaves })}
>
<Arrow
open={open}
hasLeaves={hasLeaves}
Expand All @@ -143,15 +148,17 @@ export const Node = ({ open, component, children, onOpen, onClose }) => {
/**
* @typedef {Object} PropTypes
* @static
* @prop {Node} [children]
* @prop {Element} component
* @prop {className} [string]
* @prop {Node} [children]
* @prop {boolean} [open]
* @prop {function} [onOpen]
* @prop {funtion} [onClose]
*/
Node.propTypes = {
children: propTypes.node,
component: propTypes.element.isRequired,
children: propTypes.node,
className: propTypes.string,
open: propTypes.bool,
onOpen: propTypes.func,
onClose: propTypes.func,
Expand Down

0 comments on commit 1468e35

Please sign in to comment.