-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(Tabs): create new component (#20)
- Loading branch information
Showing
4 changed files
with
55 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters