-
Notifications
You must be signed in to change notification settings - Fork 394
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor(base): import preview-resolver part from central location
- Loading branch information
Showing
4 changed files
with
29 additions
and
27 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import React from 'react' | ||
import {SchemaType} from '@sanity/types' | ||
import {previewResolver as resolvePreview} from '../legacyParts' | ||
|
||
interface PreviewProps { | ||
layout?: string | ||
value?: unknown | ||
type: SchemaType | ||
} | ||
|
||
export default function Preview(props: PreviewProps) { | ||
const {type, value, layout} = props | ||
|
||
const PreviewComponent = resolvePreview(type) | ||
|
||
return PreviewComponent ? ( | ||
<PreviewComponent type={type} value={value} layout={layout} /> | ||
) : ( | ||
<div>No preview for {JSON.stringify(value)}</div> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
// @todo: remove the following line when part imports has been removed from this file | ||
///<reference types="@sanity/types/parts" /> | ||
|
||
import previewResolver from 'part:@sanity/base/preview-resolver?' | ||
|
||
export {previewResolver} |
7 changes: 2 additions & 5 deletions
7
packages/@sanity/base/src/preview/components/RenderPreviewSnapshot.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters