-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: update Pill component to support latest colors
- Loading branch information
1 parent
38f5641
commit bc50bc7
Showing
12 changed files
with
181 additions
and
297 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
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
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 |
---|---|---|
@@ -1,46 +1,59 @@ | ||
import classnames from 'classnames'; | ||
import PropTypes from 'prop-types'; | ||
import React from 'react'; | ||
import PropTypes from 'prop-types'; | ||
import cx from 'classnames'; | ||
import { colors } from '../Button'; | ||
import { expandDts } from '../../utils'; | ||
import './styles.css'; | ||
|
||
const sizes = ['large', 'medium', 'small']; | ||
|
||
const Pill = ({ className, children, onClick, size, dts }) => ( | ||
const Pill = ({ children, color = colors[0], size = sizes[1], inverse = false, onClick, dts, className, ...rest }) => ( | ||
<div | ||
className={classnames('aui--pill', `aui--pill-${size}`, { 'aui--pill-clickable': onClick }, className)} | ||
{...rest} | ||
className={cx( | ||
'aui--pill', | ||
size !== sizes[1] && `aui-${size}`, | ||
color !== colors[0] && `aui-${color}`, | ||
inverse && 'aui-inverse', | ||
onClick && 'aui-clickable', | ||
className | ||
)} | ||
onClick={onClick} | ||
{...expandDts(dts)} | ||
> | ||
<div className="aui--pill-children">{children}</div> | ||
{children} | ||
</div> | ||
); | ||
|
||
Pill.defaultProps = { | ||
size: sizes[1], | ||
}; | ||
|
||
Pill.propTypes = { | ||
/** | ||
* Content inside pill | ||
* Content inside pill | ||
*/ | ||
children: PropTypes.node.isRequired, | ||
children: PropTypes.node, | ||
/** | ||
* Custom classnames | ||
* The main color for the pill | ||
*/ | ||
className: PropTypes.oneOfType([PropTypes.string, PropTypes.arrayOf(PropTypes.string)]), | ||
/** | ||
* Custome onClick event | ||
*/ | ||
onClick: PropTypes.func, | ||
color: PropTypes.oneOf(colors), | ||
/** | ||
* one of ["large", "medium", "small"] | ||
*/ | ||
size: PropTypes.oneOf(sizes), | ||
/** | ||
* Inverse the background and content color | ||
*/ | ||
inverse: PropTypes.bool, | ||
/** | ||
* Custom onClick event | ||
*/ | ||
onClick: PropTypes.func, | ||
/** | ||
* Generate "data-test-selector" on the pill | ||
*/ | ||
dts: PropTypes.string, | ||
/** | ||
* Custom classnames | ||
*/ | ||
className: PropTypes.string, | ||
}; | ||
|
||
export default Pill; |
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
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
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.