Skip to content

Commit

Permalink
Merge pull request react-materialize#543 from CloudPower97/chip-refactor
Browse files Browse the repository at this point in the history
Adding Icon dependency to chip component
  • Loading branch information
alextrastero authored Dec 10, 2018
2 parents b67bf0b + 0d56e76 commit d20f777
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 13 deletions.
15 changes: 7 additions & 8 deletions src/Chip.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
import React from 'react';
import PropTypes from 'prop-types';
import cx from 'classnames';
import Icon from './Icon';

const Chip = ({ children, close, className, ...props }) => {
return (
<div className={cx('chip', className)} {...props}>
{children}
{close ? <i className="close material-icons">close</i> : null}
</div>
);
};
const Chip = ({ children, close, className, ...props }) => (
<div className={cx('chip', className)} {...props}>
{children}
{close && <Icon>close</Icon>}
</div>
);

Chip.propTypes = {
className: PropTypes.string,
Expand Down
2 changes: 1 addition & 1 deletion test/Chip.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ describe('<Chip />', () => {

test('accepts a close prop', () => {
wrapper = shallow(<Chip close />);
expect(wrapper.find('i.material-icons.close')).toHaveLength(1);
expect(wrapper.find('Icon')).toHaveLength(1);
});

test('accepts children', () => {
Expand Down
6 changes: 2 additions & 4 deletions test/__snapshots__/Chip.spec.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,9 @@ exports[`<Chip /> accepts children 1`] = `
>
Child
</p>
<i
className="close material-icons"
>
<Icon>
close
</i>
</Icon>
</div>
`;

Expand Down

0 comments on commit d20f777

Please sign in to comment.