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

New Feature: disableMaxHeight #2361

Open
wants to merge 12 commits into
base: main
Choose a base branch
from
Open

Conversation

nikrom17
Copy link
Contributor

@nikrom17 nikrom17 commented Mar 19, 2024

Description

Stripe wants the paypal button to expand to fill it's parent container. This PR added a new style prop disableMaxHeight that remove all height limitations on the button and adds css height: 100% everywhere.

Why are we making these changes? Include references to any related Jira tasks or GitHub Issues

Jira Ticket

Feature Branch Deployed to Test Env

I've deployed this feature branch to a test env.

I've also hooked up that test env to a storybook with a few examples of how a merchant could structure their html to showcase how the button would render in those scenarios.

https://github.paypal.com/pages/Core-SDK/button-redesign-storybook/?path=/story/edge-cases-button-disablemaxheight--container-with-fixed-height

Testing Issues

Snapshot testing seems to be the best way to go about testing this new feature, however the Percy Snapshot tests seems broken on this repo. I've spend some time trying to fix, opened a ticket with Browserstack and still havent be able to triage the exact issue for why they are failing.

I wanted to get the PR out there so yall can look at the code and then start a discussion on how we want to handle the testing.

I did update the validation tests in test/integration/tests/button/validation.js

Differences in button rendering between using style.height and disbableMaxHeight

The responsive styles of the PayPal word mark and label are calculated based off a specific height value. This comes from our default settings (height increases as width increases) or the style.height property.

I discussed this heavily with product and we decided to go this route since this solution was faster to implement and we could always go back and refactor the responsive styles if necessiary.

Below showcases the different ways the button will render based on if you specify the style.height property.
Frame 15

Groups who should review (if applicable)

❤️ Thank you!

@nikrom17 nikrom17 requested a review from a team as a code owner March 19, 2024 20:47
Copy link

codecov bot commented Mar 20, 2024

Codecov Report

Attention: Patch coverage is 33.33333% with 28 lines in your changes are missing coverage. Please review.

Project coverage is 51.96%. Comparing base (20c9729) to head (fa3f048).
Report is 62 commits behind head on main.

Current head fa3f048 differs from pull request most recent head cbd7db0

Please upload reports for the commit cbd7db0 to get more accurate results.

Files Patch % Lines
src/ui/buttons/styles/responsive.js 26.66% 11 Missing ⚠️
src/zoid/buttons/container.jsx 36.36% 6 Missing and 1 partial ⚠️
src/ui/buttons/props.js 45.45% 6 Missing ⚠️
src/ui/buttons/styles/base.js 0.00% 3 Missing ⚠️
src/ui/buttons/style.jsx 50.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2361      +/-   ##
==========================================
+ Coverage   51.32%   51.96%   +0.63%     
==========================================
  Files         104      148      +44     
  Lines        2038    11986    +9948     
  Branches      604      679      +75     
==========================================
+ Hits         1046     6228    +5182     
- Misses        889     5653    +4764     
- Partials      103      105       +2     
Flag Coverage Δ
jest 31.42% <70.00%> (-0.57%) ⬇️
karma 52.21% <88.88%> (+2.15%) ⬆️
vitest 46.10% <7.14%> (?)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@nikrom17 nikrom17 changed the title WIP: New Feature disableMaxHeight New Feature: disableMaxHeight Apr 2, 2024
@nikrom17 nikrom17 marked this pull request as draft April 2, 2024 19:19
@nikrom17 nikrom17 marked this pull request as ready for review April 2, 2024 19:19

// $FlowFixMe
].map(({ height, size, valid }) => ({
].map(({ height, valid, disableMaxHeight }) => ({
Copy link
Contributor Author

Choose a reason for hiding this comment

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

It didn't seem like size was used at all in this sections so I removed it and used the sentence structure to indicate if the disbaleMaxHeight feature was enabled.

Copy link
Member

@wsbrunson wsbrunson left a comment

Choose a reason for hiding this comment

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

looking great!

@nikrom17 nikrom17 requested a review from wsbrunson May 20, 2024 19:16
}

const disableMaxHeightInvalidFundingSources = [FUNDING.CARD, undefined];
const disableMaxHeightValidFundingSources = [
Copy link
Member

Choose a reason for hiding this comment

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

why are these the only ones supported for disabling max height?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The only 2 buttons that aren't supported are the smart stack and card. The main reason these aren't supported was the challenge of getting them to render correctly and not being the specific use case that Stripe was looking for.

It seemed like they were rendering the standalone paypal button so we focused on enabling that only.

The card button is not supported because the inline guest experience gets rendered in the same container as the card button. If the merchant but a height limitation on the container for the card button, then it was also going to apply to the inline guest experience.

I know we have a bunch of other funding sources, but I believe we only have buttons for the funding sources below. The other funding sources are for the card fields, correct?

Screenshot 2024-05-21 at 9 24 12 AM

Copy link
Member

Choose a reason for hiding this comment

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

We also have all the APMs although maybe we don't support them as standalone buttons? If so, I would think we would have a config value somewhere that disallows those buttons as standalone

https://github.com/paypal/paypal-sdk-constants/blob/main/src/funding.js#L3

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Looks like all those funding sources can be rendered as a standalone button. I've updated the error message to include all of those as well.

Copy link
Member

Choose a reason for hiding this comment

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

I would consider the following tweaks, might be easier to maintain:

  1. Early return if fundingSource === undefined. Error message could be something like disableMaxHeight is only supported for standalone buttons. You can render a standalone button by passing fundingSourceto theButton` config: paypal.Buttons({fundingSource: paypal.FUNDING.PAYPAL})

  2. Then, down below, throw the error for invalid buttons and just say "This funding source, {fundingSource}, does not support disableMaxHeight"

That's some very rough copy, feel free to change it if you decide to go in this direction

@spencersablan
Copy link
Contributor

spencersablan commented May 21, 2024

Thanks to disableMaxHeight & disableMaxWidth, I can finally fulfill my dream of making an app that is just a full screen paypal button. 🤩

image

Copy link
Contributor

@spencersablan spencersablan left a comment

Choose a reason for hiding this comment

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

Nice bro! 🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants