-
Notifications
You must be signed in to change notification settings - Fork 207
[BD-9793][BpkButton] Reimplement BpkButton(type=link) using gradient background. #3823
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
base: main
Are you sure you want to change the base?
Conversation
Visit https://backpack.github.io/storybook-prs/3823 to see this build running in a browser. |
Visit https://backpack.github.io/storybook-prs/3823 to see this build running in a browser. |
Here are some issue in the storybook:
|
Thanks for the catch. The code has been updated. |
Visit https://backpack.github.io/storybook-prs/3823 to see this build running in a browser. |
Visit https://backpack.github.io/storybook-prs/3823 to see this build running in a browser. |
if (typeof child === 'string') { | ||
const match = child.match(/^(\s*)(.*?)(\s*)$/); | ||
const leading = match?.[1] ?? ''; | ||
const text = match?.[2] ?? ''; |
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 need consider some edge case to make it more robust, for text part, for example if the children is like <Icon />Button<Icon /> Link
, it would underline both text Button and Link, which might not be expected
<> | ||
{leading.length > 0 && <span>{leading}</span>} | ||
<span className={getCommonClassName(`bpk-button--${type}__text`)}>{text}</span> | ||
{trailing.length > 0 && <span>{trailing}</span>} |
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.
Not sure if it's a possible bug: if a user intentionally need blank space between strings and icons, such as this in storybook:
<Wrapped 'Button clicked')} {...rest}>
<BaggageCheckedIcon /> blankAhead Button blankBehind <AlignedLargeLongArrowRightIcon />
</Wrapped>
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
Reimplements link-style buttons to use a gradient underline by:
- Swapping low-contrast
em
padding inbpk-link-underlined
for a one-pixelrem
variable - Refactoring
bpk-button--link
andbpk-button--link-on-dark
mixins to use new__text
spans instead of::after
- Updating
BpkButtonV2
to wrap string children in<span>
s for gradient styling, and updating affected snapshots
Reviewed Changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated no comments.
Show a summary per file
File | Description |
---|---|
packages/bpk-mixins/_typography.scss | Changed padding-bottom: 0.03em to $bpk-one-pixel-rem |
packages/bpk-mixins/_buttons.scss | Replaced ::after underline with __text span approach |
packages/bpk-component-floating-notification/...snap.tsx | Updated snapshot to include the new __text wrapper |
packages/bpk-component-button/src/BpkButtonV2/snapshots/*.snap.tsx | Updated snapshots to match new text-wrapping spans |
packages/bpk-component-button/src/BpkButtonV2/BpkButton.tsx | Added logic to split string children into <span> elements |
Hi @isteven-shu Thank you for your contribution! I have finished reviewing your implementation and had a discussion with our team regarding this style change. Your solution addresses all the cases outlined in the visual design and also handles some edge cases well. Great job! 👍 However, there are a few questions we need to highlight and consider:
Additionally, we observed an overlap between Thank you again! |
JIRA link
Reimplement BpkButton(type=link) using gradient backgound.
Remember to include the following changes:
[Clover-123][BpkButton] Updating the colour
README.md
(If you have created a new component)README.md