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

Fix Banner styling for custom action buttons #2260

Merged
merged 2 commits into from
Jun 27, 2024

Conversation

beaesguerra
Copy link
Member

@beaesguerra beaesguerra commented Jun 25, 2024

Summary:

Fixing styling issue where non-tertiary buttons get cropped when used as a custom action in the banner component.

Issue: WB-1716

Test plan:

  • Confirm buttons look as expected in the banner (?path=/story/packages-banner--with-custom-action-primary)
  • Confirm a mix of actions and custom actions look as expected in the banner (?path=/story/packages-banner--with-mixed-actions)

Screenshots:

Mixed actions (before & after changes)
before-mixed
after-mixed

Primary button for custom action (before & after changes)
before-primary
after-primary

… as a custom action in the banner component. This is fixed by wrapping the custom action with flex-shrink: 0 so that the custom action can overflow. The set height is not removed so that the alignment can still stay the same
@beaesguerra beaesguerra self-assigned this Jun 25, 2024
Copy link

changeset-bot bot commented Jun 25, 2024

🦋 Changeset detected

Latest commit: ec591bd

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@khanacademy/wonder-blocks-banner Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

Copy link
Contributor

github-actions bot commented Jun 25, 2024

Size Change: +1 B (0%)

Total Size: 97.1 kB

Filename Size Change
packages/wonder-blocks-banner/dist/es/index.js 1.53 kB +2 B (+0.13%)
packages/wonder-blocks-button/dist/es/index.js 4.28 kB -1 B (-0.02%)
ℹ️ View Unchanged
Filename Size
packages/wonder-blocks-accordion/dist/es/index.js 3.78 kB
packages/wonder-blocks-birthday-picker/dist/es/index.js 1.72 kB
packages/wonder-blocks-breadcrumbs/dist/es/index.js 1.13 kB
packages/wonder-blocks-cell/dist/es/index.js 2.25 kB
packages/wonder-blocks-clickable/dist/es/index.js 3.3 kB
packages/wonder-blocks-core/dist/es/index.js 3.66 kB
packages/wonder-blocks-data/dist/es/index.js 6.34 kB
packages/wonder-blocks-dropdown/dist/es/index.js 14.4 kB
packages/wonder-blocks-form/dist/es/index.js 5.34 kB
packages/wonder-blocks-grid/dist/es/index.js 1.36 kB
packages/wonder-blocks-i18n/dist/es/index.js 4.6 kB
packages/wonder-blocks-icon-button/dist/es/index.js 3.23 kB
packages/wonder-blocks-icon/dist/es/index.js 1.06 kB
packages/wonder-blocks-labeled-field/dist/es/index.js 72 B
packages/wonder-blocks-layout/dist/es/index.js 1.94 kB
packages/wonder-blocks-link/dist/es/index.js 2.53 kB
packages/wonder-blocks-modal/dist/es/index.js 5.51 kB
packages/wonder-blocks-pill/dist/es/index.js 1.64 kB
packages/wonder-blocks-popover/dist/es/index.js 4.85 kB
packages/wonder-blocks-progress-spinner/dist/es/index.js 1.52 kB
packages/wonder-blocks-search-field/dist/es/index.js 1.54 kB
packages/wonder-blocks-switch/dist/es/index.js 2.09 kB
packages/wonder-blocks-testing/dist/es/index.js 3.94 kB
packages/wonder-blocks-theming/dist/es/index.js 693 B
packages/wonder-blocks-timing/dist/es/index.js 1.8 kB
packages/wonder-blocks-tokens/dist/es/index.js 1.74 kB
packages/wonder-blocks-toolbar/dist/es/index.js 855 B
packages/wonder-blocks-tooltip/dist/es/index.js 6.91 kB
packages/wonder-blocks-typography/dist/es/index.js 1.48 kB

compressed-size-action

Copy link
Contributor

github-actions bot commented Jun 25, 2024

A new build was pushed to Chromatic! 🚀

https://5e1bf4b385e3fb0020b7073c-ygxcaiagiz.chromatic.com/

Chromatic results:

Metric Total
Captured snapshots 340
Tests with visual changes 2
Total stories 428
Inherited (not captured) snapshots [TurboSnap] 0
Tests on the build 340

Copy link

codecov bot commented Jun 25, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 95.76%. Comparing base (4e82c4c) to head (ec591bd).
Report is 2 commits behind head on main.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #2260      +/-   ##
==========================================
+ Coverage   94.70%   95.76%   +1.06%     
==========================================
  Files         248      248              
  Lines       29513    29514       +1     
  Branches     1668     2417     +749     
==========================================
+ Hits        27950    28265     +315     
+ Misses       1559     1241     -318     
- Partials        4        8       +4     
Files Coverage Δ
...ges/wonder-blocks-banner/src/components/banner.tsx 100.00% <100.00%> (ø)

... and 41 files with indirect coverage changes


Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 4e82c4c...ec591bd. Read the comment docs.

@beaesguerra beaesguerra marked this pull request as ready for review June 25, 2024 21:42
@khan-actions-bot
Copy link
Contributor

Gerald

Required Reviewers
  • @Khan/wonder-blocks for changes to .changeset/new-rice-punch.md, __docs__/wonder-blocks-banner/banner.stories.tsx, packages/wonder-blocks-banner/src/components/banner.tsx

Don't want to be involved in this pull request? Comment #removeme and we won't notify you of further changes.

@khan-actions-bot khan-actions-bot requested a review from a team June 25, 2024 21:42
Copy link
Contributor

github-actions bot commented Jun 25, 2024

npm Snapshot: Published

🎉 Good news!! We've packaged up the latest commit from this PR (ea52fc7) and published all packages with changesets to npm.

You can install the packages in webapp by running:

./services/static/dev/tools/deploy_wonder_blocks.js --tag="PR2260"

Packages can also be installed manually by running:

yarn add @khanacademy/wonder-blocks-<package-name>@PR2260

@@ -204,7 +204,7 @@ const Banner = (props: Props): React.ReactElement => {
if (action.type === "custom") {
return (
<View style={styles.action} key={`custom-action-${i}`}>
{action.node}
<View style={styles.customAction}>{action.node}</View>
Copy link
Member

Choose a reason for hiding this comment

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

question: Would it be possible to merge this style in the parent View? I'm not sure if that will affect applying flexShrink in there? if it can be done, it would be better as we avoid introducing more divs in that component.

<View style={[styles.action, styles.customAction]} key...>{action.node}</div>

Copy link
Member Author

Choose a reason for hiding this comment

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

Great question! flexShrink needs to be applied to the child of the flex container. It would be great if we could use a child combinator (> *) in styles.action, but I wasn't able to get that working! Let me know if there is another way we could apply the styles to the children element(s)!

Copy link
Member Author

@beaesguerra beaesguerra Jun 26, 2024

Choose a reason for hiding this comment

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

I found another solution that doesn't require adding an extra div! Thanks for the suggestion of moving the height to the actions container 😄

@khan-actions-bot khan-actions-bot requested a review from a team June 26, 2024 20:53
Copy link
Member

@jeresig jeresig left a comment

Choose a reason for hiding this comment

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

Thank you for the fixes, Bea!

@beaesguerra beaesguerra merged commit a44e87b into main Jun 27, 2024
25 of 27 checks passed
@beaesguerra beaesguerra deleted the banner-custom-actions-styling branch June 27, 2024 15:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants