|
@ -2,7 +2,6 @@ |
|
|
|
|
|
|
|
|
import React, { Fragment } from 'react' |
|
|
import React, { Fragment } from 'react' |
|
|
import styled from 'styled-components' |
|
|
import styled from 'styled-components' |
|
|
import isString from 'lodash/isString' |
|
|
|
|
|
|
|
|
|
|
|
import type { Element } from 'react' |
|
|
import type { Element } from 'react' |
|
|
|
|
|
|
|
@ -36,24 +35,17 @@ type Props = { |
|
|
onTabClick: number => void, |
|
|
onTabClick: number => void, |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
const Tabs = ({ items, index, onTabClick }: Props) => { |
|
|
const Tabs = ({ items, index, onTabClick }: Props) => ( |
|
|
const item = isString(index) ? items.find(item => item.key === index) : items[index] |
|
|
<Fragment> |
|
|
return ( |
|
|
<Box horizontal borderBottom borderWidth={1} borderColor="argile"> |
|
|
<Fragment> |
|
|
{items.map((item, i) => ( |
|
|
<Box horizontal borderBottom borderWidth={1} borderColor="argile"> |
|
|
<Tab key={item.key} isActive={index === i} onClick={() => onTabClick(i)}> |
|
|
{items.map((item, i) => ( |
|
|
{item.title} |
|
|
<Tab |
|
|
</Tab> |
|
|
key={item.key} |
|
|
))} |
|
|
isActive={isString(index) ? index === item.key : index === i} |
|
|
</Box> |
|
|
onClick={() => onTabClick(i)} |
|
|
{items[index] && items[index].render()} |
|
|
> |
|
|
</Fragment> |
|
|
{item.title} |
|
|
) |
|
|
</Tab> |
|
|
|
|
|
))} |
|
|
|
|
|
</Box> |
|
|
|
|
|
{item && item.render()} |
|
|
|
|
|
</Fragment> |
|
|
|
|
|
) |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
export default Tabs |
|
|
export default Tabs |
|
|