Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add success, error and warning variants to the Chip compo… #1717

Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions src/components/Chip/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,16 @@ Chip.propTypes = {
/** Displays tooltip text when the mouse moves over the element. */
title: PropTypes.string,
/** The variant changes the appearance of the Chip. Accepted variants include base,
* neutral, outline-brand and brand. This value defaults to base. */
variant: PropTypes.oneOf(['base', 'neutral', 'outline-brand', 'brand']),
* neutral, outline-brand, brand, success, warning and error. This value defaults to base. */
variant: PropTypes.oneOf([
'base',
'neutral',
'outline-brand',
'brand',
'success',
'warning',
'error',
]),
/** The action triggered when the close button is clicked. */
onDelete: PropTypes.func,
/** A CSS class for the outer element, in addition to the component's base classes. */
Expand Down
21 changes: 21 additions & 0 deletions src/components/Chip/styled/container.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,27 @@ const StyledContainer = attachThemeAttrs(styled.span)`
border: 1px solid ${props.palette.brand.main};
color: ${props.palette.getContrastText(props.palette.brand.main)};
`};
${props =>
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Similar blocks of code found in 4 locations. Consider refactoring.

props.variant === 'success' &&
`
background-color: ${props.palette.success.main};
border: 1px solid ${props.palette.success.main};
color: ${props.palette.getContrastText(props.palette.success.main)};
`};
${props =>
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Similar blocks of code found in 4 locations. Consider refactoring.

props.variant === 'warning' &&
`
background-color: ${props.palette.warning.main};
border: 1px solid ${props.palette.warning.main};
color: ${props.palette.getContrastText(props.palette.warning.main)};
`};
${props =>
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Similar blocks of code found in 4 locations. Consider refactoring.

props.variant === 'error' &&
`
background-color: ${props.palette.error.main};
border: 1px solid ${props.palette.error.main};
color: ${props.palette.getContrastText(props.palette.error.main)};
`};
`;

export default StyledContainer;