From 2bcdf32d738e39bb04ad950b729b06edca2eaf73 Mon Sep 17 00:00:00 2001 From: Pedro Bonamin <46196328+pedrobonamin@users.noreply.github.com> Date: Thu, 19 Oct 2023 16:27:04 +0200 Subject: [PATCH] fix(alpha-ui): support for breaking changes inside studio with new sanity/ui (#5015) --- .../form/inputs/files/ImageInput/ImagePreview.styled.tsx | 8 +++++--- packages/sanity/src/core/studio/Studio.test.tsx | 7 ++++--- packages/sanity/src/core/theme/_legacy/theme.ts | 3 ++- 3 files changed, 11 insertions(+), 7 deletions(-) diff --git a/packages/sanity/src/core/form/inputs/files/ImageInput/ImagePreview.styled.tsx b/packages/sanity/src/core/form/inputs/files/ImageInput/ImagePreview.styled.tsx index a5b1ceac90b..c7d7cf3e5e2 100644 --- a/packages/sanity/src/core/form/inputs/files/ImageInput/ImagePreview.styled.tsx +++ b/packages/sanity/src/core/form/inputs/files/ImageInput/ImagePreview.styled.tsx @@ -1,4 +1,4 @@ -import {studioTheme, rgba, Card, Flex, CardTone, Spinner} from '@sanity/ui' +import {rgba, Card, Flex, CardTone, Spinner, Theme} from '@sanity/ui' import styled, {css} from 'styled-components' export const MAX_DEFAULT_HEIGHT = 30 @@ -34,12 +34,14 @@ export const SpinnerWrapper = styled(Spinner)` export const Overlay = styled(Flex)(({ tone, drag, + theme, }: { tone: Exclude drag: boolean + theme: Theme }) => { - const textColor = studioTheme.color.light[tone].card.enabled.fg - const backgroundColor = rgba(studioTheme.color.light[tone].card.enabled.bg, 0.8) + const textColor = theme.sanity.color.card.enabled.fg + const backgroundColor = rgba(theme.sanity.color.card.enabled.bg, 0.8) return css` position: absolute; diff --git a/packages/sanity/src/core/studio/Studio.test.tsx b/packages/sanity/src/core/studio/Studio.test.tsx index f4899522096..cc19e7adeee 100644 --- a/packages/sanity/src/core/studio/Studio.test.tsx +++ b/packages/sanity/src/core/studio/Studio.test.tsx @@ -43,8 +43,9 @@ describe('Studio', () => { const sheet = new ServerStyleSheet() try { const html = renderToStaticMarkup(sheet.collectStyles()) + expect(html).toMatchInlineSnapshot( - `"
Loading…
"`, + `"
Loading…
"`, ) } finally { sheet.seal() @@ -61,7 +62,7 @@ describe('Studio', () => { try { const html = renderToString(sheet.collectStyles()) expect(html).toMatchInlineSnapshot( - `"
Loading…
"`, + `"
Loading…
"`, ) } finally { sheet.seal() @@ -81,7 +82,7 @@ describe('Studio', () => { const html = renderToString(sheet.collectStyles()) node.innerHTML = html expect(html).toMatchInlineSnapshot( - `"
Loading…
"`, + `"
Loading…
"`, ) document.head.innerHTML += sheet.getStyleTags() diff --git a/packages/sanity/src/core/theme/_legacy/theme.ts b/packages/sanity/src/core/theme/_legacy/theme.ts index 18473eac0cd..549c01807b2 100644 --- a/packages/sanity/src/core/theme/_legacy/theme.ts +++ b/packages/sanity/src/core/theme/_legacy/theme.ts @@ -28,10 +28,11 @@ import {LegacyThemeProps} from './types' * ``` * * @param partialLegacyTheme - Properties to override the theme with. See {@link LegacyThemeProps} - * * @public + * @deprecated Use `@sanity/ui studioTheme` instead */ export function buildLegacyTheme(partialLegacyTheme: Partial): StudioTheme { + return defaults const legacyTheme = resolveLegacyTheme(partialLegacyTheme) const legacyPalette = buildLegacyPalette(legacyTheme) const legacyTones = buildLegacyTones(legacyPalette)