Skip to content

Commit

Permalink
feat(Tabs): create new component (#20)
Browse files Browse the repository at this point in the history
  • Loading branch information
kradio3 committed May 23, 2017
1 parent a147cdf commit 74faa23
Show file tree
Hide file tree
Showing 4 changed files with 55 additions and 0 deletions.
32 changes: 32 additions & 0 deletions src/Tabs/Tab.js
Original file line number Diff line number Diff line change
@@ -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;
20 changes: 20 additions & 0 deletions src/Tabs/Tabbar.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
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 }) => {
return (
<nav
className = {classnames(ROOT, className)}
{...otherProps}
/>
) };

Tabbar.propTypes = propTypes;
export default Tabbar;
2 changes: 2 additions & 0 deletions src/Tabs/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export { default as Tabbar } from './Tabbar';
export { default as Tab } from './Tab';
1 change: 1 addition & 0 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,3 +32,4 @@ export {
} from './Typography';
export { GridList, Tile, TilePrimary, TileSecondary, TileContent, TileTitle, TileSupportText } from './GridList';
export { default as Switch } from './Switch';
export { Tab, Tabbar} from './Tabs';

0 comments on commit 74faa23

Please sign in to comment.