1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-12-23 09:52:26 +01:00

Simplify tab component (#8132)

The tab component now sets the `tab` and `tab--active` classes
internally regardless what class is passed in. The convention in React
is to allow adding _additional_ classes via the `className` prop, not
to allow removing internal classes entirely.

the `activeClassName` prop was removed entirely. A few other props that
are always passed in have been marked as required.
This commit is contained in:
Mark Stacey 2020-02-27 18:00:42 -04:00 committed by GitHub
parent ac4e1d4e26
commit 7e4916e59e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -3,13 +3,14 @@ import PropTypes from 'prop-types'
import classnames from 'classnames' import classnames from 'classnames'
const Tab = (props) => { const Tab = (props) => {
const { name, onClick, isActive, tabIndex, className, activeClassName } = props const { name, onClick, isActive, tabIndex, className } = props
return ( return (
<li <li
className={classnames( className={classnames(
'tab',
className, className,
{ [activeClassName]: isActive }, { 'tab--active': isActive },
)} )}
onClick={(event) => { onClick={(event) => {
event.preventDefault() event.preventDefault()
@ -22,17 +23,16 @@ const Tab = (props) => {
} }
Tab.propTypes = { Tab.propTypes = {
className: PropTypes.string,
isActive: PropTypes.bool.isRequired,
name: PropTypes.string.isRequired, name: PropTypes.string.isRequired,
onClick: PropTypes.func, onClick: PropTypes.func,
isActive: PropTypes.bool, tabIndex: PropTypes.number.isRequired,
tabIndex: PropTypes.number,
className: PropTypes.string,
activeClassName: PropTypes.string,
} }
Tab.defaultProps = { Tab.defaultProps = {
className: 'tab', className: undefined,
activeClassName: 'tab--active', onClick: undefined,
} }
export default Tab export default Tab