-
Notifications
You must be signed in to change notification settings - Fork 45
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
feat(reader-revenue): make NYP and Stripe Gateway optional #1645
Merged
Merged
Changes from 11 commits
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
79c2612
fix(donate): don’t require Name Your Price extension
dkoo db8797e
feat(donate): force untiered and non-manual when NYP is available
dkoo c7c5b5c
fix: typescript lint errors
dkoo bb3b2e1
Merge branch 'master' into fix/optional-nyp-stripe-gateway
dkoo 9f528b8
Update src/blocks/donate/frontend/class-newspack-blocks-donate-render…
dkoo a991eb8
Merge branch 'master' into fix/optional-nyp-stripe-gateway
dkoo a985f00
fix: undefined array key warning
dkoo 308181d
fix: hide layout options if NYP not available
dkoo 3701068
fix: make amount + frequency label translatable
dkoo 42e145b
chore: remove unused variables
dkoo 3a15ae5
fix: eslint errors
dkoo 5f9479a
refactor: use wc and wcs methods to get formatted price
dkoo 977db4b
fix: add missing TS type
dkoo 2b65371
fix: add missing TS type
dkoo c388896
Merge branch 'trunk' into fix/optional-nyp-stripe-gateway
dkoo 5b8470c
fix: avoid NaN with empty number inputs
dkoo 9f041db
fix: show minimum suggestion warning for null values
dkoo 8c01e69
Merge branch 'trunk' into fix/optional-nyp-stripe-gateway
dkoo File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 wonder if we can have this string passed from the backend via
newspack_blocks_data
since the logic for creating the string already lives there? Then we can remove the duplicate logic from the frontend.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.
Done in 5f9479a. Because the block needs to be able to dynamically render values from attributes, this may look a little janky with the string replacement, but I'm open to better suggestions.
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.
Ah. I see what you mean. It definitely does seem a bit overly complex. I'm not sure of a cleaner way to handle this with the existing design for the donate block. My suggestion would be to remove the
per X
/once
from the amount strings altogether as this is implied based on the category tab selection at the top (one-time/monthly/annually). But I think changing the design of this might be outside of the scope of this PR.I think what we have here is fine, although there is an edge case where the publisher has an empty value set, for example while editing an amount. The block shows
NaN
: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.
5b8470c forces the value to be
0
in this case. Maybe still not ideal, but better than$NaN
?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 think it makes sense to set this to 0 when the input is empty. One other issue I noticed just now while retesting this is if the input is empty, we need to make sure the below $X validation still functions and prevents us from saving.
Here it is with an input value less than 5 for me:

And while the input is empty:

I think instead of forcing how the null value is rendered in the preview, we can force null values to be stored as 0 somewhere around here:
newspack-blocks/src/blocks/donate/edit/index.tsx
Line 109 in 5b8470c
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 also want to note while I was retesting this, I did some more thinking about the complexity of generating the translation string with dynamic pricing and HTML elements, and realized we can probably reduce the complexity by removing the
span
wrappers from the currency symbol and price, and instead placing them only around the frequency string.We can achieve the same style results via CSS this way by setting the
.wpbnbd__tiers__amount__value
text to have the bolded and enlarged size and set the frequency span to have the unbolded smaller size.This is how it is rendered right now:
We can probably achieve the same result with this:
I'm okay if we tackle this another time though since this PR has become quite involved.
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's a good call, but yes, let's leave for another PR.
At first I tried forcing empty input values to be stored as
0
, but this results in the input itself showing0
when you delete the values in the input, which is potentially confusing to the user. Agree that we should still validate against the minimum donation value, though.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.
Implemented in 9f041db