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

Add @automattic/onboarding package to standardize stylesheets & reuse components. #44077

Merged
merged 16 commits into from
Jul 14, 2020

Conversation

yansern
Copy link
Contributor

@yansern yansern commented Jul 10, 2020

Changes proposed in this Pull Request

  1. Created @automattic/onboarding package.
    The intention of this package is to offer onboarding stylesheets & components that can be reused across Calypso, FSE & WP-Admin. Currently it has SCSS variables & mixins, <Title> and <Subtitle> component taken out from Gutenboarding.

  2. Expanded @automattic/typography with font family & font size variables.
    This is taken out from client/assets/stylesheets/shared/_typography.scss file so it can be used outside of Calypso.

  3. Clean up all the SCSS variables & mixins, <Title> & <Subtitle> duplication across the calypso codebase (within the scope of onboarding & typography). This includes:

    • Updating gutenboarding to use @automattic/onboarding.
    • Updating @automattic/domain-picker to use @automattic/onboarding.
    • Updating @automattic/plans-grid to use @automattic/onboarding.
    • Updating magic-login, wp-login & signup stylesheet to use mixins from @automattic/onboarding.
    • Updating wpcom-block-editor-nux plugin to import fonts & mixins from @automattic/typography &
      @automattic/onboarding.

There are a lot of files modified in this PR. However, they do very simple changes. To review this PR, it is easier to review by commits, as commits are grouped thematically. Most work revolves around importing, renaming variables and removing duplicated codes.

Usage Examples

For using onboarding/typography variables & mixins:

@import '~@automattic/onboarding/styles/variables';
@import '~@automattic/onboarding/styles/mixins';
@import '~@automattic/typography/styles/fonts';
@import '~@automattic/typography/styles/variables';

For using <Title> & <SubTitle> components:

@import { Title, SubTitle } from '@automattic/onboarding';

Testing instructions

  • Run yarn to rebuild all packages.
  • Run yarn start to boot up Calypso locally.
  • As long as there is no compilation errors, all variables & mixins have been imported successfully.
  • Test gutenboarding on /new, everything should look the same.
  • Look around Calypso, everything should look the same.

Note: Testing launch flow on FSE is on this PR #44087 which is based off this PR.

Fixes part of #43750

@yansern yansern added the [Goal] New Onboarding previously called Gutenboarding label Jul 10, 2020
@yansern yansern requested a review from a team as a code owner July 10, 2020 19:00
@yansern yansern self-assigned this Jul 10, 2020
@matticbot
Copy link
Contributor

@matticbot
Copy link
Contributor

matticbot commented Jul 10, 2020

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

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

name                 parsed_size           gzip_size
entry-gutenboarding        -12 B  (-0.0%)      +12 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.

@matticbot
Copy link
Contributor

Caution: This PR affects files in the FSE Plugin on WordPress.com
Please ensure your changes work on WordPress.com before merging.

D46237-code has been created so you can easily test it on your sandbox. See this FieldGuide page about developing in the FSE Plugin for more info: PCYsg-ly5-p2

@yansern yansern added the [Status] Needs Review The PR is ready for review. This also triggers e2e canary tests and wp-desktop tests automatically. label Jul 10, 2020
Comment on lines +4 to +5
$onboarding-header-height: $header-height;
$onboarding-footer-height: $header-height;
Copy link
Contributor Author

@yansern yansern Jul 10, 2020

Choose a reason for hiding this comment

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

Take note that this was originally hardcoded to 64px. This is now inherited directly from core WP which has a value of 60px. This ensures header height consistency from gutenboarding to block editor.

@@ -1,5 +1,5 @@
@import '../styles/placeholder.scss'; // Contains the placeholder mixin
@import '../styles/mixins';
@import '~@automattic/calypso-color-schemes';
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Need to beware not to import this multiple times as this creates styling duplication.

Copy link
Member

Choose a reason for hiding this comment

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

Hm! Wouldn't it now be included multiple times by importing this to Gutenboarding, which also includes this package? 🤔

Should it be declared it as peerDependencies?

Copy link
Contributor Author

@yansern yansern Jul 14, 2020

Choose a reason for hiding this comment

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

Wouldn't it now be included multiple times by importing this to Gutenboarding, which also includes this package?

I think this is happening right now. If you look at entry-gutenboarding.css file the :root selector where all the color declarations are repeated at least twice. Need to investigate how this is happening but not something to fix in this PR.

Should it be declared it as peerDependencies?

Not sure if sass-loader actually reads these things.

Comment on lines -1 to +3
@import '../base-styles.scss';
@import '../mixins.scss';
@import '../variables.scss';
@import '~@wordpress/base-styles/breakpoints';
@import '~@wordpress/base-styles/mixins';
@import '~@automattic/typography/styles/variables';
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is done to import only the specific files that has the specific variables & mixins needed instead of blindly importing everything. You'll see this in a few other files as well.

"main": "sass/fonts.scss",
"main": "styles/fonts.scss",
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 sass folder has been renamed to styles folder for consistency.

Copy link
Collaborator

@wp-desktop wp-desktop left a comment

Choose a reason for hiding this comment

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

WordPress Desktop CI Failure for job "wp-desktop-source".

@yansern please inspect this job's build steps for breaking changes at this link. For temporal failures, you may try to "Rerun Workflow from Failed".

Please also ensure this branch is rebased off latest Calypso.

@yansern yansern dismissed wp-desktop’s stale review July 13, 2020 04:24

Dependencies fixed.

