feat(tabs): provide a prop for the display of divider

This commit is contained in:
unix
2020-05-17 17:29:50 +08:00
parent fc96dba2ae
commit 6e7f8c8c5c

View File

@@ -8,12 +8,14 @@ import useWarning from '../utils/use-warning'
interface Props {
initialValue?: string
value?: string
hideDivider?: boolean
onChange?: (val: string) => void
className?: string
}
const defaultProps = {
className: '',
hideDivider: false,
}
type NativeAttrs = Omit<React.HTMLAttributes<any>, keyof Props>
@@ -22,6 +24,7 @@ export type TabsProps = Props & typeof defaultProps & NativeAttrs
const Tabs: React.FC<React.PropsWithChildren<TabsProps>> = ({
initialValue: userCustomInitialValue,
value,
hideDivider,
children,
onChange,
className,
@@ -67,7 +70,7 @@ const Tabs: React.FC<React.PropsWithChildren<TabsProps>> = ({
return (
<TabsContext.Provider value={initialValue}>
<div className={`tabs ${className}`} {...props}>
<header>
<header className={hideDivider ? 'hide-divider' : ''}>
{tabs.map((item, index) => (
<div
className={`tab ${selfValue === item.value ? 'active' : ''} ${
@@ -92,6 +95,10 @@ const Tabs: React.FC<React.PropsWithChildren<TabsProps>> = ({
border-bottom: 1px solid ${theme.palette.border};
}
.hide-divider {
border-bottom: none;
}
.content {
padding-top: 0.625rem;
}
@@ -120,7 +127,7 @@ const Tabs: React.FC<React.PropsWithChildren<TabsProps>> = ({
right: 0;
width: 100%;
height: 2px;
transform: scaleX(0.85);
transform: scaleX(0.75);
background-color: transparent;
transition: all 200ms ease;
}