-
Notifications
You must be signed in to change notification settings - Fork 84
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
LF-4079 Create reusable group pill component #3115
LF-4079 Create reusable group pill component #3115
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Super quick, and looks great!
I wonder how flexible this component should be.
If there is a pill at the bottom of the window and the number is 5 for example, the tooltip will be cut off.
I'm not sure what Loïc's solution will be, but I think it would be nice if the placement changes depending on where in the window the pill is. (it might be easy to implement it with a Mui component https://mui.com/material-ui/react-tooltip/)
@SayakaOno Oh, that is the kind of thing I would never have considered! 😂 Thank you for the MUI component link. I'll give it a try and also see if I can fix the story to be better about positioning. |
Add position property and new decorator to allow casting component to different parts of the Storybook frame
@loicsans some strings to translate here too |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great!
The options for the position in the story are very nice! Thank you ❤️
I'll approve once the changes are finalized.
Co-authored-by: Joyce Yuki <[email protected]>
enterTouchDelay={0} | ||
leaveTouchDelay={900000} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a reason we're not using the defaults here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These values come from the other MUI tooltip we have in app (the Info icon tooltip). Personally my reaction to the MUI default (that you have to long press and not tap) was to think the hover pill was broken on mobile! I think probably that's how the Infoi got its settings too. But is the long press interaction more standard?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, I have no idea which one would be more common tbh! But that makes sense to me
{ | ||
name: 'offset', | ||
options: { | ||
offset: [0, -8], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's something super small that's bothering me 😅 which I think is actually buggy behavior from MUI, but hopefully we can fix it? When you hover over the pill and the tooltip opens, if you then hover back to the pill there's a space within it where hovering doesn't work and the styling turns back to the "unhovered" style. I recorded a video which hopefully shows it better.
Grabacion.de.pantalla.2024-02-08.a.la.s.10.02.49.mov
I couldn't figure out why this was happening, but it turns out that the tooltip has a bottom margin and that bit of it is overlapped with the pill.
![Captura de pantalla 2024-02-08 a la(s) 10 05 28](https://private-user-images.githubusercontent.com/20230771/303338809-c8ca6d72-2c48-41af-aefa-4260fc27ec36.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3Mzk2NDA2NDAsIm5iZiI6MTczOTY0MDM0MCwicGF0aCI6Ii8yMDIzMDc3MS8zMDMzMzg4MDktYzhjYTZkNzItMmM0OC00MWFmLWFlZmEtNDI2MGZjMjdlYzM2LnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNTAyMTUlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjUwMjE1VDE3MjU0MFomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTIwZmM2ZTk3MjFjYmRjZTEzMjVmNmIwYmI1OTcyNzg5MDc0MzdkNGQ5YmZmZDNiMjM3YWNmMjdhMmI3OGMxYjImWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0In0.FOve7IfjR0po2YBDpNlpxNGlqHGf89t8C7C7kBnxS8o)
The solution seems to be to apply a margin: 0
style to the tooltip to override MUI's margin, and then adjust the offset to be a positive number so that there's still some space between the tooltip and the pill. The only problem is that the MUI selector is more specific than the .hoverDetails
one, so for it to work the custom selector needs to be more specific. One way that I found to do this without using !important
is to apply the hoverDetails
styling to MUI's styling for specific tooltip placements, like this:
<Tooltip
classes={{
tooltip: styles.hoverDetails,
tooltipPlacementTop: styles.hoverDetails,
}}
...
>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, so that's why the offset had to be negative in the first place! These default component styles always get me!! 🤣
I couldn't get it to work just like you described though (with override classes but without !important
); could you check again? 😅 And once the overall offset is changed to positive I think we'll need to override classes for more placements (I would think at least tooltipPlacementBottom
)? If so I think it might be okay (and at least more succinct) to go the !important
route...
(I'll commit the !important
version which does fix the bug, but if you could check the code again...!)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah no, you're right, it doesn't work, I had probably done a different change and thought it worked when it didn't. At some point I just repeated the same selector to increase the specificity, like .hoverDetails.hoverDetails.hoverDetails
but I think anyone reading that would wonder what's going on there probably 😅 so I'm alright with keeping the important. For the record this is one of the things I strongly dislike about MUI, which is how hard it is to override their styling
Looks great and the story works great too! There's a conflict from your other PR which I just merged, and I added a comment for a styling detail that's bugging me but other than that it's perfect 🙂 |
Also added the _many for the COUNT_OTHERS from PR #3115 -- although the component doesn't need it -- as the i18n script was automatically generating it. Translated total (it's the same in all languages??) as it was present in previous table headings
TODO:
Description
+ {{count}} others
Hover Pill for use on the Group column of the Animal tableSmall note: on mobile the distance from anchor to tooltip is further than on Desktop. This is true for the other MUI Tooltip in app (the
<Infoi />
component) as well and I am not sure the reason.Jira link: https://lite-farm.atlassian.net/browse/LF-4079
Type of change
How Has This Been Tested?
Only viewed in Storybook UI as not yet present in App.
Checklist: