saagie-ui
Version:
Saagie UI from Saagie Design System
60 lines (54 loc) • 1.16 kB
JavaScript
import React from 'react';
import PropTypes from 'prop-types';
import classnames from 'classnames';
import { modifierCSS } from '../../../helpers';
const propTypes = {
/**
* Children to set inside the Tabs.
*
* @see TabList
* @see Tab
* @see TabPanel
*/
children: PropTypes.node,
/**
* The default class for the TabList.
*/
defaultClassName: PropTypes.oneOfType([PropTypes.string, PropTypes.arrayOf(PropTypes.string)]),
/**
* Size of the tab.
*/
size: PropTypes.oneOf(['', 'sm', 'lg']),
/**
* The custom tag for the root of the TabList
*/
tag: PropTypes.oneOfType([PropTypes.func, PropTypes.string]),
};
const defaultProps = {
children: '',
defaultClassName: 'sui-m-tabs',
size: '',
tag: 'div',
};
/**
* Tabs is the main component to manage tabs using context.
*/
export const Tabs = ({
children,
defaultClassName,
size,
tag: Tag,
...attributes
}) => {
const classes = classnames(
defaultClassName,
modifierCSS(size),
);
return (
<Tag className={classes} {...attributes}>
{children}
</Tag>
);
};
Tabs.propTypes = propTypes;
Tabs.defaultProps = defaultProps;