Copy link
Collaborator

@wp-desktop wp-desktop left a comment

Choose a reason for hiding this comment

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

WordPress Desktop CI Failure for job "wp-desktop-source".

@yansern please inspect this job's build steps for breaking changes at this link. For temporal failures, you may try to "Rerun Workflow from Failed".

Please also ensure this branch is rebased off latest Calypso.

@nsakaimbo nsakaimbo self-requested a review July 13, 2020 14:19
Copy link
Contributor

@nsakaimbo nsakaimbo left a comment

Choose a reason for hiding this comment

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

@yansern 👋 Hello! The last run wp-desktop-source job was failinging with the error:

@automattic/onboarding: info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
lerna ERR! yarn run prepare exited 2 in '@automattic/onboarding'
lerna WARN complete Waiting for 7 child processes to exit. CTRL-C to exit immediately.
error Command failed with exit code 2.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
error Command failed with exit code 2.

The wp-desktop review would have automatically been dismissed once the job was re-ran and passed (looks like it was dismissed it manually, so it's unclear what the CI status was).

However for some reason this job is missing from the latest SHA for this PR - not sure why. Also - only 8 checks were performed (there's typically around 22-23 CI jobs that are ran against any given Calypso PR).

Can we make sure that the full suite of CI tests is reflected prior to getting this landed?

@razvanpapadopol
Copy link

razvanpapadopol commented Jul 13, 2020

There seems to be this error logged when Install dependencies step fail for wp-desktop-source:

@automattic/onboarding: src/action-buttons/index.tsx(7,25): error TS2307: Cannot find module '@automattic/react-i18n'.

only 8 checks were performed

Not sure why this would happen. Re-adding Needs Review tag in case this helps.

@razvanpapadopol razvanpapadopol added [Status] Needs Review The PR is ready for review. This also triggers e2e canary tests and wp-desktop tests automatically. and removed [Status] Needs Review The PR is ready for review. This also triggers e2e canary tests and wp-desktop tests automatically. labels Jul 13, 2020
@nsakaimbo
Copy link
Contributor

Perhaps a rebase might help kick-start things as well?

If it helps, you can now debug the wp-desktop build wholly from within Calypso by running yarn run build-desktop from Calypso root (the step that's failing is yarn run build-desktop:source (which attempts to install the dependencies). Let me know if you need any help trying to debug further.

@nsakaimbo
Copy link
Contributor

@automattic/onboarding: src/action-buttons/index.tsx(7,25): error TS2307: Cannot find module '@automattic/react-i18n'

It looks like this file was renamed as part of this PR? 🤔

@razvanpapadopol
Copy link

@automattic/onboarding: src/action-buttons/index.tsx(7,25): error TS2307: Cannot find module '@automattic/react-i18n'

It looks like this file was renamed as part of this PR? 🤔

Yes, it was extracted from /client to @automattic/onboarding package 🔎

@nsakaimbo
Copy link
Contributor

@razvanpapadopol The reason CI isn't running on this branch is that the root Calypso CI job ci/setup is failing (link) at the Install Dependencies step with the error:

@automattic/onboarding: src/action-buttons/index.tsx(7,25): error TS2307: Cannot find module '@automattic/react-i18n'.

@automattic/onboarding: error Command failed with exit code 2.
@automattic/onboarding: info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
lerna ERR! yarn run prepare exited 2 in '@automattic/onboarding'

So this error isn't specific to the wp-desktop-source job.

You can verify the Circle CI activity for this branch PR at this link.

@nsakaimbo
Copy link
Contributor

Update: looks like the last CI job that was attempted (and failed) was 12 hours ago. Seems Calypso CI hasn't been triggered at all since then.

Screen Shot 2020-07-13 at 11 36 17 AM

"classnames": "^2.2.6"
},
"devDependencies": {
"@wordpress/base-styles": "^1.8.0",
Copy link
Member

Choose a reason for hiding this comment

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

Needs @automattic/typography too?

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 catch! Added to onboarding & plans-grid package. d4633a6

Choose a reason for hiding this comment

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

Shouldn't this be added also to FSE deps? I see @wordpress/base-styles there

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

@wp-desktop wp-desktop dismissed their stale review July 14, 2020 07:25

wp-desktop ci passing, closing review

@yansern
Copy link
Contributor Author

yansern commented Jul 14, 2020

The wp-desktop review would have automatically been dismissed once the job was re-ran and passed (looks like it was dismissed it manually, so it's unclear what the CI status was).

Sorry, that was me. Wasn't sure why the desktop CI was relevant but later I saw that all tests were passing I dismissed it. Good to know that if it was really ALL tests were passing then it will be automatically dismissed.

Can we make sure that the full suite of CI tests is reflected prior to getting this landed?

Yup all good now with 67014.

@yansern yansern requested a review from nsakaimbo July 14, 2020 08:18
Copy link

@razvanpapadopol razvanpapadopol left a comment

Choose a reason for hiding this comment

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

Great work building a solid foundation for the reusable onboarding components! 💯

@yansern yansern merged commit a83f9ac into master Jul 14, 2020
@yansern yansern deleted the add/onboarding-package branch July 14, 2020 09:57
@matticbot matticbot removed the [Status] Needs Review The PR is ready for review. This also triggers e2e canary tests and wp-desktop tests automatically. label Jul 14, 2020
@deBhal deBhal mentioned this pull request Jul 20, 2020
31 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Goal] New Onboarding previously called Gutenboarding
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants