Skip to content

[WIP] fix: Fix Indent to correct level #389

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
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
8 changes: 4 additions & 4 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
const base = require('@umijs/fabric/dist/eslint');

module.exports = {
...base,
extends: [require.resolve('@umijs/fabric/dist/eslint')],

rules: {
...base.rules,
'react/sort-comp': 0,
'default-case': 0,
'eslint-comments/disable-enable-pair': 0,
Expand All @@ -12,5 +10,7 @@ module.exports = {
'jsx-a11y/label-has-for': 0,
'jsx-a11y/label-has-associated-control': 0,
'no-loop-func': 0,
'@typescript-eslint/no-loop-func': 0,
'max-classes-per-file': 0,
},
};
12 changes: 6 additions & 6 deletions assets/index.less
Original file line number Diff line number Diff line change
Expand Up @@ -216,13 +216,13 @@
&-title {
display: inline-block;
}
&-indent {
display: inline-block;
vertical-align: bottom;
height: 0;
}
// &-indent {
// display: inline-block;
// vertical-align: bottom;
// height: 0;
// }
&-indent-unit {
width: 24px;
width: 16px;
display: inline-block;
}
}
27 changes: 23 additions & 4 deletions examples/animation.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -81,9 +81,27 @@ function getTreeData() {
{
key: '1',
title: 'node 1',
children: new Array(1000)
.fill(null)
.map((_, index) => ({ title: `auto ${index}`, key: `auto-${index}` })),
// children: new Array(1000)
// .fill(null)
// .map((_, index) => ({ title: `auto ${index}`, key: `auto-${index}` })),
children: [
{
key: '1-0',
title: 'node 1-0',
children: [
{ key: '1-0-0', title: 'node 1-0-0' },
{
key: '1-0-1',
title: 'node 1-0-1',
children: [
{ key: '1-0-1-0', title: 'node 1-0-1-0' },
{ key: '1-0-1-1', title: 'node 1-0-1-1' },
],
},
{ key: '1-0-2', title: 'node 1-0-2' },
],
},
],
},
];
}
Expand All @@ -105,7 +123,8 @@ const Demo = () => {
<h3>With Virtual</h3>
<Tree
ref={treeRef}
defaultExpandAll={false}
// defaultExpandAll={false}
defaultExpandAll
defaultExpandedKeys={defaultExpandedKeys}
motion={motion}
height={200}
Expand Down
38 changes: 29 additions & 9 deletions examples/animation.less
Original file line number Diff line number Diff line change
Expand Up @@ -5,36 +5,56 @@
.rc-tree-indent {
position: relative;
align-self: stretch;
display: flex;
flex-wrap: nowrap;
align-items: stretch;

.rc-tree-indent-unit {
position: relative;
height: 100%;

&::before {
position: absolute;
top: 100%;
right: -26px;
bottom: -100%;
top: 0;
bottom: 0;
border-right: 1px solid blue;
left: 50%;
content: '';
}

// End should ignore
&-end {
&::before {
display: none;
}
}

// End should ignore
// &-end {
// &::before {
// display: none;
// }
// }
}
}

.rc-tree-switcher-noop {
&::before {
content: '';
display: inline-block;
width: 16px;
height: 16px;
background: red;
border-radius: 100%;
}
}

// Motion
&-motion:not(.node-motion-appear-active) {
.rc-tree-indent-unit {
&::before {
display: none;
}
}
// .rc-tree-indent-unit {
// &::before {
// display: none;
// }
// }
}
}
}
2 changes: 1 addition & 1 deletion examples/big-data.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class Demo extends React.Component {
selectedKeys: [],
};

componentWillUpdate(nextProps, nextState) {
componentDidUpdate(nextProps, nextState) {
// invoked immediately before rendering with new props or state, not for initial 'render'
// see componentWillReceiveProps if you need to call setState
// console.log(nextState.gData === this.state.gData);
Expand Down
7 changes: 4 additions & 3 deletions examples/dropdown.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -52,12 +52,13 @@ class DropdownTree extends React.Component {
};
}

componentWillReceiveProps(props) {
static getDerivedStateFromProps(props) {
if ('visible' in props) {
this.setState({
return {
visible: props.visible,
});
};
}
return null;
}

onChange = value => {
Expand Down
5 changes: 4 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,9 @@
"gh-pages": "npm run build && father doc deploy",
"now-build": "npm run build"
},
"resolutions": {
"@umijs/fabric": "^2.3.1"
},
"peerDependencies": {
"react": "*",
"react-dom": "*"
Expand All @@ -53,7 +56,7 @@
"@types/react": "^16.8.19",
"@types/react-dom": "^16.8.4",
"@types/warning": "^3.0.0",
"@typescript-eslint/parser": "^4.0.1",
"@umijs/fabric": "^2.3.1",
"css-animation": "^1.2.0",
"enzyme": "^3.3.0",
"enzyme-adapter-react-16": "^1.1.1",
Expand Down
5 changes: 2 additions & 3 deletions src/Indent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,8 @@ const Indent = ({ prefixCls, level, isStart, isEnd }: IndentProps) => {
<span
key={i}
className={classNames(baseClassName, {
[`${baseClassName}-start`]: isStart[i + 1],
[`${baseClassName}-end`]: isEnd[i + 1],
[`${baseClassName}-end-first-level`]: !i && isEnd[0],
[`${baseClassName}-start`]: isStart[i],
[`${baseClassName}-end`]: isEnd[i],
})}
/>,
);
Expand Down
Loading