Skip to content
This repository has been archived by the owner on Jan 16, 2023. It is now read-only.

fix(treeNode): if not exists animations set duration in zero #174

Merged
merged 1 commit into from
Mar 30, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 0 additions & 18 deletions src/components/TreeNode/Header.js

This file was deleted.

9 changes: 6 additions & 3 deletions src/components/TreeNode/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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', {
Expand All @@ -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 {
Expand Down Expand Up @@ -105,7 +108,7 @@ class TreeNode extends PureComponent {
this.topLevelRef = ref;
}}
style={style.base}>
<Header {...{decorators, animations, node, style}} onClick={() => this.onClick()}/>
<NodeHeader {...{decorators, animations, node, style}} onClick={() => this.onClick()}/>
{this.renderDrawer(decorators, animations)}
</Li>
);
Expand Down
3 changes: 1 addition & 2 deletions src/components/decorators.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,7 @@ const Toggle = ({style}) => {
<Div style={style.base}>
<Div style={style.wrapper}>
<svg height={height} width={width}>
<Polygon points={points}
style={style.arrow}/>
<Polygon points={points} style={style.arrow}/>
</svg>
</Div>
</Div>
Expand Down
11 changes: 6 additions & 5 deletions src/components/treebeard.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,13 @@ const Ul = styled('ul', {

const TreeBeard = ({animations, decorators, data, onToggle, style}) => (
<Ul style={{...defaultTheme.tree.base, ...style.tree.base}}>
{castArray(data).map((node, index) =>
{castArray(data).map(node => (
<TreeNode
{...{animations, decorators, node, onToggle}}
key={node.id || index}
style={{...defaultTheme.tree.node, ...style.tree.node}}/>
)}
{...{decorators, node, onToggle, animations}}
key={node.id}
style={{...defaultTheme.tree.node, ...style.tree.node}}
/>
))}
</Ul>
);

Expand Down
6 changes: 2 additions & 4 deletions src/themes/animations.js
Original file line number Diff line number Diff line change
@@ -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: {
Expand Down
2 changes: 0 additions & 2 deletions src/themes/default.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@


export default {
tree: {
base: {
Expand Down