forked from RedHatInsights/frontend-components
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(docs): Add JSON view component for complex prop type structures.
- Loading branch information
1 parent
27b2958
commit cb5d74e
Showing
6 changed files
with
84 additions
and
7 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 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,33 @@ | ||
import React from 'react'; | ||
import PropTypes from 'prop-types'; | ||
import dynamic from 'next/dynamic'; | ||
import { createUseStyles } from 'react-jss'; | ||
|
||
const ReactJson = dynamic( | ||
() => import('react-json-view'), | ||
{ ssr: false } | ||
); | ||
|
||
const useStyles = createUseStyles({ | ||
jsonContainer: { | ||
backgroundColor: '#031a16', | ||
borderRadius: 8, | ||
padding: 16 | ||
} | ||
}); | ||
|
||
const ExtensiveProp = ({ data }) => { | ||
const classes = useStyles(); | ||
const { required, description, defaultValue, ...src } = JSON.parse(data); | ||
return ( | ||
<div className={classes.jsonContainer}> | ||
<ReactJson className="foo" theme="apathy" collapsed={3} src={src} /> | ||
</div> | ||
); | ||
}; | ||
|
||
ExtensiveProp.propTypes = { | ||
data: PropTypes.any | ||
}; | ||
|
||
export default ExtensiveProp; |
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 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 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 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