1- import {
2- BoundaryElementProvider ,
3- Flex ,
4- PortalProvider ,
5- ThemeColorSchemeKey ,
6- ToastProvider ,
7- useMediaIndex ,
8- } from '@sanity/ui'
1+ import { Flex , useMediaIndex } from '@sanity/ui'
2+ import type { ColorScheme } from '@sanity/ui/theme'
93import { debounce } from 'lodash'
104import { isEqual } from 'lodash'
115import { memo , useCallback , useEffect , useMemo , useRef , useState } from 'react'
@@ -27,13 +21,13 @@ import {workshopReducer} from './workshopReducer'
2721export interface WorkshopProps {
2822 config : WorkshopConfig
2923 locationStore : WorkshopLocationStore
30- onSchemeChange : ( nextScheme : ThemeColorSchemeKey ) => void
31- scheme ?: ThemeColorSchemeKey
24+ onSchemeChange : ( nextScheme : ColorScheme ) => void
25+ scheme ?: ColorScheme
3226}
3327
3428function getStateFromLocation (
3529 loc : Omit < WorkshopLocation , 'type' > ,
36- schemeProp ?: ThemeColorSchemeKey ,
30+ schemeProp ?: ColorScheme ,
3731 frameReady ?: boolean ,
3832) : WorkshopState {
3933 const path = loc . path
@@ -44,7 +38,7 @@ function getStateFromLocation(
4438 frameReady : frameReady || false ,
4539 path,
4640 payload,
47- scheme : schemeProp || ( typeof scheme === 'string' ? ( scheme as ThemeColorSchemeKey ) : 'light' ) ,
41+ scheme : schemeProp || ( typeof scheme === 'string' ? ( scheme as ColorScheme ) : 'light' ) ,
4842 viewport : typeof viewport === 'string' ? viewport : 'auto' ,
4943 zoom : typeof zoom === 'number' ? zoom : 1 ,
5044 }
@@ -86,8 +80,6 @@ export const Workshop = memo(function Workshop(props: WorkshopProps): React.Reac
8680 const withNavbar = config . features ?. navbar ?? true
8781 const channel = useMemo ( ( ) => createPubsub < WorkshopMsg > ( ) , [ ] )
8882 const frame = useMemo ( ( ) => createWorkshopFrameController ( ) , [ ] )
89- const [ boundaryElement , setBoundaryElement ] = useState < HTMLDivElement | null > ( null )
90- const [ portalElement , setPortalElement ] = useState < HTMLDivElement | null > ( null )
9183 const [ { frameReady, path, payload, scheme, viewport, zoom} , setState ] = useState < WorkshopState > (
9284 ( ) => getStateFromLocation ( locationStore . get ( ) , schemeProp ) ,
9385 )
@@ -243,39 +235,25 @@ export const Workshop = memo(function Workshop(props: WorkshopProps): React.Reac
243235 viewport = { viewport }
244236 zoom = { zoom }
245237 >
246- < ToastProvider >
247- < BoundaryElementProvider element = { boundaryElement } >
248- < PortalProvider element = { portalElement } >
249- < Flex
250- data-boundary = ""
251- direction = "column"
252- height = "fill"
253- ref = { setBoundaryElement }
254- style = { { minWidth : 320 } }
255- >
256- { withNavbar && (
257- < WorkshopNavbar
258- inspectorExpanded = { inspectorExpanded }
259- navigatorExpanded = { navigatorExpanded }
260- onInspectorToggle = { handleInspectorToggle }
261- onNavigatorToggle = { handleNavigatorToggle }
262- />
263- ) }
264-
265- < Flex flex = { 1 } >
266- < WorkshopNavigator collections = { config . collections } expanded = { navigatorExpanded } />
267- < WorkshopCanvas
268- frameRef = { frame . setElement }
269- hidden = { navigatorExpanded || inspectorExpanded }
270- />
271- < WorkshopInspector expanded = { inspectorExpanded } />
272- </ Flex >
273-
274- < div data-portal = "" ref = { setPortalElement } />
275- </ Flex >
276- </ PortalProvider >
277- </ BoundaryElementProvider >
278- </ ToastProvider >
238+ < Flex data-boundary = "" direction = "column" height = "fill" style = { { minWidth : 320 } } >
239+ { withNavbar && (
240+ < WorkshopNavbar
241+ inspectorExpanded = { inspectorExpanded }
242+ navigatorExpanded = { navigatorExpanded }
243+ onInspectorToggle = { handleInspectorToggle }
244+ onNavigatorToggle = { handleNavigatorToggle }
245+ />
246+ ) }
247+
248+ < Flex flex = { 1 } >
249+ < WorkshopNavigator collections = { config . collections } expanded = { navigatorExpanded } />
250+ < WorkshopCanvas
251+ frameRef = { frame . setElement }
252+ hidden = { navigatorExpanded || inspectorExpanded }
253+ />
254+ < WorkshopInspector expanded = { inspectorExpanded } />
255+ </ Flex >
256+ </ Flex >
279257 </ WorkshopProvider >
280258 )
281259} )
0 commit comments