-
Notifications
You must be signed in to change notification settings - Fork 2k
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
Goals Capture: Add SelectCard component #64042
Conversation
Here is how your PR affects size of JS and CSS bundles shipped to the user's browser: App Entrypoints (~176 bytes added 📈 [gzipped])
Common code that is always downloaded and parsed every time the app is loaded, no matter which route is used. Legend What is parsed and gzip size?Parsed Size: Uncompressed size of the JS and CSS files. This much code needs to be parsed and stored in memory. Generated by performance advisor bot at iscalypsofastyet.com. |
9f178e0
to
577f329
Compare
577f329
to
bdf0521
Compare
type SelectCardProps = { | ||
children: React.ReactNode; | ||
className?: string; | ||
onChange: ( checked: boolean, value: string ) => void; | ||
selected: boolean; | ||
value: string; | ||
}; |
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.
Maybe we could consider moving the SelectCardProps
type definition out to client/landing/stepper/declarative-flow/internals/steps-repository/goals/types.ts
.
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.
Good question, this is a decision we would have to apply for all the next components. We could let only the data-related types or keep both UI and data types in the types.ts
. I tend to prefer the first approach, keeping the UI types close to the components since they are not used by other files. What do you think?
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 that makes sense to leave the types definition as it is now. 👍🏼
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.
Looks good to me! 👍
This Pull Request is now available for translation here: https://translate.wordpress.com/deliverables/7333479 Thank you @phcp for including a screenshot in the description! This is really helpful for our translators. |
Translation for this Pull Request has now been finished. |
Changes proposed in this Pull Request
This PR adds the SelectCard component. It uses the
CheckboxControl
from@wordpress/components
, overriding the checkboxID
to make it accessible with the children's text. The outer container is clickable, so the user can select a goal either by clicking on the check field or in any other area of theSelectCard
. TheSelectCard
doesn't have a width definition, so it fills the available width and the containers can define the width later.At first, I tried to use only the
CheckboxControl
changing the style in the outer container, but it has limitations on capturing click events. So I moved to the approach of handling the click actions directly in theSelectCard
component, that's why have to pass an empty function to the checkbox (it doesn't have an uncontrolled option). In summary, I'm using theCheckboxControl
only to display the checkbox layout, the same as in Figma Design System.This PR also updates the
stepContent
in the goals stepper for testing purposes.Testing instructions
3. Click in any area of the component to see if the selected state changes
Related to #63916