Skip to content

Commit

Permalink
refactor(core): move PreviewCardContext to singletons
Browse files Browse the repository at this point in the history
  • Loading branch information
binoy14 committed Apr 29, 2024
1 parent 3008a1c commit 30cc592
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import {createContext} from 'react'
import type {PreviewCardContextValue} from 'sanity'

/**
* @internal
*/
export const PreviewCardContext = createContext<PreviewCardContextValue>({selected: false})
1 change: 1 addition & 0 deletions packages/sanity/src/_singletons/index.ts
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
export * from './changeIndicators/ConnectorContext'
export * from './components/previewCard/PreviewCardContext'
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import {Card, type CardProps} from '@sanity/ui'
import {createContext, type ForwardedRef, forwardRef, type HTMLProps, useContext} from 'react'
import {type ForwardedRef, forwardRef, type HTMLProps, useContext} from 'react'
import {PreviewCardContext} from 'sanity/_singletons'
import {css, styled} from 'styled-components'

/** @internal */
Expand All @@ -22,8 +23,6 @@ export interface PreviewCardContextValue {
selected?: boolean
}

const PreviewCardContext = createContext<PreviewCardContextValue>({selected: false})

/** @internal */
export function usePreviewCard(): PreviewCardContextValue {
const context = useContext(PreviewCardContext)
Expand Down

0 comments on commit 30cc592

Please sign in to comment.