-
Notifications
You must be signed in to change notification settings - Fork 78
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-4374 Badge component #3486
base: integration
Are you sure you want to change the base?
LF-4374 Badge component #3486
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.
@gursimran-singh thank you so much for working on this, we really appreciate it. It looks great! 🙌
I left a couple of comments throughout, and additionally:
- In the designs, when the popover is open, the badge's bottom border has a smaller border radius (half of the normal radius) to sort of align with the popover.
- The ticket description includes adding the Beta badge to different Animals components, were you planning on tackling that in a separate PR? If you can't get to it it's no problem, we can split it up to a separate ticket.
I will do the mentioned changes. And regarding adding Beta badge to different Animals components, to what i remember when having discussion with team is that these can be added later(i might have got it wrong). I will add the Badge component to required places and will get in touch if i have any questions/issues doing that. Thanks. |
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! Not a blocker for merging (we can fix later), but on second thought I think on desktop the tooltip content should appear/disappear on click instead of on hover. It seems strange to me that the badge changes appearance on click and when clicking outside of it, but the tooltip interaction happens on hover. I'll double check with design tomorrow though.
On the other hand, I think there's a different design for the tooltip on mobile, which is full screen. I'll double check this tomorrow as well and let you know!
> | ||
{content} | ||
</div> | ||
dangerouslySetInnerHTML={{ __html: content }} |
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.
Could you explain the reason behind this change? Instead of setting the link as HTML within the content string, I think we should keep this as is and set the content up as a React Node including the tag
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.
My intentions when developing the component was to make it reusable with different title and content in any other section. So, do not want to hard code anything in the component itself. I will change it to use <Trans>
component from 'react-i18next' package(which i found later), is safer way to handle these situations and set the link when passing the content to the component.
Also, it would be nice if you can tell the link address, then i will update that as well.
I had discussion with team and showed them the functionality and they were ok with it. Only change was that the badge in the menu items should no show the content popup in any case.
Do let me know if there are changes and i will do it accordingly. |
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.
Hey @gursimran-singh ! Thanks for working on this, so sorry it took a while for us to get a review.
I think overall it is looking great I just found a few small things:
- The onClick behaviour does not quite work as expected on mobile (click does not work as click out) and desktop (click changes styles but does not keep tooltip open) for please see video
Screen.Recording.2024-10-25.at.12.09.29.PM.mov
Screen.Recording.2024-10-25.at.12.10.09.PM.mov
- Couple inline comments
- Would you be willing to make storybook stories for this new component?
setOpen(true); | ||
} | ||
}; | ||
const handleTooltipClose = () => { |
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.
Could handleTooltipOpen
+ handleTooltipClose
be combined by letting the state setter to use previous/pending value. React reference if useful
setOpen(prevState => !prevState)
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.
That can be done if we want the button to behave like toggle(one click open tooltip and another closes it). Honestly speaking, i am little unclear about the behaviour of this component and that is why i came to the meeting to show you guys what i build. Got some feedback and changed accordingly. Even Antonella is not sure about the hover/click functionality for both mobile and desktop and told me that she would let me know after discussing with the team.
So, do let me know what should be the behaviour of this component for onHover and click, for both mobile and desktop and i will make changes accordingly
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.
Honestly its mostly fine the way you have it as an only onHover on desktop and onClick on mobile.
But specifically the style of the button on desktop should not change onClick on desktop though as shown in the first video... unless the full click behaviour opens the tooltip. So either we need to disable click styles on desktop, or add the full onClick open behaviour. I would personally approve either of those two options.
I will tag Loic on the Jira ticket to hopefully get you clarification on this though so you feel confident. Sorry about that lack of clarity -- please always feel free to tag Loic with your UI/UX questions on the Jira ticket too!
:global(.hasBadge) .badge { | ||
height: 12px; | ||
font-size: 11px; | ||
padding: 6px; | ||
position: absolute; | ||
left: 50px; | ||
top: 8px; | ||
border-radius: 16px; | ||
&:focus, | ||
&:hover { | ||
color: var(--Colors-Accent-Accent-yellow-600); | ||
background: #fffbf2; | ||
border-radius: 16px !important; | ||
} | ||
|
||
@include xs-breakpoint { | ||
height: 16px; | ||
position: relative; | ||
font-size: 14px; | ||
top: initial; | ||
left: initial; | ||
padding: 6px; | ||
margin-right: 6px; | ||
} | ||
} |
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.
Would it be a bad idea to pass a className with these styles to the Badge component instead?
I've never seen a raw CSS className used here before, so it would be nice if we could keep things consistent!
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.
It is one of the way by which we can access the parent class in the child component. But, i will see these styles can be attained by passing class to the component and also avoiding the inline css.
style?: React.CSSProperties; | ||
} | ||
|
||
const Badge: React.FC<BadgeProps> = ({ content = '', title, showIcon = true, style }) => { |
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.
We're aiming to avoid inline CSS, so could you please change the style
prop to className
instead? 🙏
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.
Its good we are avoiding the inline css, i have seen a lot here. And sure, i will update accordingly.
Description
A reusable badge component that shows the content when onHover - desktop, onClick - mobile, desktop. Usage:
<Badge title='Beta' content='This is the content which will be displayed onHover - desktop, onClick - mobile, desktop' />
Jira link: https://lite-farm.atlassian.net/browse/LF-4374
Type of change
How Has This Been Tested?
Checklist: