diff --git a/client/coral-ui/components/Tab.js b/client/coral-ui/components/Tab.js index 75b30085a..4fd85b303 100644 --- a/client/coral-ui/components/Tab.js +++ b/client/coral-ui/components/Tab.js @@ -3,6 +3,10 @@ import styles from './Tab.css'; import cn from 'classnames'; import PropTypes from 'prop-types'; +/** + * The `Tab` component is used inside the `TabBar` Component, to + * render tabs. + */ class Tab extends React.Component { handleTabClick = () => { if (this.props.onTabClick) { @@ -69,7 +73,11 @@ class Tab extends React.Component { } Tab.propTypes = { + + // className to be added to the root element. className: PropTypes.string, + + // classNames allows full design customization of the component. classNames: PropTypes.shape({ root: PropTypes.string, rootActive: PropTypes.string, @@ -80,9 +88,22 @@ Tab.propTypes = { buttonSub: PropTypes.string, buttonSubActive: PropTypes.string, }), + + // active indicates that this tab is currently active. + // This is injected by the `TabBar` component. active: PropTypes.bool, + + // onTabClick is fired whenever the tab was clicked. The tabId is passed as + // the first argument. onTabClick: PropTypes.func, + + // Sub indicates that this is a tab of a sub-tab-panel. + // This is injected by the `TabBar` component. sub: PropTypes.bool, + + // `aria-controls` should be set to the `id` of the `TabContent` for accessibility. + // This is injected by the `TabBar` component. + 'aria-controls': PropTypes.string, }; export default Tab; diff --git a/client/coral-ui/components/TabBar.js b/client/coral-ui/components/TabBar.js index 433213a30..1a51c60f2 100644 --- a/client/coral-ui/components/TabBar.js +++ b/client/coral-ui/components/TabBar.js @@ -4,6 +4,10 @@ import cn from 'classnames'; import Tab from './Tab'; import PropTypes from 'prop-types'; +/** + * The `TabBar` component accepts `Tab` components to create + * a tab bar. + */ class TabBar extends React.Component { getRootClassName({className, classNames = {}, sub} = this.props) { @@ -52,15 +56,31 @@ class TabBar extends React.Component { } TabBar.propTypes = { + + // className to be added to the root element. className: PropTypes.string, + + // classNames allows full design customization of the component. classNames: PropTypes.shape({ root: PropTypes.string, rootSub: PropTypes.string, }), + + // classNames to be passed to the children. tabClassNames: Tab.propTypes.classNames, + + // activeTab should be set to the currently active tabId. activeTab: PropTypes.string, + + // onTabClick is fired whenever the tab was clicked. The tabId is passed as + // the first argument. onTabClick: PropTypes.func, + + // Sub indicates that this is a sub-tab-panel. sub: PropTypes.bool, + + // `aria-controls` should be set to the `id` of the `TabContent` for accessibility. + 'aria-controls': PropTypes.string, }; export default TabBar; diff --git a/client/coral-ui/components/TabContent.js b/client/coral-ui/components/TabContent.js index 768000cb6..99676f7cc 100644 --- a/client/coral-ui/components/TabContent.js +++ b/client/coral-ui/components/TabContent.js @@ -7,6 +7,10 @@ function getRootClassName(className) { return cn('talk-tab-content', className, styles.root); } +/** + * The `TabContent` component accepts `TabPane` components to render + * the content of a `Tab`. + */ const TabContent = ({children, className, activeTab, sub, ...rest}) => (