mirror of
https://github.com/ant-design/ant-design.git
synced 2024-12-29 03:48:26 +08:00
52 lines
1.5 KiB
TypeScript
52 lines
1.5 KiB
TypeScript
|
import * as React from 'react';
|
||
|
import Icon from '../icon';
|
||
|
import ScrollableInkTabBar from 'rc-tabs/lib/ScrollableInkTabBar';
|
||
|
import { TabsProps } from './index';
|
||
|
|
||
|
export default class TabBar extends React.Component<TabsProps> {
|
||
|
render() {
|
||
|
const {
|
||
|
tabBarStyle,
|
||
|
animated = true,
|
||
|
renderTabBar,
|
||
|
tabBarExtraContent,
|
||
|
tabPosition,
|
||
|
prefixCls,
|
||
|
} = this.props;
|
||
|
const inkBarAnimated = typeof animated === 'object' ? animated.inkBar : animated;
|
||
|
|
||
|
const isVertical = tabPosition === 'left' || tabPosition === 'right';
|
||
|
const prevIconType = isVertical ? 'up' : 'left';
|
||
|
const nextIconType = isVertical ? 'down' : 'right';
|
||
|
const prevIcon = (
|
||
|
<span className={`${prefixCls}-tab-prev-icon`}>
|
||
|
<Icon type={prevIconType} className={`${prefixCls}-tab-prev-icon-target`} />
|
||
|
</span>
|
||
|
);
|
||
|
const nextIcon = (
|
||
|
<span className={`${prefixCls}-tab-next-icon`}>
|
||
|
<Icon type={nextIconType} className={`${prefixCls}-tab-next-icon-target`} />
|
||
|
</span>
|
||
|
);
|
||
|
|
||
|
const renderProps = {
|
||
|
...this.props,
|
||
|
inkBarAnimated,
|
||
|
extraContent: tabBarExtraContent,
|
||
|
style: tabBarStyle,
|
||
|
prevIcon,
|
||
|
nextIcon,
|
||
|
};
|
||
|
|
||
|
let RenderTabBar: React.ReactElement<any>;
|
||
|
|
||
|
if (renderTabBar) {
|
||
|
RenderTabBar = renderTabBar(renderProps, ScrollableInkTabBar);
|
||
|
} else {
|
||
|
RenderTabBar = <ScrollableInkTabBar {...renderProps} />;
|
||
|
}
|
||
|
|
||
|
return React.cloneElement(RenderTabBar);
|
||
|
}
|
||
|
}
|