Skip to content

Conversation

@aduth
Copy link
Member

@aduth aduth commented Nov 3, 2025

What?

Closes #72931

Updates the object shape generated by the theme package to simplify how colors and warnings are referenced from a generated color ramp.

Follow-up to #72847

Why?

  • Reduce bundle size
  • Simplified code structure for easier understanding

How?

Rather than assigning each ramp value as an object of { color: string, warning: boolean }, optimistically assumes that colors will be generated without warnings and instead assigns the value as string, with warnings only assigned as a top-level object key if any exist.

Optionally, as mentioned by @jsnajdr in #72847 (comment), we could remove warning behavior altogether, as its primary purpose is for debugging. Personally I feel it might be valuable to keep for the short-term to protect against possible regressions in contrast matching, but this should serve as an incremental step in that direction, since it makes it easier to remove warning altogether in assuming that it's optional and likely excluded in most cases.

Testing Instructions

Validate no regressions in behavior of behavior of theme provider:

  1. Run npm run storybook:start
  2. Go to http://localhost:50240/?path=/docs/design-system-theme-provider--docs
  3. Observe that colors generate as expected

Verify that building theme package succeeds and produces no local changes:

  1. Run npm run --workspace @wordpress/theme build
  2. Observe successful run
  3. Run git status
  4. Observe clean working branch

@aduth aduth added [Type] Performance Related to performance efforts [Package] Theme /packages/theme labels Nov 3, 2025
@aduth aduth requested a review from jsnajdr November 3, 2025 19:45
@github-actions
Copy link

github-actions bot commented Nov 3, 2025

The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the props-bot label.

If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.

Co-authored-by: aduth <[email protected]>
Co-authored-by: jsnajdr <[email protected]>

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.

@aduth aduth requested a review from a team November 11, 2025 14:17
{ color: string; warning: boolean }
>;
const rampResults = {} as Record< keyof Ramp, string >;
let warnings: string[] | undefined;
Copy link
Member

Choose a reason for hiding this comment

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

warnings could always be an array, mostly empty. Adding the undefined option just forces users to do extra ?. checks.

Copy link
Member Author

Choose a reason for hiding this comment

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

The idea with making it undefined is that it could be excluded from serialized output, further reducing size (see default-ramps.ts). But it's a good point that this benefit is partially offset by having to do all the subsequent optional handling in the code.

Copy link
Member Author

Choose a reason for hiding this comment

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

I think I might keep this optional. I don't hold the opinion very strongly, but with the point of this pull request being to make the ramp objects more concise, this is an intentional and effective part of that.

@aduth aduth force-pushed the update/theme-flatten-warnings branch from ef280ab to 58eb055 Compare November 12, 2025 16:24
@github-actions
Copy link

Flaky tests detected in 58eb055.
Some tests passed with failed attempts. The failures may not be related to this commit but are still reported for visibility. See the documentation for more information.

🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/19304365111
📝 Reported issues:

@aduth aduth merged commit 6fcc181 into trunk Nov 12, 2025
34 of 35 checks passed
@aduth aduth deleted the update/theme-flatten-warnings branch November 12, 2025 18:26
@github-actions github-actions bot added this to the Gutenberg 22.2 milestone Nov 12, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

[Package] Theme /packages/theme [Type] Performance Related to performance efforts

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Theme: Condense object shape of color ramps

3 participants