Skip to content

Commit

Permalink
add noPadded prop to Tabs.Item, see #33
Browse files Browse the repository at this point in the history
- also, remove Tabs Nav bottom margin
  • Loading branch information
minwe committed May 10, 2016
1 parent f4f9a29 commit 80316ff
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 3 deletions.
6 changes: 6 additions & 0 deletions docs/tabs/api.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,12 @@
是否禁用该选项卡。

##### `noPadded`

> PropType: `bool`
是否移除选项卡面板的内边距(`padding`)。

##### `navStyle`

> PropType: `string`
Expand Down
12 changes: 10 additions & 2 deletions src/js/Tabs.js
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,8 @@ const Tabs = React.createClass({
let panels = React.Children.map(this.props.children, (child, index) => {
let {
eventKey,
children
children,
...props
} = child.props;

if (eventKey === undefined) {
Expand All @@ -130,6 +131,7 @@ const Tabs = React.createClass({
active={eventKey === activeKey}
enventKey={eventKey}
key={'tabPanel' + index}
{...props}
>
{children}
</Tabs.Item>
Expand Down Expand Up @@ -173,6 +175,7 @@ Tabs.Item = React.createClass({
eventKey: React.PropTypes.any,
disabled: React.PropTypes.bool,
active: React.PropTypes.bool,
noPadded: React.PropTypes.bool,
navSize: React.PropTypes.string,
navStyle: React.PropTypes.string,
},
Expand All @@ -188,10 +191,13 @@ Tabs.Item = React.createClass({
let {
className,
children,
noPadded,
...props
} = this.props;
const elementName = 'panel';

classSet[this.prefixClass('panel')] = true;
classSet[this.prefixClass(elementName)] = true;
classSet[this.prefixClass(`${elementName}-no-padded`)] = noPadded;

return (
<div
Expand All @@ -205,3 +211,5 @@ Tabs.Item = React.createClass({
});

export default Tabs;

// TODO: Nav 的可定制性,如允许传入 Router 的 Link 组件
9 changes: 8 additions & 1 deletion src/scss/components/_tabs.scss
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
}

.#{$tabs-prefix}-nav {
margin-bottom: 0;

.#{$button-prefix} {
@extend %text-truncate;
}
Expand All @@ -28,7 +30,7 @@
top: 0;
z-index: 99;
width: 100%;
padding: rem-calc(10) $global-spacing;
padding: $global-spacing;
visibility: hidden;
transition: transform 0.3s;
transform: translateX(-100%);
Expand All @@ -43,6 +45,11 @@
transform: translateX(100%);
}
}

// panel without padding
&#{$panel}-no-padded {
padding: 0;
}
}

// Mofidier: inset
Expand Down

0 comments on commit 80316ff

Please sign in to comment.