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

Block Support: Add font style and weight options with combined UI #26444

Open

Conversation

@aaronrobertshaw
Copy link

@aaronrobertshaw aaronrobertshaw commented Oct 26, 2020

Description

After feedback and discussion around adding block support for font styles ( #26050 ), it was decided to add support for both font styles and font weights, then combine the UI controls for them.

Changes Included

  • Adds block support for font styles and font weights
  • Allows for preset font style/weight options and uses CSS variables
  • Updates navigation block to opt-in to font style support for easier testing

How has this been tested?

Manually tested using navigation block.

Test Instructions

  1. Add a navigation block to a post and select it.
  2. You should see a new "Appearance" option under the Inspector Controls > Typography section.
  3. Select various font style/weight options and confirm the block updates visually as you'd expect.
  4. Selecting a non-default option, inspect the block in dev tools and confirm that the block includes appropriate inline styles using var() and CSS variables relating to the selection made.
  5. Save the post and view on the frontend.
  6. The same font style and weight choices should be reflected on the frontend block's inline styles.

Screenshots

CombinedFontStyleWeightOptions

Types of changes

Enhancement

Next Steps

  • Update tests in class-block-supported-styles-test.php if needed after approach confirmed.

Checklist:

  • My code is tested.
  • My code follows the WordPress code style.
  • My code follows the accessibility standards.
  • My code has proper inline documentation.
  • I've included developer documentation if appropriate.
  • I've updated all React Native files affected by any refactorings/renamings in this PR.
@aaronrobertshaw
Copy link
Author

@aaronrobertshaw aaronrobertshaw commented Oct 26, 2020

@jasmussen Hope you don't mind I started a fresh PR for this. When you get the chance can you take a look at the new control combining font style and weight options?

I'm not sure if it needs separators between the groups of weight/style combos. Also, should it be 100% width or do you see it potentially fitting in alongside other options?

Screen Shot 2020-10-26 at 5 47 23 pmScreen Shot 2020-10-26 at 5 47 30 pm

@jasmussen
Copy link
Contributor

@jasmussen jasmussen commented Oct 26, 2020

Nice. This is what I see:

weight

The names are all-caps, due to this rule it appears:

Screenshot 2020-10-26 at 10 32 37

It seems that rule was intended for menu subheadings, but is a little wide-reaching. Suffice to say, the fonts should not be all-caps, and should be the usual $gray-900 font color. I also think "Heavy Italic" is more readable than "Heavy - Italic", so no need for the dash.

Other than that, this is working well, and feels obvious. 👍 👍

@aaronrobertshaw
Copy link
Author

@aaronrobertshaw aaronrobertshaw commented Oct 27, 2020

I've updated the control's styling so the items:

  • are not all caps
  • use the $gray-900 color
  • do not include the hyphen in the label

Thanks for all the feedback. I think this is getting close now 🙂

Adds both font style and font weight block support options. The UI for both are combined into a single dropdown. The inline styles generated via this feature leverage CSS variables.
@aaronrobertshaw aaronrobertshaw force-pushed the aaronrobertshaw:add/font-weight-style-block-support branch from ca28824 to 66805f0 Oct 30, 2020
@aaronrobertshaw
Copy link
Author

@aaronrobertshaw aaronrobertshaw commented Oct 30, 2020

I've rebased this to pull in the latest changes in approach to registering/applying block support. I think this just needs a review now to move forward.

@jasmussen
Copy link
Contributor

@jasmussen jasmussen commented Oct 30, 2020

This is cool:

Screenshot 2020-10-30 at 08 57 56

I think you should sync up with @karmatosed per the opportunity outlined in #26572 (comment), it looks like you're both touching the same files, and the color, font size, all caps styles that are currently inherited, probably shouldn't be inherited at all.

@aaronrobertshaw
Copy link
Author

@aaronrobertshaw aaronrobertshaw commented Oct 30, 2020

I'm glad you're happy so far with the combined weight/style dropdown.

I think you should sync up with karmatosed per the opportunity outlined in #26572 (comment), it looks like you're both touching the same files, and the color, font size, all caps styles that are currently inherited, probably shouldn't be inherited at all.

Agreed. Those styles appear to be applied when they shouldn't be. I was hoping to be able to take a look at where they are actually used and tweak the CSS accordingly. I will probably do that via a separate PR though.

@jasmussen
Copy link
Contributor

@jasmussen jasmussen commented Oct 30, 2020

By the way, can you add a separator between the regular and italic weights? It's not super necessary but would be nice.

@aaronrobertshaw
Copy link
Author

@aaronrobertshaw aaronrobertshaw commented Oct 30, 2020

By the way, can you add a separator between the regular and italic weights? It's not super necessary but would be nice.

I initially thought it could do with a separator in there as well although I didn't find an obvious option to do that. Now, it's been brought up, I'll take another look at it next week.

My main issue was making sure that I wasn't adding another option that users could interact with or would impede accessibility. If anyone has any suggestions for doing this with a CustomSelectControl they'd be much appreciated 🙂

@jasmussen
Copy link
Contributor

@jasmussen jasmussen commented Oct 30, 2020

The separator should not block this PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

2 participants
You can’t perform that action at this time.