Componentry: migrate Status to @wordpress/ui Text in plugin consumers#48711
Conversation
|
Are you an Automattician? Please test your changes on all WordPress.com environments to help mitigate accidental explosions.
Interested in more tips and information?
|
|
Thank you for your PR! When contributing to Jetpack, we have a few suggestions that can help us test and review your patch:
This comment will be updated as you work on your PR and make changes. If you think that some of those checks are not needed for your PR, please explain why you think so. Thanks for cooperation 🤖 Follow this PR Review Process:
If you have questions about anything, reach out in #jetpack-developers for guidance! Jetpack plugin: The Jetpack plugin has different release cadences depending on the platform:
If you have any questions about the release process, please ask in the #jetpack-releases channel on Slack. Protect plugin: No scheduled milestone found for this plugin. If you have any questions about the release process, please ask in the #jetpack-releases channel on Slack. |
Code Coverage SummaryCoverage changed in 1 file.
|
| white-space: nowrap; | ||
|
|
||
| &.is-active { | ||
| color: var(--jp-green-50); |
There was a problem hiding this comment.
Colors should use design tokens, not the --jp-* variables
There was a problem hiding this comment.
Done in 361bcad — swapped the --jp-* vars in pro-status/style.module.scss for WPDS design tokens (--wpds-color-fg-content-success / -error / -warning / -info / -neutral-weak).
| label={ __( 'Standalone mode', 'jetpack' ) } | ||
| /> | ||
| style={ { | ||
| alignItems: 'center', |
There was a problem hiding this comment.
why are we using inlined styles if the component has a className? Style the class. Also, colors should use design token vars, not --jp-*
There was a problem hiding this comment.
Done in 361bcad — dropped the inline style={} block and moved the indicator + label styling under the existing .waf__standalone__mode selector in _inc/client/security/style.scss, using --wpds-color-fg-content-success for the color.
| } } | ||
| > | ||
| <span | ||
| style={ { |
There was a problem hiding this comment.
Same as above: inlined styles when we could have this on a css file
There was a problem hiding this comment.
Same fix in 361bcad — the indicator span is now styled via a new .waf__standalone__mode__indicator class added under .waf__standalone__mode in the existing global SCSS file.
…styles) - Replace all --jp-* color vars with --wpds-color-fg-content-* design tokens (success/error/warning/info/neutral-weak) in pro-status and protect heroes. - waf.jsx: drop the inline style blocks; move styling under the existing .waf__standalone__mode class in _inc/client/security/style.scss. - Protect heroes: extract a small AdminSectionHero.StatusIndicator helper co-located with the existing admin-section-hero module so the four consumers (storybook, firewall, scan, scan history) share one CSS source instead of duplicating inline style blocks. - Update the @deprecated JSDoc on the Status component to point at the new WPDS tokens so future consumers do not reintroduce --jp-*. Addresses review comments r3228168471, r3228177952, r3228180635 on PR #48711.
|
Colour regression fixed in Root cause (one line)
What landed
Each Verification on the live dev siteDevTools readings from each affected surface ( Protect → Scan ( Protect → Firewall ( Jetpack → Settings → Security ( i.e. on the legacy dashboard the token isn't defined, but the hex fallback paints correctly. I injected a DOM-level preview of all five status indicators onto the live Files changed in
|
a59feea to
b3192df
Compare
…styles) - Replace all --jp-* color vars with --wpds-color-fg-content-* design tokens (success/error/warning/info/neutral-weak) in pro-status and protect heroes. - waf.jsx: drop the inline style blocks; move styling under the existing .waf__standalone__mode class in _inc/client/security/style.scss. - Protect heroes: extract a small AdminSectionHero.StatusIndicator helper co-located with the existing admin-section-hero module so the four consumers (storybook, firewall, scan, scan history) share one CSS source instead of duplicating inline style blocks. - Update the @deprecated JSDoc on the Status component to point at the new WPDS tokens so future consumers do not reintroduce --jp-*. Addresses review comments r3228168471, r3228177952, r3228180635 on PR #48711.
Part of #48160. Replace the internal Jetpack Status component (from @automattic/jetpack-components) with inline JSX using Text from @wordpress/ui plus a small colour-coded indicator span in the six consumer sites in plugins/protect and plugins/jetpack: - protect: AdminSectionHero storybook, firewall hero, scan hero, scan history hero -- single Status sites, inline style blocks keep the same var(--jp-green-50|gray-50) colour vars, 0.666em indicator, font-weight 600, and line-height 1.666 as the wrapper SCSS. - jetpack: security/waf "Standalone mode" label -- inline style, preserves the waf__standalone__mode className. - jetpack: pro-status renders four different status states; co-locate a style.module.scss mirroring the wrapper's status colour map (is-active|inactive|error|action|initializing) so the four call sites stay terse. Also drop the dead text prop on the legacy rewind status site (the original wrapper only ever read "label") and fall back to the now-explicit default label per status. Annotate the Status source in js-packages/components with an @deprecated JSDoc block (mirroring the Chip -> Badge pattern from #48162) so external consumers see the guidance without breaking on upgrade. Implementation, styles, stories, and barrel export are otherwise unchanged.
…styles) - Replace all --jp-* color vars with --wpds-color-fg-content-* design tokens (success/error/warning/info/neutral-weak) in pro-status and protect heroes. - waf.jsx: drop the inline style blocks; move styling under the existing .waf__standalone__mode class in _inc/client/security/style.scss. - Protect heroes: extract a small AdminSectionHero.StatusIndicator helper co-located with the existing admin-section-hero module so the four consumers (storybook, firewall, scan, scan history) share one CSS source instead of duplicating inline style blocks. - Update the @deprecated JSDoc on the Status component to point at the new WPDS tokens so future consumers do not reintroduce --jp-*. Addresses review comments r3228168471, r3228177952, r3228180635 on PR #48711.
…okens + hex fallback) The previous commit switched to --wpds-color-fg-content-success / -error / -warning / -info, but those are the "ink" tokens used as text on tinted backgrounds in alerts/badges — they resolve to near-black hexes (e.g. success = #2900) and are visually indistinguishable from `color: inherit` for a small dot + label. The Status indicator is a standalone color-coded element on a plain admin-page background, so it needs the recognizable shade family — the *-weak tokens: success-weak = #8030 ≈ --jp-green-50 (#8710) error-weak = #cc1818 ≈ --jp-red-50 (#d63638) warning-weak = #926300 ≈ --jp-yellow-* (warm amber) info-weak = #006bd7 ≈ --jp-blue-* (link blue) neutral-weak = #707070 ≈ --jp-gray-50 (#646970) In addition, the legacy Jetpack settings dashboard (which hosts the WAF standalone-mode indicator and the Pro Status panel) does NOT load `@wordpress/theme/design-tokens.css` at all — so any --wpds-* variable resolves to empty/initial there, and the indicator falls back to `color: inherit`. Add a hex fallback inside each var(--wpds-…, #rrggbb) so the legacy dashboard renders the right shade without depending on the design-tokens stylesheet being enqueued. Verified in DevTools on the live dev site: - /wp-admin/admin.php?page=jetpack-protect#/scan → indicator color now rgb(0, 128, 48) (was rgb(0, 41, 0) near-black). - /wp-admin/admin.php?page=jetpack-protect#/firewall → same. - /wp-admin/admin.php?page=jetpack (legacy dashboard) → WPDS token resolves empty but the #8030 fallback paints correctly. Also update the @deprecated JSDoc on the Status component to point at the *-weak tokens and to mention the hex-fallback requirement.
b3192df to
181b147
Compare
The legacy _inc/ Jetpack settings dashboard's postcss pipeline runs
postcss-custom-properties with preserve: false, which inlines var(--foo)
at build time and strips :root { --foo: value } declarations from the
output. The pipeline only sees the calypso-color-schemes token source, so
any var(--wpds-*) in dashboard SCSS would fall back to whatever hex the
consumer hand-wrote in the var(...) second argument.
Extend the @csstools/postcss-global-data files list to include
@wordpress/theme/design-tokens.css. With both sources loaded, postcss
resolves var(--wpds-*) calls to the real WPDS token values at build time,
matching the long-standing precedent for @automattic/calypso-color-schemes.
This unblocks consumers (e.g. PR #48711) from using raw var(--wpds-*) in
legacy dashboard SCSS without having to manually mirror every token value
into a hex fallback. Hex fallbacks remain valid as defensive coding for
surfaces that may not have run through this postcss pipeline.
Add @wordpress/theme as a direct dependency so the require.resolve call
works deterministically regardless of pnpm hoisting changes (it was
previously only transitive via @wordpress/ui).
…#48711) * Componentry: migrate Status to @wordpress/ui Text in plugin consumers Part of #48160. Replace the internal Jetpack Status component (from @automattic/jetpack-components) with inline JSX using Text from @wordpress/ui plus a small colour-coded indicator span in the six consumer sites in plugins/protect and plugins/jetpack: - protect: AdminSectionHero storybook, firewall hero, scan hero, scan history hero -- single Status sites, inline style blocks keep the same var(--jp-green-50|gray-50) colour vars, 0.666em indicator, font-weight 600, and line-height 1.666 as the wrapper SCSS. - jetpack: security/waf "Standalone mode" label -- inline style, preserves the waf__standalone__mode className. - jetpack: pro-status renders four different status states; co-locate a style.module.scss mirroring the wrapper's status colour map (is-active|inactive|error|action|initializing) so the four call sites stay terse. Also drop the dead text prop on the legacy rewind status site (the original wrapper only ever read "label") and fall back to the now-explicit default label per status. Annotate the Status source in js-packages/components with an @deprecated JSDoc block (mirroring the Chip -> Badge pattern from #48162) so external consumers see the guidance without breaking on upgrade. Implementation, styles, stories, and barrel export are otherwise unchanged. * Componentry: address review - design tokens + CSS classes (no inline styles) - Replace all --jp-* color vars with --wpds-color-fg-content-* design tokens (success/error/warning/info/neutral-weak) in pro-status and protect heroes. - waf.jsx: drop the inline style blocks; move styling under the existing .waf__standalone__mode class in _inc/client/security/style.scss. - Protect heroes: extract a small AdminSectionHero.StatusIndicator helper co-located with the existing admin-section-hero module so the four consumers (storybook, firewall, scan, scan history) share one CSS source instead of duplicating inline style blocks. - Update the @deprecated JSDoc on the Status component to point at the new WPDS tokens so future consumers do not reintroduce --jp-*. Addresses review comments r3228168471, r3228177952, r3228180635 on PR #48711. * Componentry: fix Status indicator color regression (use *-weak WPDS tokens + hex fallback) The previous commit switched to --wpds-color-fg-content-success / -error / -warning / -info, but those are the "ink" tokens used as text on tinted backgrounds in alerts/badges — they resolve to near-black hexes (e.g. success = #2900) and are visually indistinguishable from `color: inherit` for a small dot + label. The Status indicator is a standalone color-coded element on a plain admin-page background, so it needs the recognizable shade family — the *-weak tokens: success-weak = #8030 ≈ --jp-green-50 (#8710) error-weak = #cc1818 ≈ --jp-red-50 (#d63638) warning-weak = #926300 ≈ --jp-yellow-* (warm amber) info-weak = #006bd7 ≈ --jp-blue-* (link blue) neutral-weak = #707070 ≈ --jp-gray-50 (#646970) In addition, the legacy Jetpack settings dashboard (which hosts the WAF standalone-mode indicator and the Pro Status panel) does NOT load `@wordpress/theme/design-tokens.css` at all — so any --wpds-* variable resolves to empty/initial there, and the indicator falls back to `color: inherit`. Add a hex fallback inside each var(--wpds-…, #rrggbb) so the legacy dashboard renders the right shade without depending on the design-tokens stylesheet being enqueued. Verified in DevTools on the live dev site: - /wp-admin/admin.php?page=jetpack-protect#/scan → indicator color now rgb(0, 128, 48) (was rgb(0, 41, 0) near-black). - /wp-admin/admin.php?page=jetpack-protect#/firewall → same. - /wp-admin/admin.php?page=jetpack (legacy dashboard) → WPDS token resolves empty but the #8030 fallback paints correctly. Also update the @deprecated JSDoc on the Status component to point at the *-weak tokens and to mention the hex-fallback requirement.
The legacy _inc/ Jetpack settings dashboard's postcss pipeline runs
postcss-custom-properties with preserve: false, which inlines var(--foo)
at build time and strips :root { --foo: value } declarations from the
output. The pipeline only sees the calypso-color-schemes token source, so
any var(--wpds-*) in dashboard SCSS would fall back to whatever hex the
consumer hand-wrote in the var(...) second argument.
Extend the @csstools/postcss-global-data files list to include
@wordpress/theme/design-tokens.css. With both sources loaded, postcss
resolves var(--wpds-*) calls to the real WPDS token values at build time,
matching the long-standing precedent for @automattic/calypso-color-schemes.
This unblocks consumers (e.g. PR #48711) from using raw var(--wpds-*) in
legacy dashboard SCSS without having to manually mirror every token value
into a hex fallback. Hex fallbacks remain valid as defensive coding for
surfaces that may not have run through this postcss pipeline.
Add @wordpress/theme as a direct dependency so the require.resolve call
works deterministically regardless of pnpm hoisting changes (it was
previously only transitive via @wordpress/ui).
Part of #48160.
Proposed changes
Replace the internal Jetpack
Statuscomponent (from@automattic/jetpack-components) with inline JSX usingTextfrom@wordpress/uiplus a small colour-coded indicator span across all six in-repo consumer sites inplugins/protectandplugins/jetpack. Mark theStatussource injs-packages/componentsas@deprecated(JSDoc-only, no API change) following the chip → badge precedent from #48162.plugins/protect:AdminSectionHerostorybook, firewall admin-section-hero, scan admin-section-hero, scan history admin-section-hero — single Status sites. Now share anAdminSectionHero.StatusIndicatorhelper backed bystyles.module.scssso the four call sites stay terse.plugins/jetpack:_inc/client/security/waf.jsx"Standalone mode" label. Styling lives under the existing.waf__standalone__modeclass in_inc/client/security/style.scss(no inlinestyleblocks).plugins/jetpack:_inc/client/pro-status/index.jsxrenders four different status states (active,error,action,initializing); co-locate astyle.module.scssmirroring the wrapper's status colour map (is-active | is-inactive | is-error | is-action | is-initializing) so the four call sites stay terse. Also drops the deadtextprop on the legacy rewind status site (the originalStatuswrapper only ever readlabel, nevertext, so the prop was already being ignored — same strings reach the DOM via the now-explicitDEFAULT_LABELSmap).js-packages/components:Statuskeeps the same implementation, styles, stories, and barrel export; only adds an@deprecatedJSDoc block pointing at the inline replacement pattern so external npm consumers see the guidance without breaking on a patch upgrade.Colour tokens — design-system migration
This PR no longer uses
--jp-*colour vars. Indicators now reference WPDS design tokens with a hex fallback for surfaces that don't enqueue@wordpress/theme/design-tokens.css:active--wpds-color-fg-content-success-weak#008030error--wpds-color-fg-content-error-weak#cc1818action--wpds-color-fg-content-warning-weak#926300initializing--wpds-color-fg-content-info-weak#006bd7inactive--wpds-color-fg-content-neutral-weak#707070The
*-weakfamily is the recognizable shade (matches the old--jp-green-50/--jp-red-50/--jp-gray-50palette); the base--wpds-color-fg-content-*tokens are near-black "ink" colours intended for text on tinted alert/badge backgrounds — wrong choice for a standalone dot + label, and they were what made the indicators look colourless on the previous push (commit361bcad). The fallback hex covers the legacy Jetpack settings dashboard, which does not load@wordpress/theme/design-tokens.css. See follow-up comment for the verification on the live dev site.Acceptance:
grep -rn "from '@automattic/jetpack-components'" projects/plugins/protect/ projects/plugins/jetpack/ | grep '\\bStatus\\b'returns zero matches.pnpm jetpack build plugins/protect,pnpm jetpack build plugins/jetpack,pnpm jetpack build js-packages/componentsall green.rgb(0, 128, 48)from the token) and the legacy Jetpack settings dashboard (rgb(0, 128, 48)from the hex fallback).Related product discussion/links
@deprecatedJSDoc on a jetpack-components export: Componentry: Migrate Chip to @wordpress/ui Badge #48162 (Chip → Badge)@wordpress/uiTextadoption: Publicize: migrate all Button consumers to @wordpress/ui #48150, Charts: Replace __experimentalText with @wordpress/ui Text #47894, My Jetpack: render interstitials with unified header (breadcrumbs-like back-link + license-key action) #48414, My Jetpack: migrate interstitial Buttons to @wordpress/ui #48489Does this pull request change what data or activity we track or use?
No.
Testing instructions
waf['standalone_mode']in WAF settings), the "● Standalone mode" green indicator should render in the section header, identical to trunk.Plugins/Protect/AdminSectionHero— the green "● Active" indicator at the top of the hero should still look the same.Screenshots
Visual parity check across the six Status consumer surfaces. Indicators paint identically — same recognizable green / red / amber / blue / grey, same dot size, same line-height. On modern Protect routes the colour resolves from the WPDS token; on the legacy Jetpack dashboard the
#008030hex fallback paints (the token is absent there).Notes on the legacy-dashboard captures:
waf.jsxshort-circuits to a redirect-banner branch and<QueryWafSettings />never mounts; the REST short-circuit returnsstandalone_mode: truebut isn't fetched. The "after" image is the rendered DOM with the indicator HTML re-injected at.waf__headerso the PR's CSS path (.waf__standalone__mode/__indicator) is exercised exactly as the production render emits it.! isOfflineMode; the dev site is in Offline Mode (URL classed as local-dev). The "after" image is a multi-state DOM-injected demo at the Security section of the dashboard so all four status colour mappings can be eyeballed in one shot.Verification that the hex fallback resolves correctly on the legacy dashboard (all five status colours rendered via the same CSS path, WPDS token absent on
:root— thevar(--wpds-…, #hex)fallback paints):