Skip to content

fix(dashboard-widget-netlify): migrate styled-components to vanilla-extract - #1842

Open
stipsan wants to merge 5 commits into
mainfrom
cursor/netlify-widget-vanilla-extract-d8ff
Open

fix(dashboard-widget-netlify): migrate styled-components to vanilla-extract#1842
stipsan wants to merge 5 commits into
mainfrom
cursor/netlify-widget-vanilla-extract-d8ff

Conversation

@stipsan

@stipsan stipsan commented Aug 6, 2026

Copy link
Copy Markdown
Member

Summary

Migrates sanity-plugin-dashboard-widget-netlify styling from styled-components to vanilla-extract (zero-runtime CSS), following the monorepo migration skill.

Changes

  • Replaced the single styled(Card) ContentCard wrapper with a colocated NetlifyWidget.css.ts rule and a thin ContentCard component that preserves the same call-site API
  • Merge className with clsx/lite (added clsx to the pnpm catalog)
  • Used the && specificity selector so min-height: 66px wins over @sanity/ui Card/Box defaults (styled-components previously won via CSSOM insertion order)
  • Switched tsdown.config.ts from styledComponents: true to vanillaExtract: true (emits dist/bundle.css and wires the ./bundle.css export)
  • Registered @sanity/vanilla-extract-vite-plugin in vitest.config.ts (with disableRuntimeStyles)
  • Removed the styled-components peer dependency; kept the catalog: devDependency for @sanity/ui peer-variant alignment
  • Added a patch changeset

Verification

  • dist/bundle.css emits .kd2ym90.kd2ym90{min-height:66px}
  • dist/index.js imports sanity-plugin-dashboard-widget-netlify/bundle.css and uses clsx from clsx/lite
  • Package-exports snapshot updated with ./bundle.css
  • Manual studio check: ContentCard has computed min-height: 66px
  • pnpm format / pnpm lint / pnpm knip / CI-style turbo build --filter='!./dev/*' / pnpm test run (211 files) all pass

Netlify widget rendered
Computed min-height 66px after && specificity fix

Test plan

  • Open the Netlify dashboard widget in the test studio and confirm layout/min-height matches pre-migration
  • Confirm light/dark themes still look correct
  • CI: lint, knip, build, test

To show artifacts inline, enable in settings.

Open in Web Open in Cursor 

…xtract

Replace the ContentCard styled(Card) wrapper with a colocated .css.ts
rule and thin component layer, enable the tsdown/vitest vanilla-extract
integration, and drop the styled-components peer.
@vercel

vercel Bot commented Aug 6, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
plugins-studio Ready Ready Preview Aug 6, 2026 8:49am
1 Skipped Deployment
Project Deployment Actions Updated (UTC)
plugins-e2e-test-studio Ignored Ignored Aug 6, 2026 8:49am

Request Review

@changeset-bot

changeset-bot Bot commented Aug 6, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: f77ed45

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
sanity-plugin-dashboard-widget-netlify Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@github-actions

github-actions Bot commented Aug 6, 2026

Copy link
Copy Markdown

✅ E2E Tests

🟢 26 passedview full reportview run

Studio: https://plugins-e2e-test-studio-3l2e3qfpu.sanity.dev

Datasets: pr-1842-chromium-31086386563, pr-1842-firefox-31086386563

@github-actions

github-actions Bot commented Aug 6, 2026

Copy link
Copy Markdown

Coverage Report

Status Category Percentage Covered / Total
🔵 Lines 32% 5507 / 17209
🔵 Statements 31.77% 5811 / 18288
🔵 Functions 27.77% 1427 / 5137
🔵 Branches 23.33% 2828 / 12118
File Coverage
File Stmts Branches Functions Lines Uncovered Lines
Changed Files
plugins/sanity-plugin-dashboard-widget-netlify/src/components/NetlifyWidget.css.ts 0% 0% 0% 0%
plugins/sanity-plugin-dashboard-widget-netlify/src/components/NetlifyWidget.tsx 0% 0% 0% 0% 12-48
Generated in workflow #8779 for commit f77ed45 by the Vitest Coverage Report Action

