Skip to content

Commit

Permalink
fix(alpha-ui): support for breaking changes inside studio with new sa…
Browse files Browse the repository at this point in the history
…nity/ui (#5015)
  • Loading branch information
pedrobonamin authored and robinpyon committed Nov 3, 2023
1 parent d36dc68 commit cc29f14
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
7 changes: 4 additions & 3 deletions packages/sanity/src/core/studio/Studio.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,9 @@ describe('Studio', () => {
const sheet = new ServerStyleSheet()
try {
const html = renderToStaticMarkup(sheet.collectStyles(<Studio config={config} />))

expect(html).toMatchInlineSnapshot(
`"<div data-as=\\"div\\" data-ui=\\"Flex\\" data-scheme=\\"light\\" data-tone=\\"default\\" class=\\"sc-pNWRh kHzIXK sc-hBMVwJ cxXFEA sc-pNWRh bjOKiY sc-crzpnZ hbdofD\\"><div data-ui=\\"Text\\" class=\\"sc-bdnyFh bQjgIG\\"><span>Loading…</span></div><div data-ui=\\"Spinner\\" class=\\"sc-bdnyFh bQjgIG sc-dItHI dqtoFF\\"><span><svg data-sanity-icon=\\"spinner\\" width=\\"1em\\" height=\\"1em\\" viewBox=\\"0 0 25 25\\" fill=\\"none\\" xmlns=\\"http://www.w3.org/2000/svg\\"><path d=\\"M4.5 12.5C4.5 16.9183 8.08172 20.5 12.5 20.5C16.9183 20.5 20.5 16.9183 20.5 12.5C20.5 8.08172 16.9183 4.5 12.5 4.5\\" stroke=\\"currentColor\\" stroke-width=\\"1.2\\" stroke-linejoin=\\"round\\"></path></svg></span></div></div>"`,
`"<div data-ui=\\"Flex\\" data-scheme=\\"light\\" data-tone=\\"default\\" class=\\"sc-jXbUNg bbOBvc sc-dLMFU bVnOTN sc-jXbUNg gwUwPO sc-jlZhew blWHRn\\"><div data-ui=\\"Text\\" class=\\"sc-aXZVg fsTqmC\\"><span>Loading…</span></div><div data-ui=\\"Spinner\\" class=\\"sc-aXZVg fsTqmC sc-cwHptR hNIzxo\\"><span><svg data-sanity-icon=\\"spinner\\" width=\\"1em\\" height=\\"1em\\" viewBox=\\"0 0 25 25\\" fill=\\"none\\" xmlns=\\"http://www.w3.org/2000/svg\\"><path d=\\"M4.5 12.5C4.5 16.9183 8.08172 20.5 12.5 20.5C16.9183 20.5 20.5 16.9183 20.5 12.5C20.5 8.08172 16.9183 4.5 12.5 4.5\\" stroke=\\"currentColor\\" stroke-width=\\"1.2\\" stroke-linejoin=\\"round\\"></path></svg></span></div></div>"`,
)
} finally {
sheet.seal()
Expand All @@ -61,7 +62,7 @@ describe('Studio', () => {
try {
const html = renderToString(sheet.collectStyles(<Studio config={config} />))
expect(html).toMatchInlineSnapshot(
`"<div data-as=\\"div\\" data-ui=\\"Flex\\" data-scheme=\\"light\\" data-tone=\\"default\\" class=\\"sc-pNWRh kHzIXK sc-hBMVwJ cxXFEA sc-pNWRh bjOKiY sc-crzpnZ hbdofD\\"><div data-ui=\\"Text\\" class=\\"sc-bdnyFh bQjgIG\\"><span>Loading…</span></div><div data-ui=\\"Spinner\\" class=\\"sc-bdnyFh bQjgIG sc-dItHI dqtoFF\\"><span><svg data-sanity-icon=\\"spinner\\" width=\\"1em\\" height=\\"1em\\" viewBox=\\"0 0 25 25\\" fill=\\"none\\" xmlns=\\"http://www.w3.org/2000/svg\\"><path d=\\"M4.5 12.5C4.5 16.9183 8.08172 20.5 12.5 20.5C16.9183 20.5 20.5 16.9183 20.5 12.5C20.5 8.08172 16.9183 4.5 12.5 4.5\\" stroke=\\"currentColor\\" stroke-width=\\"1.2\\" stroke-linejoin=\\"round\\"></path></svg></span></div></div>"`,
`"<div data-ui=\\"Flex\\" data-scheme=\\"light\\" data-tone=\\"default\\" class=\\"sc-jXbUNg bbOBvc sc-dLMFU bVnOTN sc-jXbUNg gwUwPO sc-jlZhew blWHRn\\"><div data-ui=\\"Text\\" class=\\"sc-aXZVg fsTqmC\\"><span>Loading…</span></div><div data-ui=\\"Spinner\\" class=\\"sc-aXZVg fsTqmC sc-cwHptR hNIzxo\\"><span><svg data-sanity-icon=\\"spinner\\" width=\\"1em\\" height=\\"1em\\" viewBox=\\"0 0 25 25\\" fill=\\"none\\" xmlns=\\"http://www.w3.org/2000/svg\\"><path d=\\"M4.5 12.5C4.5 16.9183 8.08172 20.5 12.5 20.5C16.9183 20.5 20.5 16.9183 20.5 12.5C20.5 8.08172 16.9183 4.5 12.5 4.5\\" stroke=\\"currentColor\\" stroke-width=\\"1.2\\" stroke-linejoin=\\"round\\"></path></svg></span></div></div>"`,
)
} finally {
sheet.seal()
Expand All @@ -81,7 +82,7 @@ describe('Studio', () => {
const html = renderToString(sheet.collectStyles(<Studio config={config} />))
node.innerHTML = html
expect(html).toMatchInlineSnapshot(
`"<div data-as=\\"div\\" data-ui=\\"Flex\\" data-scheme=\\"light\\" data-tone=\\"default\\" class=\\"sc-pNWRh kHzIXK sc-hBMVwJ cxXFEA sc-pNWRh bjOKiY sc-crzpnZ hbdofD\\"><div data-ui=\\"Text\\" class=\\"sc-bdnyFh bQjgIG\\"><span>Loading…</span></div><div data-ui=\\"Spinner\\" class=\\"sc-bdnyFh bQjgIG sc-dItHI dqtoFF\\"><span><svg data-sanity-icon=\\"spinner\\" width=\\"1em\\" height=\\"1em\\" viewBox=\\"0 0 25 25\\" fill=\\"none\\" xmlns=\\"http://www.w3.org/2000/svg\\"><path d=\\"M4.5 12.5C4.5 16.9183 8.08172 20.5 12.5 20.5C16.9183 20.5 20.5 16.9183 20.5 12.5C20.5 8.08172 16.9183 4.5 12.5 4.5\\" stroke=\\"currentColor\\" stroke-width=\\"1.2\\" stroke-linejoin=\\"round\\"></path></svg></span></div></div>"`,
`"<div data-ui=\\"Flex\\" data-scheme=\\"light\\" data-tone=\\"default\\" class=\\"sc-jXbUNg bbOBvc sc-dLMFU bVnOTN sc-jXbUNg gwUwPO sc-jlZhew blWHRn\\"><div data-ui=\\"Text\\" class=\\"sc-aXZVg fsTqmC\\"><span>Loading…</span></div><div data-ui=\\"Spinner\\" class=\\"sc-aXZVg fsTqmC sc-cwHptR hNIzxo\\"><span><svg data-sanity-icon=\\"spinner\\" width=\\"1em\\" height=\\"1em\\" viewBox=\\"0 0 25 25\\" fill=\\"none\\" xmlns=\\"http://www.w3.org/2000/svg\\"><path d=\\"M4.5 12.5C4.5 16.9183 8.08172 20.5 12.5 20.5C16.9183 20.5 20.5 16.9183 20.5 12.5C20.5 8.08172 16.9183 4.5 12.5 4.5\\" stroke=\\"currentColor\\" stroke-width=\\"1.2\\" stroke-linejoin=\\"round\\"></path></svg></span></div></div>"`,
)
document.head.innerHTML += sheet.getStyleTags()

Expand Down
3 changes: 2 additions & 1 deletion packages/sanity/src/core/theme/_legacy/theme.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<LegacyThemeProps>): StudioTheme {
return defaults
const legacyTheme = resolveLegacyTheme(partialLegacyTheme)
const legacyPalette = buildLegacyPalette(legacyTheme)
const legacyTones = buildLegacyTones(legacyPalette)
Expand Down

0 comments on commit cc29f14

Please sign in to comment.