-
Notifications
You must be signed in to change notification settings - Fork 4.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
Try: apply the new type scale #18244
Conversation
Sorry, I meant to add as a draft, and now I can't figure out how to convert it. |
* Type scale mixins | ||
*/ | ||
|
||
@mixin text-title-large { |
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 we prefix the mixins e.g. wp-text-title-large
to avoid potential namespace clashes?
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.
That seems ok to me, since there will probably be editor
specific font styles like editor-text-body
.
@@ -1090,18 +1090,16 @@ | |||
|
|||
.components-toolbar { | |||
border: none; | |||
line-height: 1; | |||
font-family: $default-font; |
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 font-family
be part of the mixin by default? The consumer can still override the font-family
if they have a valid reason to do so.
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.
Seems like we could get rid of font-family in the mixin.
$editor-font: "Noto Serif", serif; | ||
$editor-html-font: Menlo, Consolas, monaco, monospace; | ||
$editor-font-size: 16px; | ||
$default-block-margin: 28px; // This value provides a consistent, contiguous spacing between blocks (it's 2x $block-padding). | ||
$text-editor-font-size: 14px; | ||
$editor-line-height: 1.8; | ||
$big-font-size: 18px; | ||
$big-font-size: 16px; |
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.
Do these typography related variables still need to exist now that the mixins exist? Can they be removed or at least deprecated?
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.
The ones that are applied to the content of the post need to be kept separate and intact. The type scale shouldn't be applied in the content area because it represents the front end of the site, which is not in the scope of the type scale. For now, the type scale only applies to the application UI.
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.
🆒🆒
Why did it change as part of this PR?
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 think $big-font-size
may be used for the UI, but I'd have to check and see why I changed 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.
Looks like it's not used that much, but I think I changed it because of this class
.block-editor-inserter__menu-help-panel-title {
which is some sort of title in the inserter popover.
Since it's only used a couple times, it might be easier just to eliminate the need for $big-font-size
@@ -37,3 +37,11 @@ | |||
@import "./components/warning/style.scss"; | |||
@import "./components/writing-flow/style.scss"; | |||
@import "./hooks/anchor.scss"; | |||
|
|||
body { | |||
@include text-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.
@davewhitley Halloo!!! This PR looks great :).
The thing that stuck out to me was applying styles to the overall body
. For a plugin-like thing like Gutenberg, it feels strange that it would target something so broad outside of itself.
For example, when this is loaded in WP-Admin, I'm not sure what body p
may affect.
If we wanted to adjust "global" (in the context of Gutenberg) font styles, would we be able to target just Gutenberg?
Hope that makes sense!
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.
If we could specify Gutenberg only instead of body
that'd be great (there's probably a good way to do that). I imagine it would take a few months to change those global styles in WP Admin.
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.
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.
To apply things just to the editor, it looks like we have to update this file:
https://github.com/WordPress/gutenberg/blob/master/packages/edit-post/src/style.scss#L65
Adding the @include text-body-small
mixin there appeared to work 👍
// Utility classes | ||
|
||
.block-editor-page .text-caption { | ||
@include text-caption; |
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.
Might be a better way to do this. I had to add a class here:
@@ -26,7 +29,7 @@ | |||
} | |||
|
|||
&__shortcut-term { | |||
font-weight: 600; | |||
// @include text-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.
Forgot to delete this.
@davewhitley @jameslnewell I've been exploring how we might utilize this type scale in the native mobile version of Gutenberg, and overall I think it's going to work quite well. I have one main concern and that is letter-spacing. tl;dr my question is this: is it possible (or feasible, reasonable) to customize the letter-spacing based on which system font is used? The most-used ones (SF Pro and Roboto) have substantially different base character widths, and could thus benefit from fine-grain adjustments. On native mobile GB, my plan was to follow the same type sizes, weights, etc. as y'all are defining here (we'd simply @import the type scale, afaik), but letter-spacing would essentially follow native values, separately for iOS and Android. Here is my work-in-progress on mobile, closely following letter-spacing guidelines from Material Guidelines and HIG: I understand setting everything to zero simplifies things a bit, but being an advocate for native I can't help but feel the urge to honor these type of details (pun fully intended). 🙃 EDIT: I just realized a couple of labels are off in the diagram above, but I think you get the point 😄 |
Awesome!
With the component added in #18495 it will be easy to customise the |
@jameslnewell All good things to hear! Thanks for confirming 😄 |
What can we do to move this PR forward? |
Also wanted to circle back and see if there is anything we can do to move this forward. Would love to be able to include this type scale in my designs. |
#18495 (comment) has landed so you can start using the styles today. import { __experimentalText as Text } from '@wordpress/components';
export const MyComponent = () => (
<>
<Text variant="title.large" as="h1">Title Large</Text>
<Text variant="title.medium" as="h2">Title Medium</Text>
<Text variant="title.small" as="h3">Title Small</Text>
<Text variant="subtitle">Subtitle</Text>
<Text variant="subtitle.small">Subtitle Small</Text>
<Text variant="body">Body</Text>
<Text variant="body.small">Body Small</Text>
<Text variant="button">Button</Text>
<Text variant="caption">Caption</Text>
<Text variant="label">Label</Text>
</>
); There is still some work left to do in updating the existing components to use these styles. |
^^^ I accidentally mashed too many keyboard keys and closed the issue, but this PR probably can be closed now @davewhitley? |
@iamthomasbishop @melchoyce @LevinMedia 🙏 I'd love some design input on the subtle changes/impact that applying the scale makes over here: #18652 |
This PR is a little stale and could probably be closed unless you think it's still relevant? |
Description
This PR is an experiment to try and apply the new type scale, which is still a proposal at the moment.
Please note, I know there may be bugs, and there may be better ways to implement the type scale in code. This PR serves as a way to see the type scale in context. I did a few somewhat hacky things to override some styles.
Please give it a try and let me know what you think.
How has this been tested?
I have only visually tested the block editor.
Screenshots
Before/After gif https://make.wordpress.org/design/files/2019/10/comparison-editor.gif
Codepen of type scale https://codepen.io/drw158/pen/zbgEqO
After:
Types of changes
Visual changes:
Checklist: