Skip to content

Migrate sanity-plugin-asset-source-unsplash styling to vanilla-extract - #1846

Open
stipsan wants to merge 1 commit into
mainfrom
cursor/migrate-unsplash-plugin-styling-to-vanilla-extract-81ce
Open

Migrate sanity-plugin-asset-source-unsplash styling to vanilla-extract#1846
stipsan wants to merge 1 commit into
mainfrom
cursor/migrate-unsplash-plugin-styling-to-vanilla-extract-81ce

Conversation

@stipsan

@stipsan stipsan commented Aug 6, 2026

Copy link
Copy Markdown
Member

What

Migrates sanity-plugin-asset-source-unsplash's styling from styled-components to vanilla-extract (zero-runtime CSS), following the migrate-styled-components-to-vanilla-extract skill's playbook.

Changes

  • SearchInput: the animated spinner icon (styled(SpinnerIcon) + keyframes) becomes a keyframes() + style() rule in SearchInput.css.ts, with a thin wrapper component keeping the same call site.
  • UnsplashAssetSource: the styled(Dialog) descendant-selector override (forcing the internal [data-ui='DialogCard'] > [data-ui='Card'] to height: 100%) becomes a globalStyle() scoped under a local wrapper class, since that structure is rendered internally by @sanity/ui's Dialog, not by this plugin.
  • UnsplashCreditLine: the link/card become style() + globalStyle() (for the hover/focus-driven Text underline, again targeting a @sanity/ui-rendered descendant), with the live theme's fg/bg colors bridged via createVar() + assignInlineVars() from useTheme_v2() (replacing the styled-components theme read via getTheme_v2({sanity: theme.sanity})).
  • tsdown.config.ts: styledComponents: truevanillaExtract: true.
  • vitest.config.ts: registers vanillaExtractPlugin() + disableRuntimeStyles.
  • package.json: adds the vanilla-extract build/runtime deps (@sanity/vanilla-extract-vite-plugin, @vanilla-extract/css as devDependencies; @vanilla-extract/dynamic as a runtime dependency), drops the styled-components peerDependency (kept as a catalog: devDependency, matching @sanity/google-maps-input/sanity-plugin-bynder-input, to keep the sanity/@sanity/ui peer resolution aligned with the rest of the workspace — verified in pnpm-lock.yaml).
  • Removes the now-unused styled-components DefaultTheme augmentation (src/typings.d.ts).
  • Adds a patch changeset.

Visual output and behavior are unchanged (verified against the pre-migration rendering — see Testing below).

Testing

  • pnpm format, pnpm lint, pnpm knip, pnpm build, pnpm test run all pass.
  • dist/bundle.css contains all migrated rules (keyframes/spinner animation, dialog height override, credit-line hover/underline + theme-driven colors).
  • Manually verified in the test studio (pnpm dev): opened the Unsplash asset source dialog, confirmed it renders at full height, the search input's spinner animates while a search is pending, and the "By @username" credit-line badge renders correctly (background pill, legible text) when hovering a photo. No console errors related to CSS/vanilla-extract/styled-components.

Unsplash dialog with photo grid and credit-line badges
Search input with animated spinner while a search is pending

Note: pnpm build/pnpm test run for the rest of the monorepo pass; dev/test-studio and dev/e2e-studio fail to build in this environment because pnpm install picked up a newer sanity/@sanity/vision prerelease off the workspace's next dist-tag override that isn't yet available on the auto-updates CDN. This is unrelated to this PR — reproducible on main as well once a fresh pnpm install picks up the same prerelease, given the pinned next tag drifts over time.

To show artifacts inline, enable in settings.

Open in Web Open in Cursor 

Migrates the plugin off styled-components onto vanilla-extract (zero-runtime
CSS), following the monorepo's styling migration playbook:

- SearchInput's animated spinner icon: keyframes() + style() wrapper
- UnsplashAssetSource's Dialog height override: globalStyle() scoped under a
  wrapper class (targets the Dialog's internal DialogCard/Card structure)
- UnsplashCreditLine's link/card: style() + globalStyle() for the
  hover/focus-driven Text underline, and createVar()/assignInlineVars() to
  bridge the live @sanity/ui theme's fg/bg colors (replacing the
  styled-components theme read via getTheme_v2)

Also:
- tsdown.config.ts: styledComponents -> vanillaExtract
- vitest.config.ts: register vanillaExtractPlugin() + disableRuntimeStyles
- package.json: add vanilla-extract build/runtime deps, drop the
  styled-components peerDependency (kept as a devDependency to keep the
  sanity/@sanity/ui peer variant aligned with the rest of the workspace)
- remove the now-unused styled-components DefaultTheme augmentation
@changeset-bot

changeset-bot Bot commented Aug 6, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 5033a15

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-asset-source-unsplash 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

@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 7:56am
1 Skipped Deployment
Project Deployment Actions Updated (UTC)
plugins-e2e-test-studio Ignored Ignored Aug 6, 2026 7:56am

Request Review

@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-cjc5d41dr.sanity.dev

Datasets: pr-1846-chromium-31082801377, pr-1846-firefox-31082801377

@socket-security

Copy link
Copy Markdown

@github-actions

github-actions Bot commented Aug 6, 2026

Copy link
Copy Markdown

Coverage Report

Status Category Percentage Covered / Total
🔵 Lines 31.99% 5505 / 17208
🔵 Statements 31.76% 5809 / 18287
🔵 Functions 27.77% 1427 / 5138
🔵 Branches 23.33% 2828 / 12118
File Coverage
File Stmts Branches Functions Lines Uncovered Lines
Changed Files
plugins/sanity-plugin-asset-source-unsplash/src/components/SearchInput.css.ts 0% 0% 0% 0%
plugins/sanity-plugin-asset-source-unsplash/src/components/SearchInput.tsx 0% 0% 0% 0% 9-33
plugins/sanity-plugin-asset-source-unsplash/src/components/UnsplashAssetSource.css.ts 0% 0% 0% 0%
plugins/sanity-plugin-asset-source-unsplash/src/components/UnsplashAssetSource.tsx 10.52% 0% 0% 11.11% 15, 18-68
Generated in workflow #8757 for commit 5033a15 by the Vitest Coverage Report Action

@stipsan
stipsan marked this pull request as ready for review August 6, 2026 08:44
@stipsan
stipsan requested a review from a team as a code owner August 6, 2026 08:44
@stipsan
stipsan requested review from Copilot and pedrobonamin and removed request for a team and Copilot August 6, 2026 08:44
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.

2 participants