Repository navigation
Componentry: Migrate Chip to @wordpress/ui Badge - #48162
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. |
Code Coverage SummaryThis PR did not change code coverage! That could be good or bad, depending on the situation. Everything covered before, and still is? Great! Nothing was covered before? Not so great. 🤷 |
07543f2 to
0a1db35
Compare
04317eb to
e06cc91
Compare
There was a problem hiding this comment.
Self-review (by agent orchestrator) after a dual-reviewer pass (Claude team + codex CLI). Inline comments below cover the must-fix items (changelog significance on a public-export removal; RadioControl rebase conflict) and one should-fix item (semantic intent).
Edit: live verification on a Jurassic Ninja site confirmed the Badge renders correctly on the Composing page (green pill, 8px gap). Dropped the prior design-tokens.css bundle concern — Badge's compiled CSS has hex fallbacks baked in, so tokens are non-blocking.
*left by Biff (executive assistant agent) on behalf of Darren
| { __( 'Learn more about all Jetpack AI features', 'jetpack' ) } | ||
| </a> | ||
| { /* TODO: remove this Badge once it's no longer "new" */ } | ||
| <Badge intent="stable">{ __( 'New', 'jetpack' ) }</Badge> |
There was a problem hiding this comment.
Semantic mismatch: intent="stable" means "healthy/unchanged" per @wordpress/ui types — chosen here because it paints green, not because it's semantically correct for a "New" label. informational (blue) or draft (neutral) are the semantically honest choices. Worth a design call rather than codifying the color-match.
*left by Biff (executive assistant agent) on behalf of Darren
There was a problem hiding this comment.
@ilonagl - what do you think about this agent review finding? I kinda agree, but semantics aside we probably still want to keep the green coloring for this purpose?
f503462 to
5b24e59
Compare
|
Small nit from a read-through — Pushed a tiny follow-up swapping |
Part of #48160. Replace the internal Jetpack `Chip` component (from `@automattic/jetpack-components`) with `Badge` from `@wordpress/ui` in the two consumers found in `plugins/jetpack` (`writing/composing.jsx` and `newsletter/email-settings.jsx`). Map the legacy `type="new"` to `intent="success"` — matches the existing green "new" styling. Delete the now-unused internal Chip component, its SCSS module, stories, README, and barrel export from `@automattic/jetpack-components`.
`intent="success"` is not a valid @wordpress/ui Badge intent (valid: high | medium | low | stable | informational | draft | none) and produces the missing CSS class `is-success-intent`, which leaves the badge unstyled. Switch to `stable`, which renders the green "positive" pill matching the previous Chip's green "new" styling and aligns with the mapping established in #48156.
- composing.jsx: wrap link + Badge in `@wordpress/ui` Stack with `gap="sm"` (8px design token) to restore the 8px margin the old Chip SCSS carried. - email-settings.jsx: drop the Chip entirely (no Badge replacement). This FormLegend is inside the legacy Newsletter settings tab which is slated for removal; no point wiring new UI into code on its way out.
…l new-badge - Recommendations: replace custom `jp-recommendations__new-badge` span in the three consumers (feature-summary index + resource, prompt-layout) with `@wordpress/ui` Badge (`intent="stable"`). Drop the pill-styling block from `recommendations/style.scss` and the scoped `margin-*: 1rem` descendant rules in feature-summary and prompt-layout stylesheets; replace them with `gap: 1rem` on the already-flex parents. - My Jetpack AI interstitial: drop the orphaned `.product-interstitial__new-badge` SCSS block. The JSX that used it was removed in the Write Brief (Breve) removal commit, leaving this CSS unused.
@automattic/jetpack-components is published to npm as a public package, so removing the Chip named export under Significance: patch would break downstream consumers pinned to ^1.8.x on a normal semver-compatible upgrade. Restore the original Chip implementation, README, and barrel export, and mark them @deprecated pointing at Badge from @wordpress/ui (mapping type="new" to intent="success"). Bump the changelog entry to Significance: minor / Type: deprecated to reflect the actual API change. The internal consumers in plugins/jetpack already migrated to Badge in the prior commits on this branch, so the deprecated Chip is unused inside the monorepo. Refs #48160.
…cation The Chip component's deprecation note, README, and changelog entry still pointed consumers at `intent="success"`, but `@wordpress/ui@0.11.0` Badge has no `success` intent. Valid values are high | medium | low | stable | informational | draft | none. The call-site code already uses `intent="stable"` after 3addf04; this sync'd the docs/JSDoc/changelog that migrators will actually read. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
b137407 to
5616bc5
Compare
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.
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.
…#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.
Part of #48160.
Proposed changes
Chip → Badge
Chipcomponent (from@automattic/jetpack-components) withBadgefrom@wordpress/ui._inc/client/writing/composing.jsx— "New" tag on the AI Assistant learn-more link. Wrapped in<Stack align="center" gap="sm">to restore the 8px horizontal gap the old Chip SCSS provided._inc/client/newsletter/email-settings.jsx— the old Chip is removed entirely with no Badge replacement. This FormLegend is inside the legacy Newsletter settings tab which is slated for removal (new dashboard atpage=jetpack-newslettervia@jetpack/newsletteris the default now viajetpack_wp_admin_newsletter_settings_enabled).type="new"prop tointent="stable"— matches the mapping established in Components: Migrate Badge to @wordpress/ui #48156 (success→stable) and renders the same green "positive" pill as the old.is-newchip.Chipcomponent, its SCSS module, stories, README, and barrel export from@automattic/jetpack-components.Custom "New"-pill migration (same semantic, sibling of Chip)
plugins/jetpackRecommendations — replace the custom.jp-recommendations__new-badgespan in the three consumers (feature-summary/index.jsx,feature-summary/resource.jsx,prompts/prompt-layout/index.jsx) with<Badge intent="stable">. Drop the pill-styling block fromrecommendations/style.scssand replace the.jp-recommendations__new-badge { margin-*: 1rem }descendant rules infeature-summary/style.scssandprompts/prompt-layout/style.scsswithgap: 1remon the (already-flex) parents.packages/my-jetpackAI product interstitial — drop the orphaned.product-interstitial__new-badgeSCSS block. The JSX that used it was removed in the Write Brief (Breve) removal commit, leaving this CSS unused.@wordpress/ui@0.11.0is already a dependency ofplugins/jetpack, no new dependency added.Related product discussion/links
Does this pull request change what data or activity we track or use?
No.
Screenshots
Captured on a live Jurassic Tube site at 1440×900 via the
jetpack-screenshotskill.Writing → Composing — "Learn more about all Jetpack AI features" New badge
Chip)@wordpress/uiBadge intent="stable"inStack gap="sm")Recommendations summary — feature-summary New badges
.jp-recommendations__new-badgespan)@wordpress/uiBadge intent="stable", parent flexgap: 1rem)Note
The Recommendations screenshots were taken with a temporary local patch that forced
isNewtotruein the three consumers (feature-summary/index.jsx,feature-summary/resource.jsx,prompts/prompt-layout/index.jsx) so the badge would render unconditionally. The patch was reverted before pushing — this branch ships only the realisNewgated behavior. In production, only features actually flagged as "new" in recommendations data will render the badge.Testing instructions
jp build plugins/jetpack.wp-admin/admin.php?page=jetpack#/writingon a site that has Jetpack connected.wp-admin/admin.php?page=jetpack#/recommendations, navigate to any step where a feature is flagged as new (requires specific server state). The New badge should render as a green pill adjacent to the feature display name or progress bar with ~1rem gap.Chipexport is removed from@automattic/jetpack-components; the.jp-recommendations__new-badgeand.product-interstitial__new-badgeCSS classes are removed.