diff --git a/src/components/TreeNode/Header.js b/src/components/TreeNode/Header.js deleted file mode 100644 index 9677d48..0000000 --- a/src/components/TreeNode/Header.js +++ /dev/null @@ -1,18 +0,0 @@ -import React from 'react'; -import PropTypes from 'prop-types'; - -import NodeHeader from '../header'; - -const Header = ({animations, decorators, style, node, onClick}) => ( - -); - -Header.propTypes = { - onClick: PropTypes.func.isRequired, - animations: PropTypes.oneOfType([PropTypes.object, PropTypes.bool]).isRequired, - style: PropTypes.object.isRequired, - node: PropTypes.object.isRequired, - decorators: PropTypes.object.isRequired -}; - -export default Header; diff --git a/src/components/TreeNode/index.js b/src/components/TreeNode/index.js index 875b272..4c320f5 100644 --- a/src/components/TreeNode/index.js +++ b/src/components/TreeNode/index.js @@ -3,8 +3,9 @@ import PropTypes from 'prop-types'; import styled from '@emotion/styled'; import {isArray} from 'lodash'; +import defaultAnimations from '../../themes/animations'; +import NodeHeader from '../header'; import Drawer from './Drawer'; -import Header from './Header'; import Loading from './Loading'; const Li = styled('li', { @@ -27,7 +28,9 @@ class TreeNode extends PureComponent { animations() { const {animations, node} = this.props; if (!animations) { - return false; + return { + toggle: defaultAnimations.toggle(this.props, 0) + }; } const animation = Object.assign({}, animations, node.animations); return { @@ -105,7 +108,7 @@ class TreeNode extends PureComponent { this.topLevelRef = ref; }} style={style.base}> -
this.onClick()}/> + this.onClick()}/> {this.renderDrawer(decorators, animations)} ); diff --git a/src/components/decorators.js b/src/components/decorators.js index f79e53a..51449b5 100644 --- a/src/components/decorators.js +++ b/src/components/decorators.js @@ -27,8 +27,7 @@ const Toggle = ({style}) => {
- +
diff --git a/src/components/treebeard.js b/src/components/treebeard.js index 947ad6c..df70460 100644 --- a/src/components/treebeard.js +++ b/src/components/treebeard.js @@ -14,12 +14,13 @@ const Ul = styled('ul', { const TreeBeard = ({animations, decorators, data, onToggle, style}) => (
    - {castArray(data).map((node, index) => + {castArray(data).map(node => ( - )} + {...{decorators, node, onToggle, animations}} + key={node.id} + style={{...defaultTheme.tree.node, ...style.tree.node}} + /> + ))}
); diff --git a/src/themes/animations.js b/src/themes/animations.js index 6b71b8b..ba479b7 100644 --- a/src/themes/animations.js +++ b/src/themes/animations.js @@ -1,9 +1,7 @@ - - export default { - toggle: ({node: {toggled}}) => ({ + toggle: ({node: {toggled}}, duration = 300) => ({ animation: {rotateZ: toggled ? 90 : 0}, - duration: 300 + duration: duration }), drawer: (/* props */) => ({ enter: { diff --git a/src/themes/default.js b/src/themes/default.js index 0d7f39d..6506bae 100644 --- a/src/themes/default.js +++ b/src/themes/default.js @@ -1,5 +1,3 @@ - - export default { tree: { base: {