-
Notifications
You must be signed in to change notification settings - Fork 841
Components: Add PricingTable component #25377
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
Conversation
|
Caution: This PR has changes that must be merged to WordPress.com |
|
Thank you for your PR! When contributing to Jetpack, we have a few suggestions that can help us test and review your patch:
This comment will be updated as you work on your PR and make changes. If you think that some of those checks are not needed for your PR, please explain why you think so. Thanks for cooperation 🤖 The e2e test report can be found here. Please note that it can take a few minutes after the e2e tests checks are complete for the report to be available. Once your PR is ready for review, check one last time that all required checks (other than "Required review") appearing at the bottom of this PR are passing or skipped. Jetpack plugin:
Boost plugin:
Social plugin:
Starter Plugin plugin:
Protect plugin:
Videopress plugin:
|
projects/js-packages/components/components/pricing-table/index.tsx
Outdated
Show resolved
Hide resolved
| PricingTableItemProps, | ||
| } from './types'; | ||
|
|
||
| const PricingTableContext = createContext( undefined ); |
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.
Some context on why I'm adding undefined here: WordPress/gutenberg#39526
projects/js-packages/components/components/pricing-table/stories/index.tsx
Outdated
Show resolved
Hide resolved
projects/js-packages/components/components/pricing-table/index.tsx
Outdated
Show resolved
Hide resolved
projects/js-packages/components/components/pricing-table/index.tsx
Outdated
Show resolved
Hide resolved
projects/js-packages/components/components/pricing-table/index.tsx
Outdated
Show resolved
Hide resolved
| const items = useContext( PricingTableContext ); | ||
| const Wrapper = isLg ? Fragment : 'div'; | ||
| const wrapperProps = ! isLg ? { className: styles.card } : {}; | ||
| let index = 0; |
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.
You can remove it, the second received parameter in Children.map is the index.
Children.map( children, ( child, index ) => ... )
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've left this in, because I want the index of the PricingTableItem, not just anything in PricingTableColumn. For example, if there's a PricingTableHeader in the column, the indexes of the items will be 1 and 2 (after the headers), but the indexes of the related labels will still be 0 and 1.
That being said, there's probably a better way to do this so I'm very much open to suggestions.
projects/js-packages/components/components/pricing-table/index.tsx
Outdated
Show resolved
Hide resolved
projects/js-packages/components/components/pricing-table/styles.module.scss
Outdated
Show resolved
Hide resolved
projects/js-packages/components/components/pricing-table/styles.module.scss
Outdated
Show resolved
Hide resolved
projects/js-packages/components/components/pricing-table/styles.module.scss
Outdated
Show resolved
Hide resolved
projects/js-packages/components/components/pricing-table/styles.module.scss
Outdated
Show resolved
Hide resolved
| } | ||
|
|
||
| .label.label { | ||
| font-weight: 700; |
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.
You can remove this one, you're already using strong there, and we avoid overriding font-weight since Text is the one responsible for it.
Btw, this is something we should go for Design, in their current specs, there's no strong variant for body-small
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 I added the strong later (that's also why I initially used .value.value and .label.label, since without those double classes the Text component was overriding it.
projects/js-packages/components/components/pricing-table/styles.module.scss
Outdated
Show resolved
Hide resolved
projects/js-packages/components/components/pricing-table/styles.module.scss
Outdated
Show resolved
Hide resolved
| position: absolute; | ||
| height: 100%; | ||
| width: calc( | ||
| ( 100% / var( --columns ) ) - ( ( var( --columns ) - 1 ) * var( --gap ) / var( --columns ) ) |
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.
IMO this approach has 2 problems:
Is difficult to read all the calc and looks really complex and could break in some moment if something changes in the structure.
I took the freedom to create a new branch and suggest a refactor at this, using display: contents:
Take a look at it, and let me know if makes sense.
It already includes: #25377 (comment) suggestion on it
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.
Should be better now!
projects/js-packages/components/components/pricing-table/styles.module.scss
Show resolved
Hide resolved
projects/js-packages/components/components/pricing-table/styles.module.scss
Outdated
Show resolved
Hide resolved
Co-authored-by: Renato Augusto Gama dos Santos <renato_0603@hotmail.com>
|
@renatoagds Thank you for the thorough review! It was super helpful and I think it helped simplify and improve the component a lot.
Looking forward to hearing what you think! |
renatoagds
left a comment
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! Thanks for your work on this 🚀
|
Great news! One last step: head over to your WordPress.com diff, D85299-code, and deploy it. Thank you! |
|
r250813-wpcom |
Co-authored-by: Renato Augusto Gama dos Santos <renato_0603@hotmail.com> Co-authored-by: sdixon194 <steve.dixon@automattic.com>
This PR adds a new Pricing Table component, that can be used to compare multiple plans.
Changes proposed in this Pull Request:
Other information:
Jetpack product discussion
p1659435614747009-slack-C02TQF5VAJD
p6TEKc-6td-p2
Does this pull request change what data or activity we track or use?
No.
Testing instructions:
npm run testin the component package and make sure the tests pass.