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

Style engine: refine Box type #38894

Merged
merged 2 commits into from
Feb 21, 2022
Merged

Conversation

ciampo
Copy link
Contributor

@ciampo ciampo commented Feb 17, 2022

Description

Follow-up to this conversation, this PR proposes a more advanced type for Box which is closer to the actual values that Box is going to assume.

Testing Instructions

Screenshots

Types of changes

Enhancement

Checklist:

  • My code is tested.
  • My code follows the WordPress code style.
  • My code follows the accessibility standards.
  • I've tested my changes with keyboard and screen readers.
  • 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 (please manually search all *.native.js files for terms that need renaming or removal).
  • I've updated related schemas if appropriate.

@ciampo ciampo added [Type] Enhancement A suggestion for improvement. Global Styles Anything related to the broader Global Styles efforts, including Styles Engine and theme.json [Feature] Design Tools Tools that impact the appearance of blocks both to expand the number of tools and improve the experi labels Feb 17, 2022
@ciampo ciampo self-assigned this Feb 17, 2022
Copy link
Contributor

@andrewserong andrewserong left a comment

Choose a reason for hiding this comment

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

Oh, this is clever, thanks for the follow-up @ciampo! The other use case that we will have for the Box type that isn't covered yet is when we add in position support, where the lower case top, right, bottom, and left will be used directly. Is there a way to have those words be lowercase if BoxVariants is an empty string?

(For reference, here's an early WIP PR looking at adding in position support — it'll likely change a lot, but just for context as to why it was on my mind 😀)

@ciampo
Copy link
Contributor Author

ciampo commented Feb 18, 2022

You raise a good point!

I went ahead and allowed BoxVariant to be undefined — in that case, the CSS props used as types are going to be the lowercase variants.

I quickly tested it in my IDE and it seems to work as expected (note that top has a different computed type depending on the parent object being margin, padding or box):

box-variants-ts.mp4

Copy link
Contributor

@andrewserong andrewserong left a comment

Choose a reason for hiding this comment

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

Nice one, thanks @ciampo — that's looking good to me now, and confirmed that it's working the same in my IDE as it is in your screengrab 👍

Looks like there's a failing e2e unrelated to this PR, so it might need either a rebase or to kick off the tests again before you merge it in.

Thanks again for the follow-up!

@ciampo ciampo force-pushed the feat/style-engine-box-type-refinements branch from 7dd7818 to fa85133 Compare February 21, 2022 08:48
@ciampo ciampo merged commit 499fc36 into trunk Feb 21, 2022
@ciampo ciampo deleted the feat/style-engine-box-type-refinements branch February 21, 2022 09:48
@github-actions github-actions bot added this to the Gutenberg 12.7 milestone Feb 21, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Feature] Design Tools Tools that impact the appearance of blocks both to expand the number of tools and improve the experi Global Styles Anything related to the broader Global Styles efforts, including Styles Engine and theme.json [Type] Enhancement A suggestion for improvement.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants