Skip to content

Commit

Permalink
modularize tabBar and tabContent
Browse files Browse the repository at this point in the history
  • Loading branch information
yiminghe committed Aug 29, 2016
1 parent d4a6724 commit 5a9b07b
Show file tree
Hide file tree
Showing 29 changed files with 742 additions and 730 deletions.
4 changes: 4 additions & 0 deletions HISTORY.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
# History
----

## 7.0.0 / 2016-08-29

- modularize tabBar and tabContent

## 6.0.0 / 2016-08-20

- support allowInkBar/allowScrollBar prop
Expand Down
1 change: 0 additions & 1 deletion assets/index.less
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
@effect-duration: .3s;

@import "index/common";
@import "index/anim";
@import "index/left";
@import "index/right";
@import "index/bottom";
Expand Down
103 changes: 0 additions & 103 deletions assets/index/anim.less

This file was deleted.

15 changes: 10 additions & 5 deletions assets/index/bottom.less
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
.@{tabs-prefix-cls} {
&-bottom {
border-top: 2px solid #f3f3f3;
overflow-x: hidden;
}

&-bottom &-bar {
Expand All @@ -19,9 +20,13 @@
&-bottom &-nav-wrap {
width: 100%;
}

&-bottom &-content {
width: 100%;

&-bottom &-content-animated {
flex-direction: row;

.@{tabs-prefix-cls}-tabpane {
width: 100%;
}
}

&-bottom &-tab-next {
Expand All @@ -43,14 +48,14 @@
margin-right: -2px;
width: 32px;
height: 100%;
top:0;
top: 0;
text-align: center;
}

&-bottom &-ink-bar {
height: 2px;
top: 3px;
left:0;
left: 0;
}

&-bottom &-tab {
Expand Down
49 changes: 26 additions & 23 deletions assets/index/common.less
Original file line number Diff line number Diff line change
Expand Up @@ -20,24 +20,12 @@
margin-top: -3px;
background-color: #3fc7fa;
transform-origin: 0 0;

&-transition-forward {
transition: right @effect-duration @easing-in-out,
left @effect-duration @easing-in-out @effect-duration * 0.3,
bottom @effect-duration @easing-in-out,
transform @effect-duration @easing-in-out @effect-duration * 0.3,
-webkit-transform @effect-duration @easing-in-out @effect-duration * 0.3,
top @effect-duration @easing-in-out @effect-duration * 0.3;
}

&-transition-backward {
transition: bottom @effect-duration @easing-in-out @effect-duration * 0.3,
right @effect-duration @easing-in-out @effect-duration * 0.3,
left @effect-duration @easing-in-out,
transform @effect-duration @easing-in-out @effect-duration * 0.3,
-webkit-transform @effect-duration @easing-in-out @effect-duration * 0.3,
top @effect-duration @easing-in-out;
}
transition: right @effect-duration @easing-in-out,
left @effect-duration @easing-in-out,
bottom @effect-duration @easing-in-out,
transform @effect-duration @easing-in-out,
-webkit-transform @effect-duration @easing-in-out,
top @effect-duration @easing-in-out;
}

&-tab-prev, &-tab-next {
Expand Down Expand Up @@ -135,12 +123,27 @@
}
}

&-tabpane-hidden {
display: none;
&-content {
zoom: 1;

.@{tabs-prefix-cls}-tabpane {
overflow: auto;
}
}

&-content-no-animated {
.@{tabs-prefix-cls}-tabpane-inactive {
display: none;
}
}

&-content {
position: relative;
overflow: hidden;
&-content-animated {
transition: transform @effect-duration @easing-in-out;
display: flex;
will-change: transform;

.@{tabs-prefix-cls}-tabpane {
flex-shrink: 0;
}
}
}
14 changes: 11 additions & 3 deletions assets/index/left.less
Original file line number Diff line number Diff line change
@@ -1,14 +1,18 @@
.@{tabs-prefix-cls} {
&-left {
border-right: 2px solid #f3f3f3;
overflow-y: hidden;
}

&-left &-bar {
float: left;
height:100%;
margin-right: 10px;
border-right: 1px solid #f3f3f3;
}

&-left &-nav-container {
height:100%;
}
&-left &-nav-container-scrolling {
padding-top: 32px;
padding-bottom: 32px;
Expand All @@ -18,8 +22,12 @@
height: 100%;
}

&-left &-content {
height: 100%;
&-left &-content-animated {
flex-direction: column;

.@{tabs-prefix-cls}-tabpane {
height: 100%;
}
}

&-left &-nav-scroll {
Expand Down
14 changes: 11 additions & 3 deletions assets/index/right.less
Original file line number Diff line number Diff line change
@@ -1,14 +1,18 @@
.@{tabs-prefix-cls} {
&-right {
border-left: 2px solid #f3f3f3;
overflow-y: hidden;
}

&-right &-bar {
float: right;
height: 100%;
margin-left: 10px;
border-left: 1px solid #f3f3f3;
}

&-right &-nav-container {
height:100%;
}
&-right &-nav-container-scrolling {
padding-top: 32px;
padding-bottom: 32px;
Expand Down Expand Up @@ -53,8 +57,12 @@
}
}

&-right &-content {
height: 100%;
&-right &-content-animated {
flex-direction: column;

.@{tabs-prefix-cls}-tabpane {
height: 100%;
}
}

&-right &-ink-bar {
Expand Down
8 changes: 6 additions & 2 deletions assets/index/top.less
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
.@{tabs-prefix-cls} {
&-top {
border-bottom: 2px solid #f3f3f3;
overflow-x: hidden;
}

&-top &-bar {
Expand All @@ -20,8 +21,11 @@
width: 100%;
}

&-top &-content {
width: 100%;
&-top &-content-animated {
flex-direction: row;
.@{tabs-prefix-cls}-tabpane {
width: 100%;
}
}

&-top &-tab-next {
Expand Down
7 changes: 4 additions & 3 deletions examples/activeKey.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import 'rc-tabs/assets/index.less';
import React from 'react';
import ReactDOM from 'react-dom';
import Tabs, { TabPane } from 'rc-tabs';
import TabContent from '../src/TabContent';
import ScrollableInkTabBar from '../src/ScrollableInkTabBar';

class PanelContent extends React.Component {
constructor(props) {
Expand Down Expand Up @@ -63,10 +65,9 @@ const Component = React.createClass({
return (<div>
<h1>Simple Tabs</h1>
<Tabs
allowScrollBar={false}
allowInkBar
renderTabBar={()=><ScrollableInkTabBar onTabClick={this.onTabClick}/>}
renderTabContent={()=><TabContent/>}
activeKey={this.state.activeKey}
onTabClick={this.onTabClick}
onChange={this.onChange}
>
<TabPane tab={`tab ${start}`} key="1">
Expand Down
12 changes: 6 additions & 6 deletions examples/add.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import 'rc-tabs/assets/index.less';
import React from 'react';
import ReactDOM from 'react-dom';
import Tabs, { TabPane } from 'rc-tabs';
import TabContent from '../src/TabContent';
import ScrollableInkTabBar from '../src/ScrollableInkTabBar';

let index = 1;

Expand Down Expand Up @@ -97,8 +99,6 @@ const Test = React.createClass({
},

render() {
const animation = 'slide-horizontal';

const tabStyle = {
width: 500,
};
Expand All @@ -108,12 +108,12 @@ const Test = React.createClass({

<div style={tabStyle}>
<Tabs
animation={animation}
renderTabBar={()=><ScrollableInkTabBar tabBarExtraContent={
<button onClick={this.add}>+添加</button>
} />}
renderTabContent={()=><TabContent/>}
activeKey={this.state.activeKey}
onChange={this.onTabChange}
tabBarExtraContent={
<button onClick={this.add}>+添加</button>
}
>
{this.construct()}
</Tabs>
Expand Down

0 comments on commit 5a9b07b

Please sign in to comment.