2018-12-12 13:31:18 +00:00
|
|
|
import Icon from '../icon'
|
|
|
|
import ScrollableInkTabBar from '../vc-tabs/src/ScrollableInkTabBar'
|
|
|
|
import { cloneElement } from '../_util/vnode'
|
|
|
|
const TabBar = {
|
|
|
|
functional: true,
|
|
|
|
render (h, context) {
|
|
|
|
const {
|
|
|
|
tabBarStyle,
|
|
|
|
animated = true,
|
|
|
|
renderTabBar,
|
|
|
|
tabBarExtraContent,
|
|
|
|
tabPosition,
|
|
|
|
prefixCls,
|
2018-12-14 15:31:02 +00:00
|
|
|
type = 'line',
|
|
|
|
size,
|
2018-12-12 13:31:18 +00:00
|
|
|
} = context.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 class={`${prefixCls}-tab-prev-icon`}>
|
|
|
|
<Icon type={prevIconType} class={`${prefixCls}-tab-prev-icon-target`} />
|
|
|
|
</span>
|
|
|
|
)
|
|
|
|
const nextIcon = (
|
|
|
|
<span class={`${prefixCls}-tab-next-icon`}>
|
|
|
|
<Icon type={nextIconType} class={`${prefixCls}-tab-next-icon-target`} />
|
|
|
|
</span>
|
|
|
|
)
|
|
|
|
|
2018-12-14 15:31:02 +00:00
|
|
|
// Additional className for style usage
|
|
|
|
const cls = {
|
|
|
|
[`${prefixCls}-${tabPosition}-bar`]: true,
|
|
|
|
[`${prefixCls}-${size}-bar`]: !!size,
|
|
|
|
[`${prefixCls}-card-bar`]: type && type.indexOf('card') >= 0,
|
|
|
|
}
|
|
|
|
|
2018-12-12 13:31:18 +00:00
|
|
|
const renderProps = {
|
|
|
|
props: {
|
|
|
|
...context.props,
|
|
|
|
inkBarAnimated,
|
|
|
|
extraContent: tabBarExtraContent,
|
|
|
|
prevIcon,
|
|
|
|
nextIcon,
|
|
|
|
},
|
|
|
|
style: tabBarStyle,
|
2018-12-12 13:42:22 +00:00
|
|
|
on: context.listeners,
|
2018-12-14 15:31:02 +00:00
|
|
|
class: cls,
|
2018-12-12 13:31:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
let RenderTabBar
|
|
|
|
|
|
|
|
if (renderTabBar) {
|
|
|
|
RenderTabBar = renderTabBar(renderProps, ScrollableInkTabBar)
|
|
|
|
} else {
|
|
|
|
RenderTabBar = <ScrollableInkTabBar {...renderProps} />
|
|
|
|
}
|
|
|
|
|
|
|
|
return cloneElement(RenderTabBar, renderProps)
|
|
|
|
},
|
|
|
|
}
|
|
|
|
|
|
|
|
export default TabBar
|