UNPKG

glass-app-manager

Version:

Informatica's Glass Framework CLI for bootstrapping

50 lines (41 loc) 1.17 kB
// @flow import * as React from "react"; import classNames from "classnames"; import { wrapTextNode } from "../../utils/common"; type Props = { /** * Children of the tab. */ children: Array<React.Node> | React.Node, /** * Set to true for vertical tabs. */ vertical?: boolean, /** * Additional class selectors to pass to component. */ className?: string, }; function Tabs(props: Props) { const { vertical, children, className, ...rest } = props; const classes = classNames("tabs", className, { "tabs--vertical": vertical }); return ( <ul className={classes} {...rest}> {children} </ul> ); } Tabs.defaultProps = { vertical: false, }; Tabs.Tab = function Tab({ children, className, ...rest }) { const wrapped = wrapTextNode(children); return ( <li className={classNames("tabs__tab", className)} {...rest}> {React.cloneElement(wrapped, { className: classNames("tabs__tab__control", wrapped.props.className), })} </li> ); }; export default Tabs;