Skip to content

Migrate sanity-plugin-mux-input styling to vanilla-extract - #1848

Open
stipsan wants to merge 1 commit into
mainfrom
cursor/migrate-mux-input-vanilla-extract-d55a
Open

Migrate sanity-plugin-mux-input styling to vanilla-extract#1848
stipsan wants to merge 1 commit into
mainfrom
cursor/migrate-mux-input-vanilla-extract-d55a

Conversation

@stipsan

@stipsan stipsan commented Aug 6, 2026

Copy link
Copy Markdown
Member

What

Migrates sanity-plugin-mux-input's styling from styled-components (legacy) to vanilla-extract, following the migrate-styled-components-to-vanilla-extract skill's procedure.

Every styled-components usage in the plugin is converted to a colocated .css.ts file, preserving visual fidelity:

  • Static stylesstyle() rules, wrapped in a thin component layer where callers need the same import/JSX API (PlayButton, TopControls, CardWrapper/FlexWrapper/LeftSection/CodeWrapper in UploadProgress, StyledDialog in InputBrowser, FileButton, RangeInput/WatermarkOverlay in DraggableWatermark).
  • Theme-dependent styles (withFocusRing, FileButton, VideoReferences's Container) now read useTheme_v2() and bridge the runtime values through createVar() + assignInlineVars() instead of interpolating props.theme in a styled template.
  • Descendant / third-party DOM selectors (Checkbox's internal input, Dialog's internal DialogCard/Card, MenuItem's internal input, the watermark range input's vendor-prefixed thumb pseudo-elements) use globalStyle() scoped to a wrapper class.
  • The position: static !important override on ImportVideosFromMux's checkbox now uses the && specificity trick instead of !important.
  • A dead/invalid h2 { font-size: [object Object] } rule in the old VideoReferences Container (interpolating a theme font-size object directly into CSS, which is invalid CSS and was silently dropped by the browser) is removed — it never had a rendering effect and there are no h2 elements in the subtree.

Config / dependency changes

  • tsdown.config.ts: styledComponents: truevanillaExtract: true (auto-wires the ./bundle.css export).
  • vitest.config.ts: registers vanillaExtractPlugin() and disableRuntimeStyles in setupFiles.
  • package.json: drops the styled-components peer + devDependency (verified in pnpm-lock.yaml that @sanity/ui still resolves to a single shared styled-components@6.4.4 instance across the monorepo — no fork); adds @vanilla-extract/css + @sanity/vanilla-extract-vite-plugin (devDependencies), @vanilla-extract/dynamic (runtime dependency), and clsx (for merging className per the styling skill's encapsulation pattern).
  • Removed src/sanity-ui.d.ts (the styled-components DefaultTheme augmentation is no longer needed).
  • Added a patch changeset.

Testing

  • pnpm format, pnpm lint, pnpm knip, pnpm build, pnpm test run all pass for the whole monorepo (only unrelated test-studio#build deploy step fails, due to a pre-existing prerelease-Sanity-version/auto-updates-CDN issue unrelated to this change).
  • Updated the plugin's package-exports inline snapshot for the new ./bundle.css export.
  • Manually verified in the running test studio (pnpm dev) that: the upload card renders with its focus ring intact, the "Select video" browse dialog is full height with the hover play-button overlay working, and the "Configure API" dialog shows the Mux logo inline before "API Credentials".

Upload card with dashed border and Upload/Select buttons
Select video browse dialog, full height, with white play button overlay on thumbnail hover
Configure API dialog with the Mux logo inline before the API Credentials title

To show artifacts inline, enable in settings.

Open in Web Open in Cursor 

…illa-extract

Converts every styled-components usage in the plugin (withFocusRing HOC,
VideoThumbnail, VideoInBrowser, InputBrowser, ImportVideosFromMux,
FileInputMenuItem, FileInputButton, DraggableWatermark, ConfigureApi,
PlayerActionsMenu, Player, UploadProgress, Uploader, VideoReferences) to
colocated .css.ts files using vanilla-extract, preserving visual fidelity:

- Static styles become style() rules, wrapped in thin component layers
  where callers need the same API.
- Theme-dependent styles (withFocusRing, FileButton, VideoReferences) read
  useTheme_v2() and bridge values through createVar()/assignInlineVars().
- Descendant/third-party selectors use globalStyle() scoped to a wrapper
  class; the position:static override in ImportVideosFromMux uses the &&
  specificity trick instead of !important.
- Switches tsdown.config.ts to vanillaExtract, registers the Vite plugin
  in vitest.config.ts, and updates package.json dependencies (drops the
  styled-components peer/devDependency, adds @vanilla-extract/css,
  @vanilla-extract/dynamic, @sanity/vanilla-extract-vite-plugin, clsx).
- Removes the now-unused styled-components DefaultTheme augmentation.
@changeset-bot

changeset-bot Bot commented Aug 6, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 7bf49e3

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-mux-input 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 8:20am

Request Review

@github-actions

github-actions Bot commented Aug 6, 2026

Copy link
Copy Markdown

✅ E2E Tests

🟢 25 passed🟡 1 flakyview full reportview run

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

Datasets: pr-1848-chromium-31084429254, pr-1848-firefox-31084429254

@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.92% 5490 / 17197
🔵 Statements 31.7% 5794 / 18276
🔵 Functions 27.76% 1427 / 5140
🔵 Branches 23.33% 2828 / 12118
File Coverage
File Stmts Branches Functions Lines Uncovered Lines
Changed Files
plugins/sanity-plugin-mux-input/src/components/ConfigureApi.css.ts 0% 0% 0% 0%
plugins/sanity-plugin-mux-input/src/components/ConfigureApi.styled.tsx 50% 100% 0% 50% 6-11
plugins/sanity-plugin-mux-input/src/components/DraggableWatermark.css.ts 0% 0% 0% 0%
plugins/sanity-plugin-mux-input/src/components/DraggableWatermark.tsx 0% 0% 0% 0% 24-810
plugins/sanity-plugin-mux-input/src/components/FileInputButton.css.ts 0% 0% 0% 0%
plugins/sanity-plugin-mux-input/src/components/FileInputButton.tsx 11.11% 0% 0% 12.5% 11-41
plugins/sanity-plugin-mux-input/src/components/FileInputMenuItem.css.ts 0% 0% 0% 0%
plugins/sanity-plugin-mux-input/src/components/FileInputMenuItem.styled.tsx 0% 100% 0% 0% 11-28
plugins/sanity-plugin-mux-input/src/components/ImportVideosFromMux.css.ts 0% 0% 0% 0%
plugins/sanity-plugin-mux-input/src/components/ImportVideosFromMux.tsx 0% 0% 0% 0% 37-325
plugins/sanity-plugin-mux-input/src/components/InputBrowser.css.ts 0% 0% 0% 0%
plugins/sanity-plugin-mux-input/src/components/InputBrowser.tsx 0% 100% 0% 0% 11-38
plugins/sanity-plugin-mux-input/src/components/Player.css.ts 0% 0% 0% 0%
plugins/sanity-plugin-mux-input/src/components/Player.styled.tsx 0% 100% 0% 0% 7
plugins/sanity-plugin-mux-input/src/components/PlayerActionsMenu.css.ts 0% 0% 0% 0%
plugins/sanity-plugin-mux-input/src/components/PlayerActionsMenu.tsx 3.57% 0% 0% 3.84% 39-175
plugins/sanity-plugin-mux-input/src/components/UploadProgress.css.ts 0% 0% 0% 0%
plugins/sanity-plugin-mux-input/src/components/UploadProgress.tsx 14.28% 0% 0% 14.28% 11-23, 39-70
plugins/sanity-plugin-mux-input/src/components/Uploader.css.ts 0% 0% 0% 0%
plugins/sanity-plugin-mux-input/src/components/Uploader.styled.tsx 11.11% 0% 0% 11.11% 29-60
plugins/sanity-plugin-mux-input/src/components/VideoInBrowser.css.ts 0% 0% 0% 0%
plugins/sanity-plugin-mux-input/src/components/VideoInBrowser.tsx 0% 0% 0% 0% 31-128
plugins/sanity-plugin-mux-input/src/components/VideoThumbnail.css.ts 0% 0% 0% 0%
plugins/sanity-plugin-mux-input/src/components/VideoThumbnail.tsx 4.54% 0% 0% 4.76% 32-123
plugins/sanity-plugin-mux-input/src/components/VideoDetails/VideoReferences.css.ts 0% 0% 0% 0%
plugins/sanity-plugin-mux-input/src/components/VideoDetails/VideoReferences.tsx 8.33% 0% 0% 8.33% 14-21, 29-60
plugins/sanity-plugin-mux-input/src/components/withFocusRing/withFocusRing.css.ts 0% 0% 0% 0%
plugins/sanity-plugin-mux-input/src/components/withFocusRing/withFocusRing.tsx 33.33% 0% 50% 33.33% 16-39
Generated in workflow #8766 for commit 7bf49e3 by the Vitest Coverage Report Action

@stipsan
stipsan marked this pull request as ready for review August 6, 2026 08:42
@stipsan
stipsan requested review from a team as code owners August 6, 2026 08:42
@stipsan
stipsan requested review from Copilot and pedrobonamin and removed request for a team August 6, 2026 08:42

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-mux-input from legacy styled-components styling to zero-runtime vanilla-extract, including theme-aware dynamic styling via useTheme_v2() + createVar()/assignInlineVars(), and wires the plugin’s ./bundle.css export + test/build tooling accordingly.

Changes:

  • Replaces styled-components usage across the plugin with colocated .css.ts files (plus small wrapper components to preserve JSX APIs).
  • Updates build/test configuration to support vanilla-extract (tsdown.config.ts, vitest.config.ts) and adds the ./bundle.css export + snapshot update.
  • Removes styled-components peer/dev dependency and adds vanilla-extract + helper deps, plus a changeset.

Reviewed changes

Copilot reviewed 34 out of 36 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
pnpm-lock.yaml Lockfile updates reflecting dependency graph changes (vanilla-extract deps added; other next resolutions updated).
plugins/sanity-plugin-mux-input/vitest.config.ts Registers vanillaExtractPlugin() and disables runtime styles in tests.
plugins/sanity-plugin-mux-input/tsdown.config.ts Enables vanillaExtract: true for CSS bundling/export wiring.
plugins/sanity-plugin-mux-input/test/exports.test.ts Updates exports snapshot to include ./bundle.css.
plugins/sanity-plugin-mux-input/src/sanity-ui.d.ts Removes styled-components theme augmentation (no longer needed).
plugins/sanity-plugin-mux-input/src/components/withFocusRing/withFocusRing.tsx Reimplements focus-ring styling using vanilla-extract vars + inline var assignment.
plugins/sanity-plugin-mux-input/src/components/withFocusRing/withFocusRing.ts Removes the prior styled-components implementation.
plugins/sanity-plugin-mux-input/src/components/withFocusRing/withFocusRing.css.ts Adds vanilla-extract styles/vars backing the focus ring behavior.
plugins/sanity-plugin-mux-input/src/components/VideoThumbnail.tsx Replaces styled <img> with a class-backed <img>.
plugins/sanity-plugin-mux-input/src/components/VideoThumbnail.css.ts Adds vanilla-extract styles for the thumbnail image.
plugins/sanity-plugin-mux-input/src/components/VideoInBrowser.tsx Replaces styled play button with class-backed <button>.
plugins/sanity-plugin-mux-input/src/components/VideoInBrowser.css.ts Adds vanilla-extract styles for play-button overlay/hover behavior.
plugins/sanity-plugin-mux-input/src/components/VideoDetails/VideoReferences.tsx Replaces styled container with a wrapper component + theme-driven vars.
plugins/sanity-plugin-mux-input/src/components/VideoDetails/VideoReferences.css.ts Adds vanilla-extract global styles scoped to the container.
plugins/sanity-plugin-mux-input/src/components/UploadProgress.tsx Replaces styled wrappers with small wrapper components that attach classes.
plugins/sanity-plugin-mux-input/src/components/UploadProgress.css.ts Adds vanilla-extract styles + a scoped code descendant rule.
plugins/sanity-plugin-mux-input/src/components/Uploader.styled.tsx Removes styled-components hidden input; uses a vanilla-extract class instead.
plugins/sanity-plugin-mux-input/src/components/Uploader.css.ts Adds vanilla-extract styling for the hidden input element.
plugins/sanity-plugin-mux-input/src/components/PlayerActionsMenu.tsx Replaces styled lock UI elements with class-backed Card/Button.
plugins/sanity-plugin-mux-input/src/components/PlayerActionsMenu.css.ts Adds vanilla-extract styles for lock UI positioning/appearance.
plugins/sanity-plugin-mux-input/src/components/Player.styled.tsx Replaces styled TopControls with a class-backed component.
plugins/sanity-plugin-mux-input/src/components/Player.css.ts Adds vanilla-extract styles for TopControls + scoped button rule.
plugins/sanity-plugin-mux-input/src/components/InputBrowser.tsx Replaces styled dialog wrapper with a class-backed wrapper component.
plugins/sanity-plugin-mux-input/src/components/InputBrowser.css.ts Adds vanilla-extract globalStyle to force full-height dialog layout.
plugins/sanity-plugin-mux-input/src/components/ImportVideosFromMux.tsx Replaces styled checkbox override with a vanilla-extract class.
plugins/sanity-plugin-mux-input/src/components/ImportVideosFromMux.css.ts Adds vanilla-extract styles/globalStyle for checkbox positioning + overlay.
plugins/sanity-plugin-mux-input/src/components/FileInputMenuItem.styled.tsx Replaces styled MenuItem focus styling with theme vars + class styles.
plugins/sanity-plugin-mux-input/src/components/FileInputMenuItem.css.ts Adds vanilla-extract focus/descendant input styles.
plugins/sanity-plugin-mux-input/src/components/FileInputButton.tsx Replaces styled label/input with class-backed DOM elements.
plugins/sanity-plugin-mux-input/src/components/FileInputButton.css.ts Adds vanilla-extract styles for the hidden input + label wrapper.
plugins/sanity-plugin-mux-input/src/components/DraggableWatermark.tsx Replaces styled range/overlay with class-backed elements and css.ts styling.
plugins/sanity-plugin-mux-input/src/components/DraggableWatermark.css.ts Adds vanilla-extract styles for the range input and overlay (incl. thumb styling).
plugins/sanity-plugin-mux-input/src/components/ConfigureApi.styled.tsx Replaces styled logo wrapper with a class-backed <span>.
plugins/sanity-plugin-mux-input/src/components/ConfigureApi.css.ts Adds vanilla-extract styles for the logo wrapper.
plugins/sanity-plugin-mux-input/package.json Adds ./bundle.css export, removes styled-components peer/devDep, adds vanilla-extract deps and clsx.
.changeset/mux-input-vanilla-extract.md Adds a patch changeset for the plugin migration.
Files not reviewed (1)
  • pnpm-lock.yaml: Generated file

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

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 7bf49e3. Configure here.

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.

3 participants