From cb8f6a6ef53b119d6f81b6293da09d4a8ab55e6c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=81=8F=E5=8F=B3?= Date: Sat, 5 Aug 2017 23:01:28 +0800 Subject: [PATCH] Fix tabs extra content (#7090) * Fix tabBarExtraContent style in vertical tabs close #6578 * update snap * fix rc-tabs --- .../__tests__/__snapshots__/demo.test.js.snap | 210 ++++++++++++++++-- .../__snapshots__/index.test.js.snap | 152 +++++++++++++ components/tabs/__tests__/index.test.js | 11 + components/tabs/demo/editable-card.md | 1 - components/tabs/style/card-style.less | 9 +- components/tabs/style/index.less | 31 ++- package.json | 2 +- 7 files changed, 388 insertions(+), 28 deletions(-) create mode 100644 components/tabs/__tests__/__snapshots__/index.test.js.snap diff --git a/components/tabs/__tests__/__snapshots__/demo.test.js.snap b/components/tabs/__tests__/__snapshots__/demo.test.js.snap index 48266fbf0c..014cf016f3 100644 --- a/components/tabs/__tests__/__snapshots__/demo.test.js.snap +++ b/components/tabs/__tests__/__snapshots__/demo.test.js.snap @@ -12,6 +12,22 @@ exports[`renders ./components/tabs/demo/basic.md correctly 1`] = `
+ + + + + +
@@ -90,6 +106,22 @@ exports[`renders ./components/tabs/demo/card.md correctly 1`] = `
+ + + + + +
@@ -170,6 +202,22 @@ exports[`renders ./components/tabs/demo/card-top.md correctly 1`] = `
+ + + + + +
@@ -269,6 +317,22 @@ exports[`renders ./components/tabs/demo/custom-add-trigger.md correctly 1`] = `
+ + + + + +
@@ -344,6 +408,22 @@ exports[`renders ./components/tabs/demo/disabled.md correctly 1`] = `
+ + + + + +
@@ -420,21 +500,34 @@ exports[`renders ./components/tabs/demo/editable-card.md correctly 1`] = ` tabindex="0" >
-
- - - -
+ + +
+ + + + + +
@@ -506,24 +599,37 @@ exports[`renders ./components/tabs/demo/extra.md correctly 1`] = ` tabindex="0" >
-
- -
+ + Extra Action + +
+ + + + + +
@@ -602,6 +708,22 @@ exports[`renders ./components/tabs/demo/icon.md correctly 1`] = `
+ + + + + +
@@ -715,6 +837,22 @@ exports[`renders ./components/tabs/demo/position.md correctly 1`] = `
+ + + + + +
@@ -794,6 +932,22 @@ exports[`renders ./components/tabs/demo/size.md correctly 1`] = `
+ + + + + +
@@ -916,6 +1070,22 @@ exports[`renders ./components/tabs/demo/slide.md correctly 1`] = `
+ + + + + +
diff --git a/components/tabs/__tests__/__snapshots__/index.test.js.snap b/components/tabs/__tests__/__snapshots__/index.test.js.snap new file mode 100644 index 0000000000..dfde54aa28 --- /dev/null +++ b/components/tabs/__tests__/__snapshots__/index.test.js.snap @@ -0,0 +1,152 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`Tabs tabPosition remove card 1`] = ` + + +
+ + xxx +
+ } + inkBarAnimated={true} + onKeyDown={[Function]} + onNextClick={[Function]} + onPrevClick={[Function]} + onTabClick={[Function]} + panels={ + + foo + + } + prefixCls="ant-tabs" + scrollAnimated={true} + styles={Object {}} + tabBarPosition="left" + > +
+
+ + + + + + +
+
+
+
+
+ foo +
+
+
+
+
+
+ xxx +
+
+ + +
+ +
+ foo +
+
+
+
+
+
+
+`; diff --git a/components/tabs/__tests__/index.test.js b/components/tabs/__tests__/index.test.js index ce1b2d34f1..ae3b1b15ce 100644 --- a/components/tabs/__tests__/index.test.js +++ b/components/tabs/__tests__/index.test.js @@ -28,4 +28,15 @@ describe('Tabs', () => { expect(handleEdit).toBeCalledWith('1', 'remove'); }); }); + + describe('tabPosition', () => { + it('remove card', () => { + const wrapper = mount( + + foo + + ); + expect(wrapper).toMatchSnapshot(); + }); + }); }); diff --git a/components/tabs/demo/editable-card.md b/components/tabs/demo/editable-card.md index f375a6f526..68a8562676 100644 --- a/components/tabs/demo/editable-card.md +++ b/components/tabs/demo/editable-card.md @@ -19,7 +19,6 @@ Only card type Tabs support adding & closable. import { Tabs } from 'antd'; const TabPane = Tabs.TabPane; - class Demo extends React.Component { constructor(props) { super(props); diff --git a/components/tabs/style/card-style.less b/components/tabs/style/card-style.less index ceab767a7c..7c3e25ca93 100644 --- a/components/tabs/style/card-style.less +++ b/components/tabs/style/card-style.less @@ -69,7 +69,6 @@ } &-extra-content { - float: right; line-height: 32px; .@{tab-prefix-cls}-new-tab { @@ -83,9 +82,10 @@ font-size: @font-size-base; .iconfont-size-under-12px(10px); color: @text-color-secondary; - transition: color 0.3s ease; + transition: all .3s; &:hover { - color: #404040; + color: @primary-color; + border-color: @primary-color; } } } @@ -105,6 +105,9 @@ margin-bottom: 8px; } } + .@{tab-prefix-cls}-new-tab { + width: 90%; + } } &-vertical&-card&-left > .@{tab-prefix-cls}-bar { diff --git a/components/tabs/style/index.less b/components/tabs/style/index.less index c6d20caa41..ff6b47f0a2 100644 --- a/components/tabs/style/index.less +++ b/components/tabs/style/index.less @@ -26,6 +26,7 @@ border-bottom: @border-width-base @border-style-base @border-color-base; margin-bottom: 16px; outline: none; + transition: padding .45s; } &-nav-container { @@ -36,6 +37,7 @@ position: relative; white-space: nowrap; margin-bottom: -1px; + transition: padding .45s; .clearfix; &-scrolling { @@ -48,8 +50,8 @@ &-tab-next { user-select: none; z-index: 2; - width: 32px; - height: 100%; + width: 0; + height: 0; line-height: 32px; cursor: pointer; border: 0; @@ -57,7 +59,16 @@ position: absolute; text-align: center; color: @text-color-secondary; - transition: color 0.3s ease; + transition: width .3s, height .3s, opacity .3s, color .3s; + opacity: 0; + pointer-events: none; + + &.@{tab-prefix-cls}-tab-arrow-show { + opacity: 1; + width: 32px; + height: 100%; + pointer-events: auto; + } &:hover { color: @text-color; @@ -220,6 +231,12 @@ border-bottom: 0; height: 100%; + &-tab-prev.@{tab-prefix-cls}-tab-arrow-show, + &-tab-next.@{tab-prefix-cls}-tab-arrow-show { + width: 100%; + height: 32px; + } + .@{tab-prefix-cls}-tab { float: none; margin-right: 0; @@ -232,6 +249,10 @@ } } + .@{tab-prefix-cls}-extra-content { + text-align: center; + } + .@{tab-prefix-cls}-nav-scroll { width: auto; } @@ -253,6 +274,10 @@ margin-bottom: 0; } + .@{tab-prefix-cls}-nav { + width: 100%; + } + .@{tab-prefix-cls}-ink-bar { width: 2px; left: auto; diff --git a/package.json b/package.json index 3bd5f14e65..957e68d289 100644 --- a/package.json +++ b/package.json @@ -65,7 +65,7 @@ "rc-steps": "~2.5.1", "rc-switch": "~1.5.1", "rc-table": "~5.4.0", - "rc-tabs": "~8.0.0", + "rc-tabs": "~9.0.2", "rc-time-picker": "~2.4.1", "rc-tooltip": "~3.4.6", "rc-tree": "~1.7.0",