-
Notifications
You must be signed in to change notification settings - Fork 536
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
"Open in IDE" button for contracts (#1544)
* "Open in IDE" button for contracts Fixes #1508 * small fixes and tests * update icon styles * [skip ci] change ENV value
- Loading branch information
Showing
21 changed files
with
133 additions
and
1 deletion.
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
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
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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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,5 @@ | ||
export interface ContractCodeIde { | ||
title: string; | ||
url: string; | ||
icon_url: string; | ||
} |
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,75 @@ | ||
import { Flex, Button, chakra, Popover, PopoverTrigger, PopoverBody, PopoverContent, useDisclosure, Image, useColorModeValue } from '@chakra-ui/react'; | ||
import React from 'react'; | ||
|
||
import config from 'configs/app'; | ||
import IconSvg from 'ui/shared/IconSvg'; | ||
import LinkExternal from 'ui/shared/LinkExternal'; | ||
|
||
interface Props { | ||
className?: string; | ||
hash: string; | ||
} | ||
|
||
const ContractCodeIde = ({ className, hash }: Props) => { | ||
const { isOpen, onToggle, onClose } = useDisclosure(); | ||
const defaultIconColor = useColorModeValue('gray.600', 'gray.500'); | ||
|
||
const ideLinks = React.useMemo(() => { | ||
return config.UI.ides.items | ||
.map((ide) => { | ||
const url = decodeURIComponent(ide.url.replace('{hash}', hash).replace('{domain}', config.app.host || '')); | ||
const icon = 'icon_url' in ide ? | ||
<Image boxSize={ 5 } mr={ 2 } src={ ide.icon_url } alt={ `${ ide.title } icon` }/> : | ||
<IconSvg name="ABI_slim" boxSize={ 5 } color={ defaultIconColor } mr={ 2 }/>; | ||
|
||
return ( | ||
<LinkExternal key={ ide.title } href={ url } display="inline-flex" alignItems="center"> | ||
{ icon } | ||
{ ide.title } | ||
</LinkExternal> | ||
); | ||
}); | ||
}, [ defaultIconColor, hash ]); | ||
|
||
if (ideLinks.length === 0) { | ||
return null; | ||
} | ||
|
||
return ( | ||
<Popover isOpen={ isOpen } onClose={ onClose } placement="bottom-start" isLazy> | ||
<PopoverTrigger> | ||
<Button | ||
className={ className } | ||
size="sm" | ||
variant="outline" | ||
colorScheme="gray" | ||
onClick={ onToggle } | ||
aria-label="Open source code in IDE" | ||
fontWeight={ 500 } | ||
px={ 2 } | ||
h="32px" | ||
flexShrink={ 0 } | ||
> | ||
<span>Open in</span> | ||
<IconSvg name="arrows/east-mini" transform={ isOpen ? 'rotate(90deg)' : 'rotate(-90deg)' } transitionDuration="faster" boxSize={ 5 }/> | ||
</Button> | ||
</PopoverTrigger> | ||
<PopoverContent w="240px"> | ||
<PopoverBody > | ||
<chakra.span color="text_secondary" fontSize="xs">Redactors</chakra.span> | ||
<Flex | ||
flexDir="column" | ||
alignItems="flex-start" | ||
columnGap={ 6 } | ||
rowGap={ 3 } | ||
mt={ 3 } | ||
> | ||
{ ideLinks } | ||
</Flex> | ||
</PopoverBody> | ||
</PopoverContent> | ||
</Popover> | ||
); | ||
}; | ||
|
||
export default React.memo(chakra(ContractCodeIde)); |
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
Binary file modified
BIN
+927 Bytes
(100%)
...eenshots__/ContractCode.pw.tsx_dark-color-mode_full-view-mobile-dark-mode-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
+976 Bytes
(100%)
...ct/__screenshots__/ContractCode.pw.tsx_default_full-view-mobile-dark-mode-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
+1.09 KB
(100%)
...hots__/ContractCode.pw.tsx_default_verified-with-changed-byte-code-socket-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
+1011 Bytes
(100%)
..._screenshots__/ContractCode.pw.tsx_default_verified-with-multiple-sources-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
+1.79 KB
(100%)
..._screenshots__/ContractCode.pw.tsx_default_verified-with-multiple-sources-2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+33.5 KB
..._screenshots__/ContractCode.pw.tsx_default_verified-with-multiple-sources-3.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
+1.38 KB
(100%)
...act/__screenshots__/ContractCode.pw.tsx_mobile_full-view-mobile-dark-mode-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.