Moved to use syntax-highlighter instead of prism

This commit is contained in:
sam-keen 2022-03-03 17:11:18 +00:00 committed by Dexter Edwards
parent 346135c6d4
commit e981b8c7fa
3 changed files with 9 additions and 29 deletions

View File

@ -1,19 +0,0 @@
import { useEffect } from 'react';
import Prism from 'prismjs';
interface CodeblockProps {
code: string;
language: string;
}
export const Codeblock = ({ code, language }: CodeblockProps) => {
useEffect(() => {
Prism.highlightAll();
});
return (
<pre>
<code className={`language-${language}`}>{code}</code>
</pre>
);
};

View File

@ -1,6 +1,6 @@
import { Codeblock } from '../../codeblock';
import { ChainExplorerTxResponse } from '../../../routes/types/chain-explorer-response'; import { ChainExplorerTxResponse } from '../../../routes/types/chain-explorer-response';
import { Table } from '../../table'; import { Table } from '../../table';
import { SyntaxHighlighter } from '../../syntax-highlighter';
interface TxContentProps { interface TxContentProps {
data: ChainExplorerTxResponse | undefined; data: ChainExplorerTxResponse | undefined;
@ -11,14 +11,14 @@ export const TxContent = ({ data }: TxContentProps) => {
return <>Awaiting decoded transaction data</>; return <>Awaiting decoded transaction data</>;
} }
const Command = JSON.parse(data.Command); const { marketId, type, side, size } = JSON.parse(data.Command);
const displayCode = `{ const displayCode = {
"market": "${Command.marketId}", market: marketId,
"type": "${Command.type}", type,
"side": "${Command.side}", side,
"size": "${Command.size}", size,
}`; };
return ( return (
<> <>
@ -30,7 +30,7 @@ export const TxContent = ({ data }: TxContentProps) => {
</Table> </Table>
<h3>Decoded transaction content</h3> <h3>Decoded transaction content</h3>
<Codeblock code={displayCode} language={'javascript'} /> <SyntaxHighlighter data={displayCode} />
</> </>
); );
}; };

View File

@ -27,7 +27,6 @@
"next": "12.0.7", "next": "12.0.7",
"nx": "^13.8.3", "nx": "^13.8.3",
"postcss": "^8.4.6", "postcss": "^8.4.6",
"prismjs": "^1.27.0",
"react": "17.0.2", "react": "17.0.2",
"react-dom": "17.0.2", "react-dom": "17.0.2",
"react-syntax-highlighter": "^15.4.5", "react-syntax-highlighter": "^15.4.5",