Skip to content

Commit

Permalink
prettify JSON data
Browse files Browse the repository at this point in the history
  • Loading branch information
GuillaumeRx committed Sep 30, 2022
1 parent 99e086c commit a1bbde8
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 5 deletions.
5 changes: 5 additions & 0 deletions ui/components/app/confirm-page-container/flask/index.scss
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
.snap-insight {
word-wrap: break-word;

&__container__data__json {
word-wrap: break-word;
overflow-x: auto;
}
}
21 changes: 16 additions & 5 deletions ui/components/app/confirm-page-container/flask/snap-insight.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,11 +64,22 @@ export const SnapInsight = ({ transaction, chainId, selectedSnap }) => {
>
{key}
</Typography>
<Typography variant={TYPOGRAPHY.H6}>
{typeof data[key] === 'string'
? data[key]
: JSON.stringify(data[key])}
</Typography>

{typeof data[key] === 'string' ? (
<Typography variant={TYPOGRAPHY.H6}>
{data[key]}
</Typography>
) : (
<Box
className="snap-insight__container__data__json"
backgroundColor={COLORS.BACKGROUND_ALTERNATIVE}
padding={3}
>
<Typography variant={TYPOGRAPHY.H7}>
<pre>{JSON.stringify(data[key], null, 2)}</pre>
</Typography>
</Box>
)}
</div>
))}
</Box>
Expand Down

0 comments on commit a1bbde8

Please sign in to comment.