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

Gutenboarding: Set design default fonts #40680

Merged
merged 4 commits into from
Apr 2, 2020

Conversation

sirreal
Copy link
Member

@sirreal sirreal commented Apr 1, 2020

Changes proposed in this Pull Request

  • Fix base font being set incorrectly (headings font was set to headings and base)
  • Use design default fonts
Before After
Defaults Screen Shot 2020-04-01 at 23 36 22 Screen Shot 2020-04-01 at 23 34 54
Selected font Screen Shot 2020-04-01 at 23 36 29 Screen Shot 2020-04-01 at 23 35 26

Testing instructions

  • Default and selected fonts are fixed on /gutenboarding style view

@sirreal sirreal requested a review from a team as a code owner April 1, 2020 21:33
@matticbot
Copy link
Contributor

@sirreal sirreal added [Goal] New Onboarding previously called Gutenboarding Design labels Apr 1, 2020
@sirreal sirreal self-assigned this Apr 1, 2020
@sirreal sirreal requested a review from a team April 1, 2020 21:41
Comment on lines +52 to +56
export type Font = ValuesType< ValuesType< typeof fontPairings > >;
export interface FontPair {
headings: Font;
base: Font;
}
Copy link
Member Author

Choose a reason for hiding this comment

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

Let known fonts appear in either position.

Copy link
Member

@alshakero alshakero Apr 2, 2020

Choose a reason for hiding this comment

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

Maybe these should be moved here? Then Design will have the correct fonts types, not array < string >. It's 100% up to you though.

@matticbot
Copy link
Contributor

matticbot commented Apr 1, 2020

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

App Entrypoints (~82 bytes removed 📉 [gzipped])

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

@simison simison added the [Status] Needs Review The PR is ready for review. This also triggers e2e canary tests and wp-desktop tests automatically. label Apr 2, 2020
Copy link
Member

@alshakero alshakero left a comment

Choose a reason for hiding this comment

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

Tested in Chrome. Reviewed the code. All good.

Comment on lines +52 to +56
export type Font = ValuesType< ValuesType< typeof fontPairings > >;
export interface FontPair {
headings: Font;
base: Font;
}
Copy link
Member

@alshakero alshakero Apr 2, 2020

Choose a reason for hiding this comment

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

Maybe these should be moved here? Then Design will have the correct fonts types, not array < string >. It's 100% up to you though.

// in the style preview. To match that expectation, we reset any previously user-selected fonts.
resetFonts();
// Update fonts to the design defaults
setFonts( design.fonts as [ Font, Font ] );
Copy link
Member

Choose a reason for hiding this comment

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

I think if Design was typed properly, the as .. won't be needed.

selectedFonts?.headings === selectedDesignDefaultFonts?.[ 0 ] &&
selectedFonts?.base === selectedDesignDefaultFonts?.[ 1 ],
} ) }
onClick={ () => setFonts( ( selectedDesignDefaultFonts as [ Font, Font ] ) ?? undefined ) }
Copy link
Member

Choose a reason for hiding this comment

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

Same as above

Better type safety
Remove type cases
@sirreal
Copy link
Member Author

sirreal commented Apr 2, 2020

I was planning to do some type cleanup after this, but it's better to get it in here rather than making a mess and cleaning it up later. Thanks for the nudge @alshakero 😉

We couldn't infer types well from the JSON: microsoft/TypeScript#32063

Type everything!
Remove type assertions!
✨ ✨ ✨ ✨ ✨

Things should be very coherent now. Fonts are {heading: Font, base: Font} 💥

Comment on lines +1 to +121
headings: 'Arvo',
base: 'Montserrat',
},
categories: [ 'event' ],
},
{
title: 'Reynolds',
slug: 'reynolds',
template: 'rockfield2',
theme: 'rockfield',
src: 'https://public-api.wordpress.com/rest/v1/template/demo/rockfield/rockfield2/',
fonts: {
headings: 'Playfair Display',
base: 'Fira Sans',
},
categories: [ 'featured', 'portfolio' ],
},
{
title: 'Easley',
slug: 'easley',
template: 'maywood',
theme: 'maywood',
src: 'https://public-api.wordpress.com/rest/v1/template/demo/maywood/maywood/',
fonts: {
headings: 'Space Mono',
base: 'Roboto',
},
categories: [ 'featured', 'portfolio' ],
},
{
title: 'Camden',
slug: 'Camden',
template: 'maywood2',
theme: 'maywood',
src: 'https://public-api.wordpress.com/rest/v1/template/demo/maywood/maywood2/',
fonts: {
headings: 'Space Mono',
base: 'Roboto',
},
categories: [ 'featured', 'portfolio' ],
},
{
title: 'Bowen',
slug: 'bowen',
template: 'bowen',
theme: 'coutoire',
src: 'https://public-api.wordpress.com/rest/v1/template/demo/coutoire/bowen/',
fonts: {
headings: 'Playfair Display',
base: 'Fira Sans',
},
categories: [ 'featured', 'blog' ],
},
{
title: 'Edison',
slug: 'edison',
template: 'stratford2',
theme: 'stratford',
src: 'https://public-api.wordpress.com/rest/v1/template/demo/stratford/stratford2/',
fonts: {
headings: 'Chivo',
base: 'Open Sans',
},
categories: [ 'featured', 'blog' ],
},
{
title: 'Cassel',
slug: 'cassel',
template: 'mayland',
theme: 'mayland',
src: 'https://public-api.wordpress.com/rest/v1/template/demo/mayland/mayland/',
fonts: {
headings: 'Playfair Display',
base: 'Fira Sans',
},
categories: [ 'featured', 'blog' ],
},
{
title: 'Overton',
slug: 'overton',
template: 'alves',
theme: 'alves',
src: 'https://public-api.wordpress.com/rest/v1/template/demo/alves/alves/',
fonts: {
headings: 'Cabin',
base: 'Raleway',
},
categories: [ 'featured', 'business' ],
},
{
title: 'Doyle',
slug: 'doyle',
template: 'alves2',
theme: 'alves',
src: 'https://public-api.wordpress.com/rest/v1/template/demo/alves/alves2/',
fonts: {
headings: 'Playfair Display',
base: 'Fira Sans',
},
categories: [ 'featured', 'business' ],
Copy link
Member

Choose a reason for hiding this comment

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

❤️ ❤️ ❤️ ❤️

Copy link
Member

@alshakero alshakero left a comment

Choose a reason for hiding this comment

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

LEGEND!

@sirreal sirreal added [Status] Ready to Merge and removed [Status] Needs Review The PR is ready for review. This also triggers e2e canary tests and wp-desktop tests automatically. labels Apr 2, 2020
@sirreal sirreal merged commit bdd2dd3 into master Apr 2, 2020
@sirreal sirreal deleted the gutenboarding/fix-default-fonts-in-preview branch April 2, 2020 11:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Design [Goal] New Onboarding previously called Gutenboarding
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants