diff --git a/explorer/src/components/ConnectKeplrWallet.tsx b/explorer/src/components/ConnectKeplrWallet.tsx index 3093463c7a..66f8cc1598 100644 --- a/explorer/src/components/ConnectKeplrWallet.tsx +++ b/explorer/src/components/ConnectKeplrWallet.tsx @@ -67,7 +67,11 @@ export const ConnectKeplrWallet = () => { ); } - return ; + return ( + + ); }; return {getGlobalbutton()}; diff --git a/explorer/src/components/Delegations/components/ConfirmationModal.tsx b/explorer/src/components/Delegations/ConfirmationModal.tsx similarity index 100% rename from explorer/src/components/Delegations/components/ConfirmationModal.tsx rename to explorer/src/components/Delegations/ConfirmationModal.tsx diff --git a/explorer/src/components/Delegations/components/DelegateIconButton.tsx b/explorer/src/components/Delegations/DelegateIconButton.tsx similarity index 63% rename from explorer/src/components/Delegations/components/DelegateIconButton.tsx rename to explorer/src/components/Delegations/DelegateIconButton.tsx index b19a5587d0..80ae730c75 100644 --- a/explorer/src/components/Delegations/components/DelegateIconButton.tsx +++ b/explorer/src/components/Delegations/DelegateIconButton.tsx @@ -1,22 +1,23 @@ import * as React from 'react'; import { IconButton, Tooltip } from '@mui/material'; import { SxProps } from '@mui/system'; -import { DelegateIcon } from '../../../icons/DelevateSVG'; +import { DelegateIcon } from '../../icons/DelevateSVG'; export const DelegateIconButton: FCWithChildren<{ + size?: 'small' | 'medium'; disabled?: boolean; tooltip?: React.ReactNode; sx?: SxProps; onDelegate: () => void; -}> = ({ tooltip, onDelegate, sx, disabled }) => { +}> = ({ tooltip, onDelegate, sx, disabled, size = 'medium' }) => { const handleOnDelegate = (e: React.MouseEvent) => { e.stopPropagation(); onDelegate(); }; return ( - - + + ); diff --git a/explorer/src/components/Delegations/components/DelegateModal.tsx b/explorer/src/components/Delegations/DelegateModal.tsx similarity index 98% rename from explorer/src/components/Delegations/components/DelegateModal.tsx rename to explorer/src/components/Delegations/DelegateModal.tsx index d0df90ab13..c2b0da2e0a 100644 --- a/explorer/src/components/Delegations/components/DelegateModal.tsx +++ b/explorer/src/components/Delegations/DelegateModal.tsx @@ -7,8 +7,8 @@ import { useChain } from '@cosmos-kit/react'; import { SimpleModal } from './SimpleModal'; import { ModalListItem } from './ModalListItem'; import { DelegationModalProps } from './DelegationModal'; -import { unymToNym, validateAmount } from '../../../utils/currency'; -import { urls } from '../../../utils'; +import { unymToNym, validateAmount } from '../../utils/currency'; +import { urls } from '../../utils'; const MIN_AMOUNT_TO_DELEGATE = 10; const MIXNET_CONTRACT_ADDRESS = 'n17srjznxl9dvzdkpwpw24gg668wc73val88a6m5ajg6ankwvz9wtst0cznr'; diff --git a/explorer/src/components/Delegations/components/DelegationModal.tsx b/explorer/src/components/Delegations/DelegationModal.tsx similarity index 100% rename from explorer/src/components/Delegations/components/DelegationModal.tsx rename to explorer/src/components/Delegations/DelegationModal.tsx diff --git a/explorer/src/components/Delegations/components/ErrorModal.tsx b/explorer/src/components/Delegations/ErrorModal.tsx similarity index 100% rename from explorer/src/components/Delegations/components/ErrorModal.tsx rename to explorer/src/components/Delegations/ErrorModal.tsx diff --git a/explorer/src/components/Delegations/components/LoadingModal.tsx b/explorer/src/components/Delegations/LoadingModal.tsx similarity index 100% rename from explorer/src/components/Delegations/components/LoadingModal.tsx rename to explorer/src/components/Delegations/LoadingModal.tsx diff --git a/explorer/src/components/Delegations/components/ModalDivider.tsx b/explorer/src/components/Delegations/ModalDivider.tsx similarity index 100% rename from explorer/src/components/Delegations/components/ModalDivider.tsx rename to explorer/src/components/Delegations/ModalDivider.tsx diff --git a/explorer/src/components/Delegations/components/ModalListItem.tsx b/explorer/src/components/Delegations/ModalListItem.tsx similarity index 100% rename from explorer/src/components/Delegations/components/ModalListItem.tsx rename to explorer/src/components/Delegations/ModalListItem.tsx diff --git a/explorer/src/components/Delegations/components/SimpleModal.tsx b/explorer/src/components/Delegations/SimpleModal.tsx similarity index 98% rename from explorer/src/components/Delegations/components/SimpleModal.tsx rename to explorer/src/components/Delegations/SimpleModal.tsx index 76e3b1751d..88dff4d9d7 100644 --- a/explorer/src/components/Delegations/components/SimpleModal.tsx +++ b/explorer/src/components/Delegations/SimpleModal.tsx @@ -4,7 +4,7 @@ import CloseIcon from '@mui/icons-material/Close'; import ErrorOutline from '@mui/icons-material/ErrorOutline'; import InfoOutlinedIcon from '@mui/icons-material/InfoOutlined'; import ArrowBackIosNewIcon from '@mui/icons-material/ArrowBackIosNew'; -import { useIsMobile } from '../../../hooks/useIsMobile'; +import { useIsMobile } from '../../hooks/useIsMobile'; export const modalStyle = (width: number | string = 600) => ({ position: 'absolute' as 'absolute', diff --git a/explorer/src/components/Delegations/index.ts b/explorer/src/components/Delegations/index.ts new file mode 100644 index 0000000000..da51de9bd9 --- /dev/null +++ b/explorer/src/components/Delegations/index.ts @@ -0,0 +1,10 @@ +export * from './ConfirmationModal'; +export * from './DelegateIconButton'; +export * from './DelegationModal'; +export * from './DelegateModal'; +export * from './ErrorModal'; +export * from './LoadingModal'; +export * from './ModalDivider'; +export * from './ModalListItem'; +export * from './SimpleModal'; +export * from './styles'; diff --git a/explorer/src/components/Delegations/components/styles.ts b/explorer/src/components/Delegations/styles.ts similarity index 100% rename from explorer/src/components/Delegations/components/styles.ts rename to explorer/src/components/Delegations/styles.ts diff --git a/explorer/src/components/Filters/Filters.tsx b/explorer/src/components/Filters/Filters.tsx index a01d64361e..0823ef6579 100644 --- a/explorer/src/components/Filters/Filters.tsx +++ b/explorer/src/components/Filters/Filters.tsx @@ -1,5 +1,4 @@ import React, { useState, useEffect, useRef, useCallback } from 'react'; -import { Tune } from '@mui/icons-material'; import { Button, Dialog, @@ -20,6 +19,7 @@ import { EnumFilterKey, TFilterItem, TFilters } from '../../typeDefs/filters'; import { formatOnSave, generateFilterSchema } from './filterSchema'; import { Api } from '../../api'; import { useIsMobile } from '../../hooks/useIsMobile'; +import FiltersButton from './FiltersButton'; const FilterItem = ({ label, @@ -150,15 +150,7 @@ export const Filters = () => { {mixnodes?.data?.length} mixnodes matched your criteria - + Mixnode filters diff --git a/explorer/src/components/Filters/FiltersButton.tsx b/explorer/src/components/Filters/FiltersButton.tsx new file mode 100644 index 0000000000..1e6d3e2940 --- /dev/null +++ b/explorer/src/components/Filters/FiltersButton.tsx @@ -0,0 +1,34 @@ +import React from 'react'; +import { Button, IconButton } from '@mui/material'; +import { Tune } from '@mui/icons-material'; + +type FiltersButtonProps = { + iconOnly?: boolean; + fullWidth?: boolean; + onClick: () => void; +}; + +const FiltersButton = ({ iconOnly, fullWidth, onClick }: FiltersButtonProps) => { + if (iconOnly) { + return ( + + + + ); + } + + return ( + + ); +}; + +export default FiltersButton; diff --git a/explorer/src/components/MixNodes/DetailSection.tsx b/explorer/src/components/MixNodes/DetailSection.tsx index 6592e28f4f..6becf5efe4 100644 --- a/explorer/src/components/MixNodes/DetailSection.tsx +++ b/explorer/src/components/MixNodes/DetailSection.tsx @@ -1,10 +1,10 @@ import * as React from 'react'; import { Box, Button, Grid, Typography, useTheme } from '@mui/material'; import Identicon from 'react-identicons'; +import { useIsMobile } from '@src/hooks/useIsMobile'; import { MixnodeRowType } from '.'; import { getMixNodeStatusText, MixNodeStatus } from './Status'; import { MixNodeDescriptionResponse } from '../../typeDefs/explorer-api'; -import { useIsMobile } from '../../hooks/useIsMobile'; interface MixNodeDetailProps { mixNodeRow: MixnodeRowType; @@ -16,7 +16,7 @@ export const MixNodeDetailSection: FCWithChildren = ({ mixNo const palette = [theme.palette.text.primary]; const isMobile = useIsMobile(); const statusText = React.useMemo(() => getMixNodeStatusText(mixNodeRow.status), [mixNodeRow.status]); - console.log('mixNodeRow :>> ', mixNodeRow); + return ( diff --git a/explorer/src/components/MixNodes/index.ts b/explorer/src/components/MixNodes/index.ts new file mode 100644 index 0000000000..ccb6c5a8b3 --- /dev/null +++ b/explorer/src/components/MixNodes/index.ts @@ -0,0 +1,3 @@ +export * from './Status'; +export * from './StatusDropdown'; +export * from './mappings'; diff --git a/explorer/src/components/MixNodes/index.tsx b/explorer/src/components/MixNodes/mappings.ts similarity index 100% rename from explorer/src/components/MixNodes/index.tsx rename to explorer/src/components/MixNodes/mappings.ts diff --git a/explorer/src/components/Universal-DataGrid.tsx b/explorer/src/components/Universal-DataGrid.tsx index b396213998..4a53901f12 100644 --- a/explorer/src/components/Universal-DataGrid.tsx +++ b/explorer/src/components/Universal-DataGrid.tsx @@ -13,15 +13,13 @@ const useStyles = makeStyles({ }); export const cellStyles: SxProps = { - width: '100%', padding: 0, maxHeight: 100, color: 'inherit', textDecoration: 'none', fontWeight: 400, - fontSize: 12, lineHeight: 2, - textAlign: 'start', + fontSize: '12px', wordBreak: 'break-word', whiteSpace: 'break-spaces', }; diff --git a/explorer/src/components/index.ts b/explorer/src/components/index.ts new file mode 100644 index 0000000000..92eeebd010 --- /dev/null +++ b/explorer/src/components/index.ts @@ -0,0 +1,9 @@ +export * from './CustomColumnHeading'; +export * from './Title'; +export * from './Universal-DataGrid'; +export * from './Tooltip'; +export { default as StyledLink } from './StyledLink'; +export * from './Delegations'; +export * from './MixNodes'; +export * from './TableToolbar'; +export * from './Icons'; diff --git a/explorer/src/hooks/index.ts b/explorer/src/hooks/index.ts new file mode 100644 index 0000000000..e2c94ec1e4 --- /dev/null +++ b/explorer/src/hooks/index.ts @@ -0,0 +1,3 @@ +export * from './useIsMobile'; +export * from './useIsMounted'; +export * from './useGetMixnodeStatusColor'; diff --git a/explorer/src/hooks/useGetMixnodeStatusColor.ts b/explorer/src/hooks/useGetMixnodeStatusColor.ts new file mode 100644 index 0000000000..d9d71fe7e1 --- /dev/null +++ b/explorer/src/hooks/useGetMixnodeStatusColor.ts @@ -0,0 +1,17 @@ +import { useTheme } from '@mui/material'; +import { MixnodeStatus } from '@src/typeDefs/explorer-api'; + +export const useGetMixNodeStatusColor = (status: MixnodeStatus) => { + const theme = useTheme(); + + switch (status) { + case MixnodeStatus.active: + return theme.palette.nym.networkExplorer.mixnodes.status.active; + + case MixnodeStatus.standby: + return theme.palette.nym.networkExplorer.mixnodes.status.standby; + + default: + return theme.palette.nym.networkExplorer.mixnodes.status.inactive; + } +}; diff --git a/explorer/src/pages/Mixnodes/index.tsx b/explorer/src/pages/Mixnodes/index.tsx index b325a25f81..cf5cc789c3 100644 --- a/explorer/src/pages/Mixnodes/index.tsx +++ b/explorer/src/pages/Mixnodes/index.tsx @@ -3,7 +3,7 @@ import { GridColDef, GridRenderCellParams } from '@mui/x-data-grid'; import { Button, Card, Grid, Link as MuiLink, Box } from '@mui/material'; import { Link as RRDLink, useParams, useNavigate } from 'react-router-dom'; import { SelectChangeEvent } from '@mui/material/Select'; -import { SxProps } from '@mui/system'; +import { Stack, SxProps } from '@mui/system'; import { Theme, useTheme } from '@mui/material/styles'; import { CopyToClipboard } from '@nymproject/react/clipboard/CopyToClipboard'; import { useWallet } from '@cosmos-kit/react'; @@ -24,14 +24,9 @@ import { DelegateIconButton } from '../../components/Delegations/components/Dele import { DelegationModal, DelegationModalProps } from '../../components/Delegations/components/DelegationModal'; import { DelegateModal } from '../../components/Delegations/components/DelegateModal'; -const getCellFontStyle = (theme: Theme, row: MixnodeRowType, textColor?: string) => { - const color = textColor || getMixNodeStatusColor(theme, row.status); - return { - fontWeight: 400, - fontSize: 12, - color, - }; -}; +const getCellFontStyle = (theme: Theme, row: MixnodeRowType, textColor?: string) => ({ + color: textColor || getMixNodeStatusColor(theme, row.status), +}); const getCellStyles = (theme: Theme, row: MixnodeRowType, textColor?: string): SxProps => ({ ...cellStyles, @@ -99,28 +94,38 @@ export const PageMixnodes: FCWithChildren = () => { const columns: GridColDef[] = [ { - field: 'delegate', - headerName: 'Delegate', + field: 'identity_key', + headerName: 'Identity Key', disableColumnMenu: true, - disableReorder: true, - align: 'center', - renderHeader: () => , + renderHeader: () => , headerClassName: 'MuiDataGrid-header-override', - width: 80, - headerAlign: 'center', + width: 215, + headerAlign: 'left', renderCell: (params: GridRenderCellParams) => ( - { - if (wallet.status !== 'Connected') { - setConfirmationModalProps({ - status: 'info', - message: 'Please connect your wallet to delegate', - }); - } else { - setItemSelectedForDelegation({ identityKey: params.row.identity_key, mixId: params.row.mix_id }); - } - }} - /> + + { + if (wallet.status !== 'Connected') { + setConfirmationModalProps({ + status: 'info', + message: 'Please connect your wallet to delegate', + }); + } else { + setItemSelectedForDelegation({ identityKey: params.row.identity_key, mixId: params.row.mix_id }); + } + }} + /> + + + {splice(7, 29, params.value)} + + ), }, { @@ -129,8 +134,9 @@ export const PageMixnodes: FCWithChildren = () => { disableColumnMenu: true, renderHeader: () => , headerClassName: 'MuiDataGrid-header-override', - width: 70, - headerAlign: 'left', + width: 85, + align: 'center', + headerAlign: 'center', renderCell: (params: GridRenderCellParams) => ( { ), }, - { - field: 'identity_key', - headerName: 'Identity Key', - disableColumnMenu: true, - renderHeader: () => , - headerClassName: 'MuiDataGrid-header-override', - width: 190, - headerAlign: 'left', - renderCell: (params: GridRenderCellParams) => ( - <> - - - {splice(7, 29, params.value)} - - - ), - }, + { field: 'bond', headerName: 'Stake', @@ -175,7 +156,8 @@ export const PageMixnodes: FCWithChildren = () => { renderHeader: () => , type: 'number', headerClassName: 'MuiDataGrid-header-override', - width: 170, + width: 150, + align: 'left', headerAlign: 'left', renderCell: (params: GridRenderCellParams) => ( { ), headerClassName: 'MuiDataGrid-header-override', width: 185, - headerAlign: 'left', + align: 'center', + headerAlign: 'center', renderCell: (params: GridRenderCellParams) => ( 100 ? 'theme.palette.warning.main' : undefined), }} component={RRDLink} @@ -217,11 +199,12 @@ export const PageMixnodes: FCWithChildren = () => { field: 'pledge_amount', headerName: 'Bond', disableColumnMenu: true, - width: 175, + width: 150, headerClassName: 'MuiDataGrid-header-override', renderHeader: () => , type: 'number', headerAlign: 'left', + align: 'left', renderCell: (params: GridRenderCellParams) => ( { /> ), headerClassName: 'MuiDataGrid-header-override', - width: 160, - headerAlign: 'left', + width: 145, + headerAlign: 'center', + align: 'center', renderCell: (params: GridRenderCellParams) => ( @@ -266,7 +250,8 @@ export const PageMixnodes: FCWithChildren = () => { ), headerClassName: 'MuiDataGrid-header-override', width: 170, - headerAlign: 'left', + headerAlign: 'center', + align: 'center', disableColumnMenu: true, renderCell: (params: GridRenderCellParams) => ( { ), headerClassName: 'MuiDataGrid-header-override', width: 165, - headerAlign: 'left', + headerAlign: 'center', + align: 'center', renderCell: (params: GridRenderCellParams) => (