From e8311e18bae6fb309582a076b5f9c4148faacfce Mon Sep 17 00:00:00 2001 From: "Andrey.Yaroshenko" Date: Tue, 23 May 2017 14:07:29 +0300 Subject: [PATCH] feat(Tabs): create new component (#20) --- src/Tabs/Tab.js | 32 ++++++++++++++++++++++++++++++++ src/Tabs/Tabbar.js | 19 +++++++++++++++++++ src/Tabs/index.js | 2 ++ src/index.js | 1 + 4 files changed, 54 insertions(+) create mode 100644 src/Tabs/Tab.js create mode 100644 src/Tabs/Tabbar.js create mode 100644 src/Tabs/index.js diff --git a/src/Tabs/Tab.js b/src/Tabs/Tab.js new file mode 100644 index 0000000..f49808d --- /dev/null +++ b/src/Tabs/Tab.js @@ -0,0 +1,32 @@ +import PropTypes from 'prop-types'; +import React from 'react'; +import classnames from 'classnames'; + +const propTypes = { + active: PropTypes.bool, + className: PropTypes.string, + component: PropTypes.string, +}; + +const defaultProps = { + component: 'a', +}; + +const ROOT = 'mdc-tab'; +const ACTIVE = `${ROOT}--active`; + +const Tab = ({ + active, + className, + component, + ...otherProps +}) => { + const classes = classnames(ROOT, { [ACTIVE]: active }, className); + return React.createElement(component, { + className: classes, + ...otherProps, + }); +}; +Tab.propTypes = propTypes; +Tab.defaultProps = defaultProps; +export default Tab; diff --git a/src/Tabs/Tabbar.js b/src/Tabs/Tabbar.js new file mode 100644 index 0000000..e8a208d --- /dev/null +++ b/src/Tabs/Tabbar.js @@ -0,0 +1,19 @@ +import PropTypes from 'prop-types'; +import React from 'react'; +import classnames from 'classnames'; + +const propTypes = { + className: PropTypes.string, +}; + +const ROOT = 'mdc-tab-bar'; + +const Tabbar = ({ className, ...otherProps }) => ( +