Skip to content

Commit

Permalink
chore(deps): update dependency @uiw/react-json-view to ^2.0.0-alpha.7
Browse files Browse the repository at this point in the history
  • Loading branch information
jaywcjlove committed Sep 23, 2023
1 parent bdd22ae commit 8717280
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 17 deletions.
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@
},
"license": "MIT",
"dependencies": {
"@uiw/react-copy-to-clipboard": "^4.21.28",
"@uiw/react-copy-to-clipboard": "^4.22.0",
"@uiw/react-github-corners": "^1.5.15",
"@uiw/react-json-view": "^1.8.4",
"@uiw/react-json-view": "^2.0.0-alpha.7",
"@wcj/dark-mode": "^1.0.15",
"react": "^18.2.0",
"react-dom": "^18.2.0",
Expand Down
25 changes: 10 additions & 15 deletions src/app/App.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import React, { Fragment, useEffect, useState } from 'react';
import JsonViewer from '@uiw/react-json-view';
import { type SemicolonProps } from '@uiw/react-json-view/esm/semicolon';
import { darkTheme } from '@uiw/react-json-view/dark';
import { lightTheme } from '@uiw/react-json-view/light';
import CopyToClipboard from '@uiw/react-copy-to-clipboard';
Expand Down Expand Up @@ -28,6 +27,7 @@ const Header = styled.header`
flex-direction: column;
align-items: center;
justify-content: center;
padding-bottom: 6rem;
`;

const Keyboard = styled.div`
Expand Down Expand Up @@ -101,13 +101,6 @@ const JsonView = styled.div`
type Writeable<T> = { -readonly [P in keyof T]: T[P] };
type KeyboardEventType = Writeable<KeyboardEvent>;

const ObjectKey: SemicolonProps['render'] = ({ value, keyName, parentName, ...reset }) => {
if (/(keycode|charcode|which)/i.test(keyName?.toString() || '')) {
return <del {...reset} title={`"${keyName}" deprecated`} />;
}
return <span {...reset} />;
};

const App = () => {
const [data, setData] = useState<KeyboardEventType>();
const [copied, setCopied] = useState(false);
Expand Down Expand Up @@ -205,13 +198,15 @@ const App = () => {
</CopyToClipboard>
</Keyboard>
<JsonView>
<JsonViewer
value={data}
components={{
objectKey: ObjectKey,
}}
style={{ ...style, '--w-rjv-background-color': 'transparent' } as React.CSSProperties}
/>
<JsonViewer value={data} style={{ ...style, '--w-rjv-background-color': 'transparent' } as React.CSSProperties}>
<JsonViewer.KeyName
render={(props, { value, keyName }) => {
if (/(keycode|charcode|which)/i.test(keyName?.toString() || '')) {
return <del {...props}>{keyName}</del>;
}
}}
/>
</JsonViewer>
</JsonView>
</Fragment>
)}
Expand Down

0 comments on commit 8717280

Please sign in to comment.