Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/netlify-widget-vanilla-extract.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"sanity-plugin-dashboard-widget-netlify": patch
---

Migrate styling from styled-components to vanilla-extract (zero-runtime CSS)
22 changes: 19 additions & 3 deletions plugins/sanity-plugin-dashboard-widget-netlify/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,25 @@
"types": "./dist/index.d.ts",
"exports": {
".": "./src/index.ts",
"./bundle.css": {
"types": "./dist/bundle-css.d.ts",
"browser": "./dist/bundle.css",
"style": "./dist/bundle.css",
"node": "./dist/bundle-css.js",
"default": "./dist/bundle-css.js"
},
"./package.json": "./package.json"
},
"publishConfig": {
"exports": {
".": "./dist/index.js",
"./bundle.css": {
"types": "./dist/bundle-css.d.ts",
"browser": "./dist/bundle.css",
"style": "./dist/bundle.css",
"node": "./dist/bundle-css.js",
"default": "./dist/bundle-css.js"
},
"./package.json": "./package.json"
}
},
Expand All @@ -40,14 +54,17 @@
"prepack": "turbo run build"
},
"dependencies": {
"@sanity/ui": "catalog:"
"@sanity/ui": "catalog:",
"clsx": "catalog:"
},
"devDependencies": {
"@sanity/dashboard": "workspace:*",
"@sanity/tsconfig": "catalog:",
"@sanity/tsdown-config": "catalog:",
"@sanity/vanilla-extract-vite-plugin": "catalog:",
"@types/react": "catalog:",
"@types/react-dom": "catalog:",
"@vanilla-extract/css": "catalog:",
"babel-plugin-react-compiler": "catalog:",
"react": "catalog:",
"react-dom": "catalog:",
Expand All @@ -59,8 +76,7 @@
"@sanity/dashboard": "workspace:^",
"react": "catalog:peer",
"react-dom": "catalog:peer",
"sanity": "catalog:peer",
"styled-components": "catalog:peer"
"sanity": "catalog:peer"
},
"engines": {
"node": ">=20.19 <22 || >=22.12"
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import {style} from '@vanilla-extract/css'

export const contentCard = style({
selectors: {
// Double specificity so this wins over Card/Box's own `min-height: 0`
// (styled-components used to win via CSSOM insertion order).
'&&': {
minHeight: 66,
},
},
})
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
import {DashboardWidgetContainer} from '@sanity/dashboard'
import {Button, Flex, Card, Text, Box} from '@sanity/ui'
import {styled} from 'styled-components'
import {clsx} from 'clsx/lite'
import type {ComponentProps} from 'react'

import {type NetlifyWidgetProps} from '../types'
import SiteList from './SiteList'

const ContentCard = styled(Card)`
min-height: 66px;
`
import {contentCard} from './NetlifyWidget.css'

function ContentCard({className, ...props}: ComponentProps<typeof Card>) {
return <Card {...props} className={clsx(contentCard, className)} />
}

export default function NetlifyWidget(props: NetlifyWidgetProps) {
const netlifySitesUrl = 'https://app.netlify.com/account/sites'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ test('package exports', {timeout: 30_000}, async () => {
".": {
"netlifyWidget": "function",
},
"./bundle.css": {},
}
`)
})
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@ import {defineConfig} from '@sanity/tsdown-config'
import type {UserConfig} from 'tsdown'

export default defineConfig({
styledComponents: true,
reactCompiler: true,
vanillaExtract: true,
}) satisfies Promise<UserConfig>
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
import {vanillaExtractPlugin} from '@sanity/vanilla-extract-vite-plugin'
import {defineConfig} from 'vitest/config'

export default defineConfig({
plugins: [vanillaExtractPlugin()],
test: {
setupFiles: ['@vanilla-extract/css/disableRuntimeStyles'],
server: {
deps: {
inline: ['vitest-package-exports'],
Expand Down
12 changes: 12 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions pnpm-workspace.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ catalog:
'@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
groq: ^6.9.0
jsdom: ^29.1.1
Expand Down
Loading