Skip to content

Commit

Permalink
refactor(core): move ZIndexContext to singletons
Browse files Browse the repository at this point in the history
  • Loading branch information
binoy14 committed Apr 29, 2024
1 parent 5ca1b00 commit d1a1d40
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 18 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import {createContext} from 'react'
import type {ZIndexContextValue} from 'sanity'

import {zIndexContextDefaults} from './zIndexContextDefaults'

/**
* TODO: Rename to `ZOffsetsContext`
*
* @internal
*/
export const ZIndexContext = createContext<ZIndexContextValue>(zIndexContextDefaults)
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import {type ZIndexContextValue} from './types'
import type {ZIndexContextValue} from 'sanity'

/**
* @internal
*/
export const defaults: ZIndexContextValue = {
export const zIndexContextDefaults: ZIndexContextValue = {
navbar: 200,
navbarPopover: 500000,
navbarDialog: 500001,
Expand Down
2 changes: 2 additions & 0 deletions packages/sanity/src/_singletons/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
export * from './changeIndicators/ConnectorContext'
export * from './components/previewCard/PreviewCardContext'
export * from './components/scroll/scrollContext'
export * from './components/zOffsets/ZIndexContext'
export * from './components/zOffsets/zIndexContextDefaults'
11 changes: 0 additions & 11 deletions packages/sanity/src/core/components/zOffsets/ZIndexContext.ts

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
import {type ReactElement, type ReactNode} from 'react'

import {defaults} from './defaults'
import {ZIndexContext} from './ZIndexContext'
import {ZIndexContext, zIndexContextDefaults} from 'sanity/_singletons'

/**
* TODO: Rename to `ZOffsetsProvider`
*
* @internal
*/
export function ZIndexProvider({children}: {children?: ReactNode}): ReactElement {
return <ZIndexContext.Provider value={defaults}>{children}</ZIndexContext.Provider>
return <ZIndexContext.Provider value={zIndexContextDefaults}>{children}</ZIndexContext.Provider>
}
2 changes: 1 addition & 1 deletion packages/sanity/src/core/components/zOffsets/useZIndex.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import {useContext} from 'react'
import {ZIndexContext} from 'sanity/_singletons'

import {type ZIndexContextValue} from './types'
import {ZIndexContext} from './ZIndexContext'

/**
* TODO: Rename to `useZOffsets`
Expand Down

0 comments on commit d1a1d40

Please sign in to comment.