Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[test-studio] Improve DeveloperPreview appearance + small screen fixes
- Loading branch information
1 parent
8998ce7
commit 8bb8464
Showing
4 changed files
with
47 additions
and
22 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
26 changes: 26 additions & 0 deletions
26
packages/test-studio/src/previews/developer/DeveloperPreview.js
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,26 @@ | ||
/* eslint-disable react/prop-types */ | ||
|
||
import React from 'react' | ||
import Spinner from 'part:@sanity/components/loading/spinner' | ||
import JSONPretty from 'react-json-pretty' | ||
import monikai from 'react-json-pretty/dist/monikai' | ||
import styles from './DeveloperPreview.module.css' | ||
|
||
function DeveloperPreview(props) { | ||
const {history, draft, published} = props | ||
const {snapshot: historical, isLoading: isLoadingHistorical} = history.document | ||
|
||
return ( | ||
<div className={styles.root}> | ||
{isLoadingHistorical && <Spinner center message="Loading revision" />} | ||
|
||
<JSONPretty | ||
data={historical || draft || published} | ||
theme={monikai} | ||
mainStyle="white-space: pre-wrap" | ||
/> | ||
</div> | ||
) | ||
} | ||
|
||
export default DeveloperPreview |
12 changes: 12 additions & 0 deletions
12
packages/test-studio/src/previews/developer/DeveloperPreview.module.css
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,12 @@ | ||
.root { | ||
background: #272822; | ||
margin: 0; | ||
padding: 1em; | ||
min-height: 100%; | ||
box-sizing: border-box; | ||
word-break: break-word; | ||
|
||
@nest & > div > pre { | ||
margin: 0; | ||
} | ||
} |
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 @@ | ||
export {default as DeveloperPreview} from './DeveloperPreview' |