Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
wanjj_1210
ant-design
提交
079f2a65
A
ant-design
项目概览
wanjj_1210
/
ant-design
与 Fork 源项目一致
从无法访问的项目Fork
通知
10
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
A
ant-design
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
079f2a65
编写于
3月 02, 2016
作者:
A
afc163
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Allow close last tab, fix #1071
上级
3ba79342
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
25 addition
and
22 deletion
+25
-22
components/tabs/demo/editable-card.md
components/tabs/demo/editable-card.md
+8
-4
components/tabs/index.jsx
components/tabs/index.jsx
+15
-17
style/components/tabs.less
style/components/tabs.less
+2
-1
未找到文件。
components/tabs/demo/editable-card.md
浏览文件 @
079f2a65
...
...
@@ -36,10 +36,15 @@ const Demo = React.createClass({
},
remove
(
targetKey
)
{
let
activeKey
=
this
.
state
.
activeKey
;
let
lastIndex
=
this
.
state
.
panes
.
findIndex
(
pane
=>
pane
.
key
===
targetKey
)
-
1
;
let
lastIndex
;
this
.
state
.
panes
.
forEach
((
pane
,
i
)
=>
{
if
(
pane
.
key
===
targetKey
)
{
lastIndex
=
i
-
1
;
}
});
const
panes
=
this
.
state
.
panes
.
filter
(
pane
=>
pane
.
key
!==
targetKey
);
if
(
activeKey
===
targetKey
)
{
activeKey
=
panes
[
lastIndex
>=
0
?
lastIndex
:
0
].
key
;
if
(
lastIndex
>=
0
&&
activeKey
===
targetKey
)
{
activeKey
=
panes
[
lastIndex
].
key
;
}
this
.
setState
({
panes
,
activeKey
});
},
...
...
@@ -55,4 +60,3 @@ const Demo = React.createClass({
ReactDOM
.
render
(<
Demo
/>,
mountNode
);
````
components/tabs/index.jsx
浏览文件 @
079f2a65
...
...
@@ -33,23 +33,22 @@ class AntTabs extends React.Component {
[
`
${
prefixCls
}
-mini`
]:
size
===
'
small
'
||
size
===
'
mini
'
,
[
`
${
prefixCls
}
-vertical`
]:
tabPosition
===
'
left
'
||
tabPosition
===
'
right
'
,
[
`
${
prefixCls
}
-card`
]:
type
.
indexOf
(
'
card
'
)
>=
0
,
[
`
${
prefixCls
}
-
${
type
}
`
]:
true
,
});
if
(
tabPosition
===
'
left
'
||
tabPosition
===
'
right
'
||
type
.
indexOf
(
'
card
'
)
>=
0
)
{
animation
=
null
;
}
// only card type tabs can be added and closed
if
(
type
===
'
editable-card
'
)
{
if
(
children
.
length
>
1
)
{
children
=
children
.
map
((
child
,
index
)
=>
{
return
cloneElement
(
child
,
{
tab
:
<
div
>
{
child
.
props
.
tab
}
<
Icon
type
=
"cross"
onClick
=
{
this
.
removeTab
.
bind
(
this
,
child
.
key
)
}
/>
</
div
>,
key
:
child
.
key
||
index
,
});
children
=
children
.
map
((
child
,
index
)
=>
{
return
cloneElement
(
child
,
{
tab
:
<
div
>
{
child
.
props
.
tab
}
<
Icon
type
=
"cross"
onClick
=
{
this
.
removeTab
.
bind
(
this
,
child
.
key
)
}
/>
</
div
>,
key
:
child
.
key
||
index
,
});
}
}
);
// Add new tab handler
tabBarExtraContent
=
(
<
span
>
...
...
@@ -58,16 +57,15 @@ class AntTabs extends React.Component {
</
span
>
);
}
// Wrap the extra content
tabBarExtraContent
=
(
<
div
className
=
{
`
${
prefixCls
}
-extra-content`
}
>
{
tabBarExtraContent
}
</
div
>
);
return
(
<
Tabs
{
...
this
.
props
}
className
=
{
className
}
tabBarExtraContent
=
{
tabBarExtraContent
}
tabBarExtraContent
=
{
<
div
className
=
{
`
${
prefixCls
}
-extra-content`
}
>
{
tabBarExtraContent
}
</
div
>
}
onChange
=
{
this
.
handleChange
}
animation
=
{
animation
}
>
{
children
}
...
...
style/components/tabs.less
浏览文件 @
079f2a65
...
...
@@ -39,6 +39,7 @@
overflow: hidden;
font-size: 14px;
line-height: @line-height-base;
height: 36px;
box-sizing: border-box;
position: relative;
white-space: nowrap;
...
...
@@ -419,7 +420,7 @@
}
}
&&-card &-tab:not(&-tab-active):hover &-tab-inner {
&&-
editable-
card &-tab:not(&-tab-active):hover &-tab-inner {
padding-left: 8px;
padding-right: 8px;
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录