2022-05-29 17:53:27 +08:00
|
|
|
import { cx } from '@emotion/css'
|
|
|
|
|
|
|
|
const Tabs = ({
|
|
|
|
tabs,
|
|
|
|
value,
|
|
|
|
onChange,
|
2022-06-09 20:16:05 +08:00
|
|
|
className,
|
2023-01-24 16:29:33 +08:00
|
|
|
style,
|
2022-05-29 17:53:27 +08:00
|
|
|
}: {
|
|
|
|
tabs: {
|
|
|
|
id: string
|
|
|
|
name: string
|
|
|
|
}[]
|
|
|
|
value: string
|
|
|
|
onChange: (id: string) => void
|
2022-06-09 20:16:05 +08:00
|
|
|
className?: string
|
2023-01-24 16:29:33 +08:00
|
|
|
style?: React.CSSProperties
|
2022-05-29 17:53:27 +08:00
|
|
|
}) => {
|
|
|
|
return (
|
2023-01-24 16:29:33 +08:00
|
|
|
<div className={cx('no-scrollbar flex overflow-y-auto', className)} style={style}>
|
2022-05-29 17:53:27 +08:00
|
|
|
{tabs.map(tab => (
|
|
|
|
<div
|
|
|
|
key={tab.id}
|
|
|
|
className={cx(
|
2022-06-14 23:23:34 +08:00
|
|
|
'mr-2.5 rounded-12 py-3 px-6 text-16 font-medium backdrop-blur transition duration-500',
|
2022-05-29 17:53:27 +08:00
|
|
|
value === tab.id
|
|
|
|
? 'bg-brand-700 text-white'
|
2022-06-14 23:23:34 +08:00
|
|
|
: 'dark:bg-white/10 dark:text-white/20 hover:dark:bg-white/20 hover:dark:text-white/40'
|
2022-05-29 17:53:27 +08:00
|
|
|
)}
|
2022-06-08 00:07:04 +08:00
|
|
|
onClick={() => onChange(tab.id)}
|
2022-05-29 17:53:27 +08:00
|
|
|
>
|
|
|
|
{tab.name}
|
|
|
|
</div>
|
|
|
|
))}
|
|
|
|
</div>
|
|
|
|
)
|
|
|
|
}
|
|
|
|
|
|
|
|
export default Tabs
|