Commit 56800288 authored by Max Alekseenko's avatar Max Alekseenko

add skeletons

parent 00ed752a
...@@ -12,24 +12,24 @@ type Props = { ...@@ -12,24 +12,24 @@ type Props = {
securityReport?: any; // eslint-disable-line @typescript-eslint/no-explicit-any securityReport?: any; // eslint-disable-line @typescript-eslint/no-explicit-any
height?: string | undefined; height?: string | undefined;
showContractList: () => void; showContractList: () => void;
isLoading?: boolean;
} }
const AppSecurityReport = ({ securityReport, height, showContractList }: Props) => { const AppSecurityReport = ({ securityReport, height, showContractList, isLoading }: Props) => {
if (!securityReport) { if (!securityReport && !isLoading) {
return null; return null;
} }
const { const {
overallInfo: { securityScore = 0,
securityScore, solidityScanContractsNumber = 0,
solidityScanContractsNumber, issueSeverityDistribution = {},
issueSeverityDistribution, totalIssues = 0,
totalIssues, } = securityReport?.overallInfo || {};
},
} = securityReport;
return ( return (
<SolidityscanReportButton <SolidityscanReportButton
isLoading={ isLoading }
height={ height } height={ height }
score={ securityScore } score={ securityScore }
popoverContent={ ( popoverContent={ (
......
import { Link, Tooltip } from '@chakra-ui/react'; import { Link, Tooltip, Skeleton } from '@chakra-ui/react';
import React from 'react'; import React from 'react';
import type { MouseEvent } from 'react'; import type { MouseEvent } from 'react';
...@@ -28,9 +28,10 @@ interface Props { ...@@ -28,9 +28,10 @@ interface Props {
children: string; children: string;
onClick: (event: MouseEvent) => void; onClick: (event: MouseEvent) => void;
variant: ContractListButtonVariants; variant: ContractListButtonVariants;
isLoading?: boolean;
} }
const ContractListButton = ({ children, onClick, variant }: Props) => { const ContractListButton = ({ children, onClick, variant, isLoading }: Props) => {
const { icon, iconColor, tooltip } = values[variant]; const { icon, iconColor, tooltip } = values[variant];
return ( return (
<Tooltip <Tooltip
...@@ -40,6 +41,14 @@ const ContractListButton = ({ children, onClick, variant }: Props) => { ...@@ -40,6 +41,14 @@ const ContractListButton = ({ children, onClick, variant }: Props) => {
isDisabled={ !tooltip } isDisabled={ !tooltip }
openDelay={ 500 } openDelay={ 500 }
width="250px" width="250px"
>
<Skeleton
isLoaded={ !isLoading }
display="inline-flex"
alignItems="center"
width={ isLoading ? '40px' : 'auto' }
height="30px"
borderRadius="base"
> >
<Link <Link
fontSize="sm" fontSize="sm"
...@@ -50,6 +59,7 @@ const ContractListButton = ({ children, onClick, variant }: Props) => { ...@@ -50,6 +59,7 @@ const ContractListButton = ({ children, onClick, variant }: Props) => {
{ icon && <IconSvg name={ icon } boxSize={ 5 } color={ iconColor } mr={ 1 }/> } { icon && <IconSvg name={ icon } boxSize={ 5 } color={ iconColor } mr={ 1 }/> }
{ children } { children }
</Link> </Link>
</Skeleton>
</Tooltip> </Tooltip>
); );
}; };
......
...@@ -93,18 +93,27 @@ const ListItem = ({ app, onInfoClick, isFavorite, onFavoriteClick, isLoading, on ...@@ -93,18 +93,27 @@ const ListItem = ({ app, onInfoClick, isFavorite, onFavoriteClick, isLoading, on
</Flex> </Flex>
<Flex alignItems="center"> <Flex alignItems="center">
<Flex flex={ 1 } gap={ 3 } alignItems="center"> <Flex flex={ 1 } gap={ 3 } alignItems="center">
{ securityReport ? ( { (securityReport || isLoading) ? (
<> <>
<AppSecurityReport <AppSecurityReport
isLoading={ isLoading }
securityReport={ securityReport } securityReport={ securityReport }
showContractList={ showAnalyzedContracts } showContractList={ showAnalyzedContracts }
height="30px" height="30px"
/> />
<ContractListButton onClick={ showAllContracts } variant={ ContractListButtonVariants.ALL_CONTRACTS }> <ContractListButton
{ securityReport.overallInfo.totalContractsNumber } onClick={ showAllContracts }
variant={ ContractListButtonVariants.ALL_CONTRACTS }
isLoading={ isLoading }
>
{ securityReport?.overallInfo.totalContractsNumber }
</ContractListButton> </ContractListButton>
<ContractListButton onClick={ showVerifiedContracts } variant={ ContractListButtonVariants.VERIFIED_CONTRACTS }> <ContractListButton
{ securityReport.overallInfo.verifiedNumber } onClick={ showVerifiedContracts }
variant={ ContractListButtonVariants.VERIFIED_CONTRACTS }
isLoading={ isLoading }
>
{ securityReport?.overallInfo.verifiedNumber }
</ContractListButton> </ContractListButton>
</> </>
) : ( ) : (
...@@ -113,9 +122,7 @@ const ListItem = ({ app, onInfoClick, isFavorite, onFavoriteClick, isLoading, on ...@@ -113,9 +122,7 @@ const ListItem = ({ app, onInfoClick, isFavorite, onFavoriteClick, isLoading, on
</chakra.span> </chakra.span>
) } ) }
</Flex> </Flex>
{ !isLoading && ( <MoreInfoButton onClick={ handleInfoClick } isLoading={ isLoading }/>
<MoreInfoButton onClick={ handleInfoClick }/>
) }
</Flex> </Flex>
</Flex> </Flex>
</ListItemMobile> </ListItemMobile>
......
import { Link } from '@chakra-ui/react'; import { Link, Skeleton } from '@chakra-ui/react';
import React from 'react'; import React from 'react';
import type { MouseEvent } from 'react'; import type { MouseEvent } from 'react';
interface Props { interface Props {
onClick: (event: MouseEvent) => void; onClick: (event: MouseEvent) => void;
isLoading?: boolean;
} }
const MoreInfoButton = ({ onClick }: Props) => ( const MoreInfoButton = ({ onClick, isLoading }: Props) => (
<Skeleton
isLoaded={ !isLoading }
display="inline-flex"
alignItems="center"
height="30px"
borderRadius="base"
>
<Link <Link
fontSize="sm" fontSize="sm"
onClick={ onClick } onClick={ onClick }
...@@ -15,6 +23,7 @@ const MoreInfoButton = ({ onClick }: Props) => ( ...@@ -15,6 +23,7 @@ const MoreInfoButton = ({ onClick }: Props) => (
> >
More info More info
</Link> </Link>
</Skeleton>
); );
export default MoreInfoButton; export default MoreInfoButton;
import { Td, Tr, IconButton } from '@chakra-ui/react'; import { Td, Tr, IconButton, Skeleton } from '@chakra-ui/react';
import React from 'react'; import React from 'react';
import type { MouseEvent } from 'react'; import type { MouseEvent } from 'react';
...@@ -61,6 +61,7 @@ const TableItem = ({ ...@@ -61,6 +61,7 @@ const TableItem = ({
return ( return (
<Tr> <Tr>
<Td verticalAlign="middle" px={ 2 }> <Td verticalAlign="middle" px={ 2 }>
<Skeleton isLoaded={ !isLoading }>
<IconButton <IconButton
aria-label="Mark as favorite" aria-label="Mark as favorite"
title="Mark as favorite" title="Mark as favorite"
...@@ -74,37 +75,50 @@ const TableItem = ({ ...@@ -74,37 +75,50 @@ const TableItem = ({
<IconSvg name="star_outline" w={ 5 } h={ 5 } color="gray.400"/> <IconSvg name="star_outline" w={ 5 } h={ 5 } color="gray.400"/>
} }
/> />
</Skeleton>
</Td> </Td>
<Td verticalAlign="middle"> <Td verticalAlign="middle">
<AppLink app={ app } isLoading={ isLoading } onAppClick={ onAppClick } isLarge/> <AppLink app={ app } isLoading={ isLoading } onAppClick={ onAppClick } isLarge/>
</Td> </Td>
<Td verticalAlign="middle"> <Td verticalAlign="middle">
{ securityReport ? ( { (securityReport || isLoading) ? (
<AppSecurityReport securityReport={ securityReport } showContractList={ showAnalyzedContracts }/> <AppSecurityReport
securityReport={ securityReport }
showContractList={ showAnalyzedContracts }
isLoading={ isLoading }
/>
) : ( ) : (
<DataNotAvailable/> <DataNotAvailable/>
) } ) }
</Td> </Td>
<Td verticalAlign="middle"> <Td verticalAlign="middle">
{ securityReport ? ( { (securityReport || isLoading) ? (
<ContractListButton onClick={ showAllContracts } variant={ ContractListButtonVariants.ALL_CONTRACTS }> <ContractListButton
{ securityReport.overallInfo.totalContractsNumber } onClick={ showAllContracts }
variant={ ContractListButtonVariants.ALL_CONTRACTS }
isLoading={ isLoading }
>
{ securityReport?.overallInfo.totalContractsNumber }
</ContractListButton> </ContractListButton>
) : ( ) : (
<DataNotAvailable/> <DataNotAvailable/>
) } ) }
</Td> </Td>
<Td verticalAlign="middle"> <Td verticalAlign="middle">
{ securityReport ? ( { (securityReport || isLoading) ? (
<ContractListButton onClick={ showVerifiedContracts } variant={ ContractListButtonVariants.VERIFIED_CONTRACTS }> <ContractListButton
{ securityReport.overallInfo.verifiedNumber } onClick={ showVerifiedContracts }
variant={ ContractListButtonVariants.VERIFIED_CONTRACTS }
isLoading={ isLoading }
>
{ securityReport?.overallInfo.verifiedNumber }
</ContractListButton> </ContractListButton>
) : ( ) : (
<DataNotAvailable/> <DataNotAvailable/>
) } ) }
</Td> </Td>
<Td verticalAlign="middle" isNumeric> <Td verticalAlign="middle" isNumeric>
<MoreInfoButton onClick={ handleInfoClick }/> <MoreInfoButton onClick={ handleInfoClick } isLoading={ isLoading }/>
</Td> </Td>
</Tr> </Tr>
); );
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment