-
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.
[field] Use Sanity preview component for fallback diffs
- Loading branch information
Showing
3 changed files
with
14 additions
and
32 deletions.
There are no files selected for viewing
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
This file was deleted.
Oops, something went wrong.
37 changes: 13 additions & 24 deletions
37
packages/@sanity/field/src/diff/fallback/FallbackDiff.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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,30 +1,19 @@ | ||
import * as React from 'react' | ||
import React from 'react' | ||
import Preview from 'part:@sanity/base/preview' | ||
import {DiffComponent} from '../../types' | ||
import {Change} from '../components' | ||
|
||
import styles from './FallbackDiff.css' | ||
function FallbackPreview({value, schemaType}) { | ||
return <Preview type={schemaType} value={value} layout="default" /> | ||
} | ||
|
||
export const FallbackDiff: DiffComponent = ({diff}) => { | ||
export const FallbackDiff: DiffComponent<any> = ({diff, schemaType}) => { | ||
return ( | ||
<div className={styles.root}> | ||
<div> | ||
<strong> | ||
Missing diff component (<code>{diff.type}</code>) | ||
</strong> | ||
</div> | ||
|
||
<details> | ||
<summary>JSON</summary> | ||
|
||
<h2>From</h2> | ||
<pre> | ||
<code>{JSON.stringify(diff.fromValue, null, 2)}</code> | ||
</pre> | ||
|
||
<h2>To</h2> | ||
<pre> | ||
<code>{JSON.stringify(diff.toValue, null, 2)}</code> | ||
</pre> | ||
</details> | ||
</div> | ||
<Change | ||
diff={diff} | ||
schemaType={schemaType} | ||
previewComponent={FallbackPreview} | ||
layout="inline" | ||
/> | ||
) | ||
} |