Skip to content

Commit

Permalink
fix: update types definition from StudioTheme to BaseTheme
Browse files Browse the repository at this point in the history
  • Loading branch information
pedrobonamin committed Jan 16, 2024
1 parent 8cd0b1d commit b69b133
Show file tree
Hide file tree
Showing 7 changed files with 20 additions and 19 deletions.
3 changes: 2 additions & 1 deletion apps/v1/components/Themer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import {
ThemeProvider,
ToastProvider,
} from '@sanity/ui'
import { BaseTheme } from '@sanity/ui/theme'
import Head from 'components/Head'
import { HeaderCard, useHeaderCard } from 'components/HeaderCard'
import HuesFields from 'components/HuesFields'
Expand Down Expand Up @@ -74,7 +75,7 @@ export default function Themer({
)

return {
createTheme: createTheme as (hues: Hues) => StudioTheme,
createTheme: createTheme as (hues: Hues) => BaseTheme,
initialHues: hues as Hues,
}
}, [preset.url])
Expand Down
2 changes: 1 addition & 1 deletion apps/v1/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
"@sanity/color": "^2.2.5",
"@sanity/icons": "^2.4.1",
"@sanity/ui": "^2.0.0",
"@sanity/vision": "^3.14.5",
"@sanity/vision": "^3.24.1",
"culori": "^3.2.0",
"history": "^5.3.0",
"json5": "^2.2.3",
Expand Down
4 changes: 2 additions & 2 deletions apps/v1/studios/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { createConfig } from 'sanity'
import { defineConfig } from 'sanity'

import { config as blog } from './blog'
import { config as movies } from './movies'

export const config = createConfig([movies, blog])
export const config = defineConfig([movies, blog])
6 changes: 3 additions & 3 deletions apps/v1/studios/movies/index.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { visionTool } from '@sanity/vision'
import { BiMoviePlay } from 'react-icons/bi'
import { createConfig } from 'sanity'
import { WorkspaceOptions } from 'sanity'
import { deskTool } from 'sanity/desk'
import { unsplashImageAsset } from 'sanity-plugin-asset-source-unsplash'
import { muxInput } from 'sanity-plugin-mux-input'
Expand All @@ -10,7 +10,7 @@ import { schemaTypes } from './schemas'
const projectId = process.env.NEXT_PUBLIC_SANITY_PROJECT_ID
const dataset = process.env.NEXT_PUBLIC_SANITY_MOVIES_DATASET

export const config = createConfig({
export const config: WorkspaceOptions = {
name: 'movies',
title: 'Movies',
basePath: '/movies',
Expand All @@ -26,4 +26,4 @@ export const config = createConfig({
schema: {
types: schemaTypes,
},
})
}
6 changes: 3 additions & 3 deletions apps/v1/utils/themeFromHues.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import type {
ThemeColorSchemes,
ThemeColorSpotKey,
} from '@sanity/ui'
import type { StudioTheme } from 'sanity'
import { BaseTheme } from '@sanity/ui/theme'
import type { PartialDeep } from 'type-fest'
import { applyHues } from 'utils/applyHues'
import {
Expand All @@ -27,7 +27,7 @@ interface Options {
hues: PartialDeep<Hues>
// if there's a color property on the studioTheme it will be overridden/ignored, thus we change the typing allowing it to be omitted
// but at the same time not _enforcing_ it to be omitted and create unnecessary TS errors for those passing `import {studioTheme} from '@sanity/ui'` directly
studioTheme: Omit<StudioTheme, 'color'> & { color?: unknown }
studioTheme: Omit<BaseTheme, 'color'> & { color?: unknown }
parseColor: (color: string) => RGB
rgbToHex: (rgb: RGB) => string
multiply: (bg: RGB, fg: RGB) => RGB
Expand Down Expand Up @@ -72,7 +72,7 @@ export function themeFromHues({
rgbToHex,
rgba,
createColorTheme,
}: Options): StudioTheme & {
}: Options): BaseTheme & {
__themer: true
/**
* This needs to be set as undefined, given it will be created internally by @sanity/ui
Expand Down
2 changes: 1 addition & 1 deletion examples/next-dynamic/themer.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ declare module 'https://themer.sanity.build/api/hues?*' {
critical: Hue
}
export const hues: Hues
type Theme = import('sanity').StudioTheme
type Theme = import('sanity').BaseTheme
export function createTheme(_hues: Hues): Theme
export const theme: Theme
}
16 changes: 8 additions & 8 deletions pnpm-lock.yaml

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

0 comments on commit b69b133

Please sign in to comment.