Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
F
frontend
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
vicotor
frontend
Commits
fb1e3bf9
Commit
fb1e3bf9
authored
Nov 22, 2024
by
tom
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix tooltip behavior on mobile
parent
65143b19
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
75 additions
and
36 deletions
+75
-36
BlockCeloEpochTag.tsx
ui/block/BlockCeloEpochTag.tsx
+72
-0
Block.tsx
ui/pages/Block.tsx
+3
-36
No files found.
ui/block/BlockCeloEpochTag.tsx
0 → 100644
View file @
fb1e3bf9
import
{
Tag
,
Tooltip
,
useDisclosure
}
from
'
@chakra-ui/react
'
;
import
React
from
'
react
'
;
import
{
route
}
from
'
nextjs-routes
'
;
import
config
from
'
configs/app
'
;
import
LinkInternal
from
'
ui/shared/links/LinkInternal
'
;
import
type
{
BlockQuery
}
from
'
./useBlockQuery
'
;
interface
Props
{
blockQuery
:
BlockQuery
;
}
const
BlockCeloEpochTag
=
({
blockQuery
}:
Props
)
=>
{
// have to implement controlled tooltip because of the issue - https://github.com/chakra-ui/chakra-ui/issues/7107
const
{
isOpen
,
onOpen
,
onToggle
,
onClose
}
=
useDisclosure
();
if
(
!
blockQuery
.
data
?.
celo
)
{
return
null
;
}
if
(
!
blockQuery
.
data
.
celo
.
is_epoch_block
)
{
const
celoConfig
=
config
.
features
.
celo
;
const
epochBlockNumber
=
celoConfig
.
isEnabled
&&
celoConfig
.
L2UpgradeBlock
&&
blockQuery
.
data
.
height
<=
celoConfig
.
L2UpgradeBlock
?
blockQuery
.
data
.
celo
.
epoch_number
*
celoConfig
.
BLOCKS_PER_EPOCH
:
undefined
;
const
tag
=
(
<
Tag
colorScheme=
{
epochBlockNumber
?
'
gray-blue
'
:
'
gray
'
}
onClick=
{
epochBlockNumber
?
undefined
:
onToggle
}
onMouseEnter=
{
onOpen
}
onMouseLeave=
{
onClose
}
>
Epoch #
{
blockQuery
.
data
.
celo
.
epoch_number
}
</
Tag
>
);
const
content
=
epochBlockNumber
?
(
<
LinkInternal
href=
{
route
({
pathname
:
'
/block/[height_or_hash]
'
,
query
:
{
height_or_hash
:
String
(
epochBlockNumber
)
}
})
}
>
{
tag
}
</
LinkInternal
>
)
:
tag
;
return
(
<
Tooltip
label=
"Displays the epoch this block belongs to before the epoch is finalized"
maxW=
"280px"
textAlign=
"center"
isOpen=
{
isOpen
}
onClose=
{
onClose
}
>
{
content
}
</
Tooltip
>
);
}
return
(
<
Tooltip
label=
"Displays the epoch finalized by this block"
maxW=
"280px"
textAlign=
"center"
isOpen=
{
isOpen
}
onClose=
{
onClose
}
>
<
Tag
bgColor=
"celo"
color=
"blackAlpha.800"
onClick=
{
onToggle
}
onMouseEnter=
{
onOpen
}
onMouseLeave=
{
onClose
}
>
Finalized epoch #
{
blockQuery
.
data
.
celo
.
epoch_number
}
</
Tag
>
</
Tooltip
>
);
};
export
default
React
.
memo
(
BlockCeloEpochTag
);
ui/pages/Block.tsx
View file @
fb1e3bf9
import
{
chakra
,
Skeleton
,
Tooltip
}
from
'
@chakra-ui/react
'
;
import
{
chakra
,
Skeleton
}
from
'
@chakra-ui/react
'
;
import
capitalize
from
'
lodash/capitalize
'
;
import
{
useRouter
}
from
'
next/router
'
;
import
React
from
'
react
'
;
...
...
@@ -6,8 +6,6 @@ import React from 'react';
import
type
{
PaginationParams
}
from
'
ui/shared/pagination/types
'
;
import
type
{
RoutedTab
}
from
'
ui/shared/Tabs/types
'
;
import
{
route
}
from
'
nextjs-routes
'
;
import
config
from
'
configs/app
'
;
import
{
useAppContext
}
from
'
lib/contexts/app
'
;
import
throwOnAbsentParamError
from
'
lib/errors/throwOnAbsentParamError
'
;
...
...
@@ -15,6 +13,7 @@ import throwOnResourceLoadError from 'lib/errors/throwOnResourceLoadError';
import
useIsMobile
from
'
lib/hooks/useIsMobile
'
;
import
getNetworkValidationActionText
from
'
lib/networks/getNetworkValidationActionText
'
;
import
getQueryParamString
from
'
lib/router/getQueryParamString
'
;
import
BlockCeloEpochTag
from
'
ui/block/BlockCeloEpochTag
'
;
import
BlockDetails
from
'
ui/block/BlockDetails
'
;
import
BlockEpochRewards
from
'
ui/block/BlockEpochRewards
'
;
import
BlockWithdrawals
from
'
ui/block/BlockWithdrawals
'
;
...
...
@@ -24,9 +23,7 @@ import useBlockTxsQuery from 'ui/block/useBlockTxsQuery';
import
useBlockWithdrawalsQuery
from
'
ui/block/useBlockWithdrawalsQuery
'
;
import
TextAd
from
'
ui/shared/ad/TextAd
'
;
import
ServiceDegradationWarning
from
'
ui/shared/alerts/ServiceDegradationWarning
'
;
import
Tag
from
'
ui/shared/chakra/Tag
'
;
import
AddressEntity
from
'
ui/shared/entities/address/AddressEntity
'
;
import
LinkInternal
from
'
ui/shared/links/LinkInternal
'
;
import
NetworkExplorers
from
'
ui/shared/NetworkExplorers
'
;
import
PageTitle
from
'
ui/shared/Page/PageTitle
'
;
import
Pagination
from
'
ui/shared/pagination/Pagination
'
;
...
...
@@ -149,36 +146,6 @@ const BlockPageContent = () => {
return `
Block
#
$
{
blockQuery
.
data
?.
height
}
`;
}
})();
const contentAfter = (() => {
if (!blockQuery.data?.celo) {
return null;
}
if (!blockQuery.data.celo.is_epoch_block) {
const celoConfig = config.features.celo;
const epochBlockNumber = celoConfig.isEnabled && celoConfig.L2UpgradeBlock && blockQuery.data.height <= celoConfig.L2UpgradeBlock ?
blockQuery.data.celo.epoch_number * celoConfig.BLOCKS_PER_EPOCH :
undefined;
const tag = <Tag colorScheme={ epochBlockNumber ? 'gray-blue' : 'gray' }>Epoch #{ blockQuery.data.celo.epoch_number }</Tag>;
const content = epochBlockNumber ? (
<LinkInternal href={ route({ pathname: '/block/[height_or_hash]', query: { height_or_hash: String(epochBlockNumber) } }) }>
{ tag }
</LinkInternal>
) : tag;
return (
<Tooltip label="Displays the epoch this block belongs to before the epoch is finalized" maxW="280px" textAlign="center">
{ content }
</Tooltip>
);
}
return (
<Tooltip label="Displays the epoch finalized by this block" maxW="280px" textAlign="center">
<Tag bgColor="celo" color="blackAlpha.800">Finalized epoch #{ blockQuery.data.celo.epoch_number }</Tag>
</Tooltip>
);
})();
const titleSecondRow = (
<>
{ !config.UI.views.block.hiddenFields?.miner && blockQuery.data?.miner && (
...
...
@@ -206,7 +173,7 @@ const BlockPageContent = () => {
<PageTitle
title={ title }
backLink={ backLink }
contentAfter={
contentAfter
}
contentAfter={
<BlockCeloEpochTag blockQuery={ blockQuery }/>
}
secondRow={ titleSecondRow }
isLoading={ blockQuery.isPlaceholderData }
/>
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment