-
Notifications
You must be signed in to change notification settings - Fork 203
[BD-9759][BpkPopover] Add close button beside body #3883
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
[BD-9759][BpkPopover] Add close button beside body #3883
Conversation
Visit https://backpack.github.io/storybook-prs/3883 to see this build running in a browser. |
<div className={bodyClassNames}> | ||
<div>{children}</div> | ||
{!labelAsTitle && closeButtonIcon && ( | ||
<BpkCloseButton |
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.
In the code above we also define a closebutton, can we ensure both close buttons us the same code (ie. refactor to a const)
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.
yeah, it's the same code, let me do some refactoring. Thank you
…-9759-Add-close-button-beside-BpkPopover-body
Visit https://backpack.github.io/storybook-prs/3883 to see this build running in a browser. |
Co-authored-by: tuxiu.luo <359703836@qq.com>
Visit https://backpack.github.io/storybook-prs/3883 to see this build running in a browser. |
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.
LGTM
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.
Pull Request Overview
This PR implements the ability to display a close button in the popover body when there's no title, addressing the case where a close icon button is needed without a title being present. The change allows for more flexible popover configurations while maintaining existing functionality.
- Extracts close button elements into reusable components for better code organization
- Adds conditional rendering of close button icon in popover body when
labelAsTitle
is false - Updates CSS to support flexbox layout for proper positioning of close button beside body content
Reviewed Changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.
Show a summary per file
File | Description |
---|---|
BpkPopover.tsx |
Refactors close button rendering logic and adds close button to body when no title is present |
BpkPopover.module.scss |
Adds flexbox styling to popover body for close button positioning |
BpkPopover-test.tsx |
Adds test coverage for new close button functionality and fixes code style issues |
stories.js |
Exports new story example for popover without title |
examples.js |
Implements example component demonstrating popover without title functionality |
@@ -300,7 +295,10 @@ const BpkPopover = ({ | |||
{label} | |||
</span> | |||
)} | |||
<div className={bodyClassNames}>{children}</div> | |||
<div className={bodyClassNames}> | |||
<div>{children}</div> |
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.
Wrapping children in an anonymous div without any styling or semantic purpose adds unnecessary DOM nesting. Consider removing this wrapper div or adding appropriate CSS classes if styling is needed.
<div>{children}</div> | |
{children} |
Copilot uses AI. Check for mistakes.
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.
🤔 Why do we need a nested DIV here? Any specific consideration?
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.
I just keep the original layout, previous children
is also wrapped with div. Maybe because children
could be some pure strings
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.
I'm not sure if I find the right place. I noticed the children
is a ReactNode prop. I didn't see any wrapped div
.
Is this the previous code?
backpack/packages/bpk-component-popover/src/BpkPopover.tsx
Lines 303 to 308 in e55c824
<div className={bodyClassNames}>{children}</div> | |
{actionText && onAction && ( | |
<div className={getClassName('bpk-popover__action')}> | |
<BpkButtonLink onClick={onAction}> | |
{actionText} | |
</BpkButtonLink> |
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.
yeah, I mean this line <div className={bodyClassNames}>{children}</div>
, it would keep the layout of children
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.
Visit https://backpack.github.io/storybook-prs/3883 to see this build running in a browser. |
This reverts commit 84a880a.
We found close icon button always be with title together. But sometimes we need the button while no title, so need to handle this case in codes.
Remember to include the following changes:
[Clover-123][BpkButton] Updating the colour
README.md
(If you have created a new component)README.md