ddcat1115
8 years ago
committed by
Benjy Cui
9 changed files with 201 additions and 23 deletions
@ -0,0 +1,90 @@ |
|||||
|
--- |
||||
|
order: 6 |
||||
|
title: |
||||
|
zh-CN: 自定义图标 |
||||
|
en-US: Customize Icon |
||||
|
--- |
||||
|
|
||||
|
## zh-CN |
||||
|
|
||||
|
可以针对不同节点采用样式覆盖的方式定制图标。 |
||||
|
|
||||
|
## en-US |
||||
|
|
||||
|
You can customize icons for different nodes by styles override. |
||||
|
|
||||
|
````jsx |
||||
|
import { Tree } from 'antd'; |
||||
|
const TreeNode = Tree.TreeNode; |
||||
|
|
||||
|
class Demo extends React.Component { |
||||
|
onSelect = (selectedKeys, info) => { |
||||
|
console.log('selected', selectedKeys, info); |
||||
|
} |
||||
|
render() { |
||||
|
return ( |
||||
|
<Tree |
||||
|
showIcon |
||||
|
showLine |
||||
|
defaultExpandedKeys={['0-0-0', '0-0-1']} |
||||
|
defaultSelectedKeys={['0-0-0', '0-0-1']} |
||||
|
onSelect={this.onSelect} |
||||
|
> |
||||
|
<TreeNode title="parent 1" key="0-0"> |
||||
|
<TreeNode title="parent 1-0" key="0-0-0"> |
||||
|
<TreeNode title="leaf" key="0-0-0-0" /> |
||||
|
<TreeNode title="leaf" key="0-0-0-1" /> |
||||
|
</TreeNode> |
||||
|
<TreeNode title="parent 1-1" key="0-0-1"> |
||||
|
<TreeNode title="leaf" key="0-0-1-0" /> |
||||
|
</TreeNode> |
||||
|
<TreeNode title="leaf" key="0-0-2" /> |
||||
|
</TreeNode> |
||||
|
</Tree> |
||||
|
); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
ReactDOM.render(<Demo />, mountNode); |
||||
|
```` |
||||
|
|
||||
|
```css |
||||
|
#components-tree-demo-customized-icon .ant-tree-iconEle { |
||||
|
position: absolute; |
||||
|
left: 0; |
||||
|
background: #fff; |
||||
|
} |
||||
|
#components-tree-demo-customized-icon .ant-tree-iconEle::after { |
||||
|
font-size: 12px; |
||||
|
font-size: 8px \9; |
||||
|
transform: scale(0.66666667) rotate(0deg); |
||||
|
-ms-filter: "progid:DXImageTransform.Microsoft.Matrix(sizingMethod='auto expand', M11=1, M12=0, M21=0, M22=1)"; |
||||
|
zoom: 1; |
||||
|
display: inline-block; |
||||
|
font-family: 'anticon'; |
||||
|
text-rendering: optimizeLegibility; |
||||
|
-webkit-font-smoothing: antialiased; |
||||
|
-moz-osx-font-smoothing: grayscale; |
||||
|
font-weight: bold; |
||||
|
color: #999; |
||||
|
transition: transform .3s ease; |
||||
|
margin-top: 2px; |
||||
|
} |
||||
|
#components-tree-demo-customized-icon .ant-tree-iconEle.ant-tree-icon__docu::after { |
||||
|
content: "\E664"; |
||||
|
} |
||||
|
#components-tree-demo-customized-icon .ant-tree-iconEle.ant-tree-icon__open::after { |
||||
|
content: "\E699"; |
||||
|
} |
||||
|
#components-tree-demo-customized-icon .ant-tree-iconEle.ant-tree-icon__close::after { |
||||
|
content: "\E662"; |
||||
|
} |
||||
|
#components-tree-demo-customized-icon .ant-tree-switcher { |
||||
|
position: relative; |
||||
|
z-index: 1; |
||||
|
background: transparent; |
||||
|
} |
||||
|
#components-tree-demo-customized-icon .ant-tree-switcher::after { |
||||
|
opacity: 0; |
||||
|
} |
||||
|
``` |
@ -0,0 +1,51 @@ |
|||||
|
--- |
||||
|
order: 5 |
||||
|
title: |
||||
|
zh-CN: 连接线 |
||||
|
en-US: Tree With Line |
||||
|
--- |
||||
|
|
||||
|
## zh-CN |
||||
|
|
||||
|
带连接线的树。 |
||||
|
|
||||
|
## en-US |
||||
|
|
||||
|
Tree With Line |
||||
|
|
||||
|
````jsx |
||||
|
import { Tree } from 'antd'; |
||||
|
const TreeNode = Tree.TreeNode; |
||||
|
|
||||
|
class Demo extends React.Component { |
||||
|
onSelect = (selectedKeys, info) => { |
||||
|
console.log('selected', selectedKeys, info); |
||||
|
} |
||||
|
render() { |
||||
|
return ( |
||||
|
<Tree |
||||
|
showLine |
||||
|
defaultExpandedKeys={['0-0-0']} |
||||
|
onSelect={this.onSelect} |
||||
|
> |
||||
|
<TreeNode title="parent 1" key="0-0"> |
||||
|
<TreeNode title="parent 1-0" key="0-0-0"> |
||||
|
<TreeNode title="leaf" key="0-0-0-0" /> |
||||
|
<TreeNode title="leaf" key="0-0-0-1" /> |
||||
|
<TreeNode title="leaf" key="0-0-0-2" /> |
||||
|
</TreeNode> |
||||
|
<TreeNode title="parent 1-1" key="0-0-1"> |
||||
|
<TreeNode title="leaf" key="0-0-1-0" /> |
||||
|
</TreeNode> |
||||
|
<TreeNode title="parent 1-2" key="0-0-2"> |
||||
|
<TreeNode title="leaf" key="0-0-2-0" /> |
||||
|
<TreeNode title="leaf" key="0-0-2-1" /> |
||||
|
</TreeNode> |
||||
|
</TreeNode> |
||||
|
</Tree> |
||||
|
); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
ReactDOM.render(<Demo />, mountNode); |
||||
|
```` |
@ -1,16 +1,16 @@ |
|||||
@import "../../style/mixins/index"; |
@import "../../style/mixins/index"; |
||||
|
|
||||
.antTreeSwitcherIcon() { |
@open: "\e621"; |
||||
position: relative; |
@close: "\e645"; |
||||
|
@doc: "\e664"; |
||||
|
|
||||
|
.antTreeSwitcherIcon(@type) { |
||||
&:after { |
&:after { |
||||
.iconfont-size-under-12px(7px); |
.iconfont-size-under-12px(8px); |
||||
display: inline-block; |
display: inline-block; |
||||
.iconfont-font("\e606"); |
.iconfont-font(@@type); |
||||
font-weight: bold; |
font-weight: bold; |
||||
position: absolute; |
color: @tree-icon-color; |
||||
top: 0; |
|
||||
right: 4px; |
|
||||
color: @text-color; |
|
||||
transition: transform .3s ease; |
transition: transform .3s ease; |
||||
} |
} |
||||
} |
} |
||||
|
Loading…
Reference in new issue