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

[Chip] Add chip classes #33801

Merged
merged 4 commits into from Sep 20, 2022
Merged

[Chip] Add chip classes #33801

merged 4 commits into from Sep 20, 2022

Conversation

pratikkarad
Copy link
Contributor

@pratikkarad pratikkarad commented Aug 4, 2022

I have tested this fix locally and also tested using a preview package on CodeSandbox.

Fixes #33246

@mui-bot
Copy link

mui-bot commented Aug 4, 2022

Details of bundle changes

Generated by 🚫 dangerJS against f65bdb5

@mnajdova mnajdova added bug 🐛 Something doesn't work component: chip This is the name of the generic UI component, not the React module! package: material-ui Specific to @mui/material labels Aug 5, 2022
Copy link
Member

@mnajdova mnajdova left a comment

Choose a reason for hiding this comment

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

Let's add a test for this please.

Comment on lines 75 to 101
it('should render with the root and the info class', () => {
const { container } = render(<Chip color="info" />);

const chip = container.querySelector(`.${classes.root}`);
expect(chip).to.have.class(classes.colorInfo);
});

it('should render with the root and the error class', () => {
const { container } = render(<Chip color="error" />);

const chip = container.querySelector(`.${classes.root}`);
expect(chip).to.have.class(classes.colorError);
});

it('should render with the root and the warning class', () => {
const { container } = render(<Chip color="warning" />);

const chip = container.querySelector(`.${classes.root}`);
expect(chip).to.have.class(classes.colorWarning);
});

it('should render with the root and the success class', () => {
const { container } = render(<Chip color="success" />);

const chip = container.querySelector(`.${classes.root}`);
expect(chip).to.have.class(classes.colorSuccess);
});
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
it('should render with the root and the info class', () => {
const { container } = render(<Chip color="info" />);
const chip = container.querySelector(`.${classes.root}`);
expect(chip).to.have.class(classes.colorInfo);
});
it('should render with the root and the error class', () => {
const { container } = render(<Chip color="error" />);
const chip = container.querySelector(`.${classes.root}`);
expect(chip).to.have.class(classes.colorError);
});
it('should render with the root and the warning class', () => {
const { container } = render(<Chip color="warning" />);
const chip = container.querySelector(`.${classes.root}`);
expect(chip).to.have.class(classes.colorWarning);
});
it('should render with the root and the success class', () => {
const { container } = render(<Chip color="success" />);
const chip = container.querySelector(`.${classes.root}`);
expect(chip).to.have.class(classes.colorSuccess);
});
it('should render with the color class name based on the color prop', () => {
const capitalize = str => str.charAt(0).toUpperCase() + str.slice(1);
['error', 'success', 'info', 'warning'].map((color) => {
const { container } = render(<Chip color={color} />);
const chip = container.querySelector(`.${classes.root}`);
expect(chip).to.have.class(classes[`color${capitalize(color)}`]);
});

Can we simplify maybe to something like this (I haven't run, there could be some issues with the code :))

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, Thanks for the suggestion. I have updated the unit tests for color classes.

Copy link
Member

@mnajdova mnajdova left a comment

Choose a reason for hiding this comment

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

Looks good, left one final comment.

@pratikkarad
Copy link
Contributor Author

PTAL, Thanks!

@pratikkarad
Copy link
Contributor Author

Hi @mnajdova, any updates on this?

@pratikkarad
Copy link
Contributor Author

Hey @mnajdova, any updates on this?

Copy link
Member

@mnajdova mnajdova left a comment

Choose a reason for hiding this comment

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

Looks good, thanks for the contribution. Sorry for the delay

@mnajdova mnajdova merged commit 5d09d94 into mui:master Sep 20, 2022
alexfauquette pushed a commit to alexfauquette/material-ui that referenced this pull request Oct 14, 2022
daniel-rabe pushed a commit to daniel-rabe/material-ui that referenced this pull request Nov 29, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug 🐛 Something doesn't work component: chip This is the name of the generic UI component, not the React module! package: material-ui Specific to @mui/material
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Mui Chip missing colorError in chipClasses.d.ts
3 participants