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

Goals Capture: Add SelectCard component #64042

Merged
merged 2 commits into from
May 26, 2022
Merged

Goals Capture: Add SelectCard component #64042

merged 2 commits into from
May 26, 2022

Conversation

phcp
Copy link
Contributor

@phcp phcp commented May 25, 2022

Changes proposed in this Pull Request

This PR adds the SelectCard component. It uses the CheckboxControl from @wordpress/components, overriding the checkbox ID 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 the SelectCard. The SelectCard 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 the SelectCard 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 the CheckboxControl 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

  1. Go to the Goals Step url
  2. Verify if the SelectCard component appears

unselected

3. Click in any area of the component to see if the selected state changes

selected

Related to #63916

@github-actions
Copy link

github-actions bot commented May 25, 2022

@matticbot
Copy link
Contributor

matticbot commented May 25, 2022

Here is how your PR affects size of JS and CSS bundles shipped to the user's browser:

App Entrypoints (~176 bytes added 📈 [gzipped])

name           parsed_size           gzip_size
entry-stepper       +569 B  (+0.0%)     +176 B  (+0.0%)

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.
Gzip Size: Compressed size of the JS and CSS files. This much data needs to be downloaded over network.

Generated by performance advisor bot at iscalypsofastyet.com.

@phcp phcp force-pushed the add/select-card-component branch from 9f178e0 to 577f329 Compare May 25, 2022 20:51
Base automatically changed from add/goals-step-skeleton to trunk May 26, 2022 07:44
@yansern yansern linked an issue May 26, 2022 that may be closed by this pull request
@phcp phcp force-pushed the add/select-card-component branch from 577f329 to bdf0521 Compare May 26, 2022 10:40
@phcp phcp requested a review from a team May 26, 2022 10:48
@matticbot matticbot added the [Status] Needs Review The PR is ready for review. This also triggers e2e canary tests and wp-desktop tests automatically. label May 26, 2022
@phcp phcp marked this pull request as ready for review May 26, 2022 10:48
Comment on lines +6 to +12
type SelectCardProps = {
children: React.ReactNode;
className?: string;
onChange: ( checked: boolean, value: string ) => void;
selected: boolean;
value: string;
};
Copy link
Contributor

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.

Copy link
Contributor Author

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?

Copy link
Contributor

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. 👍🏼

@ivan-ottinger
Copy link
Contributor

SelectCard component works and looks as expected:

Markup on 2022-05-26 at 13:28:27

Copy link
Contributor

@mashikag mashikag left a 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! 👍

@mashikag mashikag added [Status] Needs Author Reply and removed [Status] Needs Review The PR is ready for review. This also triggers e2e canary tests and wp-desktop tests automatically. labels May 26, 2022
@phcp phcp merged commit b3f5424 into trunk May 26, 2022
@phcp phcp deleted the add/select-card-component branch May 26, 2022 13:12
@a8ci18n
Copy link

a8ci18n commented May 26, 2022

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.

@a8ci18n
Copy link

a8ci18n commented Jun 2, 2022

Translation for this Pull Request has now been finished.

@yansern yansern added the [Feature] Site Goals & Onboarding Paths The onboarding flows for all new sites. label Jun 21, 2022
@yansern yansern changed the title Add SelectCard component Goals Capture: Add SelectCard component Jun 21, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Feature] Site Goals & Onboarding Paths The onboarding flows for all new sites.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[UI] Build the SelectCard component
6 participants