mirror of
https://github.com/luxfi/explore.git
synced 2026-09-24 00:28:18 +00:00
* display address selector for non-verified proxy contract * add code view snippet for ABI and Compiler Settings * syntax highlighting for Scilla contracts * ENV preset for zilliqa * fix tests * add native coin value to simulate method call * fix test
38 lines
1.2 KiB
TypeScript
38 lines
1.2 KiB
TypeScript
import { Box, chakra, Flex, Skeleton } from '@chakra-ui/react';
|
|
import React from 'react';
|
|
|
|
import CopyToClipboard from 'ui/shared/CopyToClipboard';
|
|
import CodeEditor from 'ui/shared/monaco/CodeEditor';
|
|
|
|
interface Props {
|
|
data: string;
|
|
copyData?: string;
|
|
language: string;
|
|
title?: string;
|
|
className?: string;
|
|
rightSlot?: React.ReactNode;
|
|
isLoading?: boolean;
|
|
}
|
|
|
|
const CodeViewSnippet = ({ data, copyData, language, title, className, rightSlot, isLoading }: Props) => {
|
|
|
|
const editorData = React.useMemo(() => {
|
|
return [ { file_path: 'index', source_code: data } ];
|
|
}, [ data ]);
|
|
|
|
return (
|
|
<Box className={ className } as="section" title={ title }>
|
|
{ (title || rightSlot) && (
|
|
<Flex justifyContent={ title ? 'space-between' : 'flex-end' } alignItems="center" mb={ 3 }>
|
|
{ title && <Skeleton fontWeight={ 500 } isLoaded={ !isLoading }>{ title }</Skeleton> }
|
|
{ rightSlot }
|
|
<CopyToClipboard text={ copyData ?? data } isLoading={ isLoading }/>
|
|
</Flex>
|
|
) }
|
|
{ isLoading ? <Skeleton height="500px" w="100%"/> : <CodeEditor data={ editorData } language={ language }/> }
|
|
</Box>
|
|
);
|
|
};
|
|
|
|
export default React.memo(chakra(CodeViewSnippet));
|