Skip to content

Commit

Permalink
Merge pull request #61 from kaishens-cn/dev/tree
Browse files Browse the repository at this point in the history
  • Loading branch information
cherishs001 authored May 20, 2024
2 parents 9c3b46b + bb2513b commit 5abc3ae
Show file tree
Hide file tree
Showing 7 changed files with 300 additions and 66 deletions.
67 changes: 36 additions & 31 deletions example/tree.tsx
Original file line number Diff line number Diff line change
@@ -1,40 +1,45 @@
import React from 'react';
import React, { useEffect, useState } from 'react';

import { Column, Icon, Tree } from '../src';

const TreeOverview = () => {
const [data, setData] = useState([
{
id: '0',
label: 'node 0',
prefix: <Icon.Dns width={14} />,
children: [
{ id: '0-0', label: 'node 0-0', prefix: <Icon.Dns width={14} /> },
{
id: '0-1',
label: 'node 0-1',
prefix: <Icon.Dns width={14} />,
children: [
{
id: '0-1-1',
label: 'node 0-1-1',
prefix: <Icon.Dns width={14} />,
children: [{ id: '0-1-1-1', label: 'node 0-1-1-1', prefix: <Icon.Dns width={14} /> }],
},
{ id: '0-1-2', label: 'node 0-1-2', prefix: <Icon.Dns width={14} /> },
],
},
{ id: '0-2', label: 'node 0-2', prefix: <Icon.Dns width={14} /> },
],
},
{
id: '1',
label: 'node 1',
children: [
{ id: '1-0', label: 'node 1-0', prefix: <Icon.Dns width={14} /> },
{ id: '1-1', label: 'node 1-1', prefix: <Icon.Dns width={14} /> },
],
},
]);

return (
<Column className="component-container" align="unset">
<Tree
expandedOffset={-20}
data={[
{
id: '0',
label: 'node 0',
children: [
{ id: '0-0', label: 'node 0-0', prefix: <Icon.Dns width={14} /> },
{
id: '0-1',
label: 'node 0-1',
prefix: <Icon.Dns width={14} />,
children: [
{ id: '0-1-1', label: 'node 0-1-1', prefix: <Icon.Dns width={14} /> },
{ id: '0-1-2', label: 'node 0-1-2', prefix: <Icon.Dns width={14} /> },
],
},
{ id: '0-2', label: 'node 0-2', prefix: <Icon.Dns width={14} /> },
],
},
{
id: '1',
label: 'node 1',
children: [
{ id: '1-0', label: 'node 1-0', prefix: <Icon.Dns width={14} /> },
{ id: '1-1', label: 'node 1-1', prefix: <Icon.Dns width={14} /> },
],
},
]}
/>
<Tree defaultExpandedKeys={['0']} data={data} />
</Column>
);
};
Expand Down
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,10 @@
},
"dependencies": {
"@react-spring/web": "9.7.3",
"@types/lodash": "^4.17.4",
"classnames": "^2.3.2",
"jotai": "^2.4.1",
"lodash": "^4.17.21",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react-router-dom": "^6.15.0",
Expand Down
11 changes: 11 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 5abc3ae

Please sign in to comment.