Use the vanilla-extract && selector so min-height: 66px wins over
@sanity/ui Card/Box defaults (styled-components previously won via
CSSOM insertion order).
@stipsan
stipsan marked this pull request as ready for review August 6, 2026 08:41
@stipsan
stipsan requested a review from a team as a code owner August 6, 2026 08:41
@stipsan
stipsan requested review from Copilot and pedrobonamin and removed request for a team August 6, 2026 08:41
…lite

Prefer clsx/lite over a template literal when merging the vanilla-extract
class with a caller-provided className. Add clsx to the pnpm catalog.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Migrates sanity-plugin-dashboard-widget-netlify off styled-components to vanilla-extract, aligning the plugin with the monorepo’s zero-runtime CSS approach and adding the required build/test wiring for bundle.css.

Changes:

  • Replaced the styled(Card) wrapper with a vanilla-extract style (NetlifyWidget.css.ts) and a thin ContentCard component wrapper.
  • Updated build + test tooling to support vanilla-extract (tsdown.config.ts, vitest.config.ts) and added ./bundle.css package exports.
  • Added a patch changeset for the plugin release.

Reviewed changes

Copilot reviewed 8 out of 9 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
pnpm-lock.yaml Updates lockfile for new vanilla-extract deps, but also bumps sanity: next resolutions repo-wide.
plugins/sanity-plugin-dashboard-widget-netlify/vitest.config.ts Registers vanillaExtractPlugin() and disables runtime style injection in tests.
plugins/sanity-plugin-dashboard-widget-netlify/tsdown.config.ts Switches tsdown from styledComponents to vanillaExtract output (bundle.css pipeline).
plugins/sanity-plugin-dashboard-widget-netlify/src/index.test.ts Updates package-exports snapshot to include ./bundle.css.
plugins/sanity-plugin-dashboard-widget-netlify/src/components/NetlifyWidget.tsx Replaces styled-components wrapper with a ContentCard component applying a vanilla-extract class.
plugins/sanity-plugin-dashboard-widget-netlify/src/components/NetlifyWidget.css.ts Introduces contentCard style with && specificity and minHeight: 66.
plugins/sanity-plugin-dashboard-widget-netlify/package.json Adds ./bundle.css export mapping and adds vanilla-extract-related devDependencies; removes styled-components peer.
.changeset/netlify-widget-vanilla-extract.md Adds patch changeset describing the migration.
Files not reviewed (1)
  • pnpm-lock.yaml: Generated file

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread pnpm-lock.yaml Outdated
Copilot AI review requested due to automatic review settings August 6, 2026 08:44
Keep the lockfile on sanity@6.9.1-next.6 (same as main) and only add
the clsx catalog entry plus this widget's vanilla-extract deps.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 8 out of 9 changed files in this pull request and generated no new comments.

Files not reviewed (1)
  • pnpm-lock.yaml: Generated file
Suppressed comments (2)

pnpm-lock.yaml:2120

  • The lockfile update pulls in a newer sanity prerelease (6.9.1-next.9) for this importer (and the diff shows the same bump across many importers). That expands the PR scope beyond the Netlify widget styling migration and adds review/upgrade risk.

If this wasn’t intentional, consider regenerating the lockfile in a way that only adds the new deps required for the migration (clsx / vanilla-extract tooling) while keeping the existing sanity@next resolution consistent with main, or split the dependency upgrade into a separate PR.
pnpm-workspace.yaml:53

  • clsx was added to the shared pnpm catalog, but it appears to only be used by sanity-plugin-dashboard-widget-netlify in this PR. Per the repo guidance, the catalog is meant for dependencies shared by 2+ packages; one-off deps are usually kept as an explicit version range in the consuming package to avoid growing the global catalog unnecessarily.
  '@vis.gl/react-google-maps': ^1.9.0
  '@vitest/coverage-v8': ^4.1.10
  babel-plugin-react-compiler: ^1.0.0
  clsx: ^2.1.1
  date-fns: ^4.4.0

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 8 out of 9 changed files in this pull request and generated no new comments.

Files not reviewed (1)
  • pnpm-lock.yaml: Generated file

@pedrobonamin pedrobonamin left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Looks good!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants