mirror of
https://github.com/CHOMPStation2/CHOMPStation2.git
synced 2025-12-16 13:13:03 +00:00
55 lines
1.3 KiB
JavaScript
55 lines
1.3 KiB
JavaScript
/**
|
|
* @file
|
|
* @copyright 2020 Aleksej Komarov
|
|
* @license MIT
|
|
*/
|
|
|
|
import { canRender, classes } from 'common/react';
|
|
import { computeBoxClassName, computeBoxProps } from './Box';
|
|
import { Icon } from './Icon';
|
|
|
|
export const Tabs = (props) => {
|
|
const { className, vertical, fill, fluid, children, ...rest } = props;
|
|
return (
|
|
<div
|
|
className={classes([
|
|
'Tabs',
|
|
vertical ? 'Tabs--vertical' : 'Tabs--horizontal',
|
|
fill && 'Tabs--fill',
|
|
fluid && 'Tabs--fluid',
|
|
className,
|
|
computeBoxClassName(rest),
|
|
])}
|
|
{...computeBoxProps(rest)}>
|
|
{children}
|
|
</div>
|
|
);
|
|
};
|
|
|
|
const Tab = (props) => {
|
|
const { className, selected, color, icon, leftSlot, rightSlot, children, ...rest } = props;
|
|
return (
|
|
<div
|
|
className={classes([
|
|
'Tab',
|
|
'Tabs__Tab',
|
|
'Tab--color--' + color,
|
|
selected && 'Tab--selected',
|
|
className,
|
|
...computeBoxClassName(rest),
|
|
])}
|
|
{...computeBoxProps(rest)}>
|
|
{(canRender(leftSlot) && <div className="Tab__left">{leftSlot}</div>) ||
|
|
(!!icon && (
|
|
<div className="Tab__left">
|
|
<Icon name={icon} />
|
|
</div>
|
|
))}
|
|
<div className="Tab__text">{children}</div>
|
|
{canRender(rightSlot) && <div className="Tab__right">{rightSlot}</div>}
|
|
</div>
|
|
);
|
|
};
|
|
|
|
Tabs.Tab = Tab;
|