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

[Rating] Add a demo with different icons #19004

Merged
merged 14 commits into from
Dec 30, 2019

Conversation

hoop71
Copy link
Contributor

@hoop71 hoop71 commented Dec 27, 2019

Starts to provide a solution for #18971. Thinking I will round this out and also add a prop that allows the user to align the icons as desired.

Would love feedback from the team if this seems like a good path? @oliviertassinari

Closes #18971.

@mui-pr-bot
Copy link

mui-pr-bot commented Dec 27, 2019

No bundle size changes comparing 25d7040...08811eb

Generated by 🚫 dangerJS against 08811eb

Copy link
Member

@mbrookes mbrookes left a comment

Choose a reason for hiding this comment

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

Thanks for working on this, it's a great start!

A docs demo would be good, for example using the sentiment icons.

packages/material-ui-lab/src/Rating/Rating.js Outdated Show resolved Hide resolved
@hoop71
Copy link
Contributor Author

hoop71 commented Dec 28, 2019

Thanks for working on this, it's a great start!

A docs demo would be good, for example using the sentiment icons.

Thanks! I'll work on this soon. Any CSS ideas on how to align these icon to baseline?

@oliviertassinari
Copy link
Member

oliviertassinari commented Dec 28, 2019

@hoop71 Thanks for exploring this issue. Regarding the implementation, I don't think that we need to significantly change the source nor the API. I believe a new demo would require most of the work (leveraging the existing IconContainer prop). However, maybe we need to leak part/all the state to the public API?

@oliviertassinari oliviertassinari added component: rating This is the name of the generic UI component, not the React module! new feature New feature or request labels Dec 28, 2019
@hoop71
Copy link
Contributor Author

hoop71 commented Dec 28, 2019

@hoop71 Thanks for exploring this issue. Regarding the implementation, I don't think that we need to significantly change the source nor the API. I believe a new demo would require most of the work (leveraging the existing IconContainer prop). However, maybe we need to leak part/all the state to the public API?

Got it. This makes a lot of senes.

@hoop71
Copy link
Contributor Author

hoop71 commented Dec 28, 2019

OK - I think this is working pretty well with the IconContainer prop. This is a slick solution. Very nice. On the VariableSizeRating icons, I am having trouble getting the hidden input to match the size? Any ideas @oliviertassinari or @mbrookes? I can write a few more tests for this as well if needed.

Cheers.

@mbrookes
Copy link
Member

mbrookes commented Dec 28, 2019

For the sentiment example it would be good to provide custom text labels using getLabelText.

Not sure what's going on with the size example. (Do you have a practical use-case for this?)

If you edit the typescript demo, the JS demo can be generated with yarn docs:typescript.

@oliviertassinari
Copy link
Member

oliviertassinari commented Dec 28, 2019

Capture d’écran 2019-12-28 à 21 10 31

What has Google done! There is twice the SVG path for the eyes, it makes me feel uncomfortable 😆.

Not sure what's going on with the size example. (Do you have a practical use-case for this?)

@mbrookes +1 for keeping it simple (no demo)


@hoop71 Could you migrate the demo to TypeScript? :)

@oliviertassinari oliviertassinari added the docs Improvements or additions to the documentation label Dec 28, 2019
@hoop71
Copy link
Contributor Author

hoop71 commented Dec 28, 2019

For the sentiment example it would be good to provide custom text labels using getLabelText.

Not sure what's going on with the size example. (Do you have a practical use-case for this?)

If you edit the typescript demo, the JS demo can be generated with yarn docs:typescript.

Yes, I can do this in typescript and getLabelText, no problem.

The example came from the orginal ask in #18971. I guess it depends on how much you'd like to show in the demo or let users figure out?

Co-Authored-By: Olivier Tassinari <olivier.tassinari@gmail.com>
@oliviertassinari
Copy link
Member

oliviertassinari commented Dec 28, 2019

Regarding the size issue, all the rating needs to have the same width for the logic to work correctly. It's a simplification of the logic. We are lucky it's probably a good constraint for UX.

@mbrookes
Copy link
Member

The example came from the orginal ask in #18971.

In the sample image in the issue those look like different icons, rather than the same icon resized (they're all the same width).

I think we can safely drop the size demo as @oliviertassinari suggested.

@hoop71 hoop71 marked this pull request as ready for review December 29, 2019 17:36
@oliviertassinari oliviertassinari removed the new feature New feature or request label Dec 30, 2019
@oliviertassinari oliviertassinari changed the title [Rating] Allow different icons [Rating] Add a demo with different icons Dec 30, 2019
@oliviertassinari oliviertassinari merged commit 991b858 into mui:master Dec 30, 2019
@oliviertassinari
Copy link
Member

@hoop71 Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component: rating This is the name of the generic UI component, not the React module! docs Improvements or additions to the documentation
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Rating] Allow different icons
4 participants