Skip to content

Commit

Permalink
Merge pull request #383 from skalenetwork/add-pages-tooltips
Browse files Browse the repository at this point in the history
Add tooltips to the main pages
  • Loading branch information
dmytrotkk authored Sep 25, 2024
2 parents 8ee1aca + 22df1fd commit 8ed684d
Show file tree
Hide file tree
Showing 14 changed files with 276 additions and 63 deletions.
37 changes: 37 additions & 0 deletions src/App.scss
Original file line number Diff line number Diff line change
Expand Up @@ -389,6 +389,38 @@ body::-webkit-scrollbar {

}

.sk-icon-btn-small {
width: 34px;
height: 34px;

svg {
width: 18px;
height: 18px;
}
}

.sk-icon-btn-medium {
width: 40px;
height: 40px;

svg {
width: 24px;
height: 24px;
}
}


.sk-icon-btn-large {
width: 46px;
height: 46px;

svg {
width: 32px;
height: 32px;
}
}


.btn {
text-transform: none !important;
font-size: 0.8025rem !important;
Expand Down Expand Up @@ -1387,4 +1419,9 @@ input[type=number] {

.hidden {
display: none;
}

.MuiTooltip-tooltip {
font-size: 0.8rem !important;
padding: 8px 12px !important;
}
27 changes: 8 additions & 19 deletions src/components/HelpZen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,13 @@ import { Link } from 'react-router-dom'

import { useEffect, useState, type MouseEvent } from 'react'
import Box from '@mui/material/Box'
import Tooltip from '@mui/material/Tooltip'
import IconButton from '@mui/material/IconButton'
import Menu from '@mui/material/Menu'
import MenuItem from '@mui/material/MenuItem'
import QuestionMarkRoundedIcon from '@mui/icons-material/QuestionMarkRounded'
import HelpOutlineOutlinedIcon from '@mui/icons-material/HelpOutlineOutlined'
import MarkUnreadChatAltRoundedIcon from '@mui/icons-material/MarkUnreadChatAltRounded'
import { cls, styles, cmn } from '@skalenetwork/metaport'
import { cmn } from '@skalenetwork/metaport'
import SkIconBtn from './SkIconBth'

export default function HelpZen() {
const [anchorEl, setAnchorEl] = useState<null | HTMLElement>(null)
Expand Down Expand Up @@ -44,22 +43,12 @@ export default function HelpZen() {
className={cmn.mleft5}
sx={{ display: 'flex', alignItems: 'center', textAlign: 'center' }}
>
<Tooltip arrow title="Get help">
<IconButton
id="basic-button"
aria-controls={open ? 'basic-menu' : undefined}
aria-haspopup="true"
aria-expanded={open ? 'true' : undefined}
onClick={handleClick}
className={cls(styles.paperGrey, cmn.pPrim)}
style={{ width: '34px', height: '34px' }}
>
<QuestionMarkRoundedIcon
className={cls(cmn.pPrim)}
style={{ height: '15px', width: '15px' }}
/>
</IconButton>
</Tooltip>
<SkIconBtn
icon={QuestionMarkRoundedIcon}
onClick={handleClick}
size="small"
tooltipTitle="Get help"
/>
</Box>
<Menu
className="mp__moreMenu"
Expand Down
110 changes: 110 additions & 0 deletions src/components/SkIconBth.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
/**
* @license
* SKALE portal
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/

/**
* @file SkIconBth.tsx
* @copyright SKALE Labs 2024-Present
*/

import React, { useState, useCallback } from 'react'
import IconButton, { IconButtonProps } from '@mui/material/IconButton'
import Tooltip, { TooltipProps } from '@mui/material/Tooltip'
import { SvgIconProps } from '@mui/material/SvgIcon'
import { useTheme } from '@mui/material/styles'
import useMediaQuery from '@mui/material/useMediaQuery'
import { cls, styles, cmn } from '@skalenetwork/metaport'

type IconType = React.ComponentType<SvgIconProps>

interface SkIconBtnProps extends Omit<IconButtonProps, 'children'> {
icon: IconType
iconClassName?: string
tooltipTitle?: React.ReactNode
tooltipProps?: Partial<TooltipProps>
primary?: boolean
}

const SkIconBtn: React.FC<SkIconBtnProps> = ({
icon: Icon,
onClick,
className,
iconClassName,
size = 'medium',
tooltipTitle,
tooltipProps,
primary = true,
...props
}) => {
const [tooltipOpen, setTooltipOpen] = useState(false)
const theme = useTheme()
const isMobile = useMediaQuery(theme.breakpoints.down('sm'))

const handleTooltipToggle = useCallback(() => {
if (isMobile) {
setTooltipOpen((prevOpen) => !prevOpen)
}
}, [isMobile])

const handleClick = useCallback(
(event: React.MouseEvent<HTMLButtonElement>) => {
if (isMobile) {
handleTooltipToggle()
}
if (onClick) {
onClick(event)
}
},
[isMobile, onClick, handleTooltipToggle]
)

const button = (
<IconButton
onClick={handleClick}
className={cls(styles.paperGrey, 'sk-icon-btn', `sk-icon-btn-${size}`, className)}
size={size}
{...props}
>
<Icon
className={cls(
iconClassName,
[cmn.pPrim, primary],
[cmn.pSec, !primary],
'sk-icon-btn-img'
)}
/>
</IconButton>
)

if (tooltipTitle) {
return (
<Tooltip
title={tooltipTitle}
{...tooltipProps}
open={isMobile ? tooltipOpen : undefined}
onClose={handleTooltipToggle}
onOpen={handleTooltipToggle}
>
{button}
</Tooltip>
)
}

return button
}

export default SkIconBtn
43 changes: 43 additions & 0 deletions src/components/SkPageInfoIcon.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
/**
* @license
* SKALE portal
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/

/**
* @file SkPageInfoIcon.tsx
* @copyright SKALE Labs 2024-Present
*/

import React from 'react'
import InfoOutlinedIcon from '@mui/icons-material/InfoOutlined'
import SkIconBtn from './SkIconBth'

interface SkPageInfoIconProps {
meta_tag: any
}

const SkPageInfoIcon: React.FC<SkPageInfoIconProps> = ({ meta_tag }) => {
return (
<SkIconBtn
primary={false}
icon={InfoOutlinedIcon}
size="small"
tooltipTitle={meta_tag.help || meta_tag.description}
/>
)
}

export default SkPageInfoIcon
14 changes: 8 additions & 6 deletions src/components/chains/HubTile.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -73,12 +73,14 @@ export default function HubTile(props: {
<div
className={cls(cmn.flex, cmn.flexcv, cmn.flexg, cmn.mtop20, cmn.mbott20, cmn.mleft20)}
>
<ChainLogo
network={props.network}
chainName={props.schainName}
logos={MAINNET_CHAIN_LOGOS}
className={cls(styles.chainIconlg)}
/>
<div className={cls(styles.chainIconlg, cmn.flex, cmn.flexcv)}>
<ChainLogo
network={props.network}
chainName={props.schainName}
logos={MAINNET_CHAIN_LOGOS}
className="responsive-logo"
/>
</div>
<div
className={cls([cmn.mleft20, !props.isXs], [cmn.mleft10, props.isXs], cmn.flexg)}
>
Expand Down
13 changes: 9 additions & 4 deletions src/core/meta.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@ export const META_TAGS = {
},
bridge: {
title: 'SKALE Portal - Bridge Tokens',
description: 'Bridge tokens using SKALE Bridge - Zero Gas Fees between SKALE Chains.'
description: 'Bridge tokens using SKALE Bridge - Zero Gas Fees between SKALE Chains.',
help: 'Bridge tokens between Ethereum and SKALE chains with zero gas fees.'
},
history: {
title: 'SKALE Portal - Bridge History',
Expand All @@ -49,9 +50,9 @@ export const META_TAGS = {
description:
'Explore SKALE Hubs, AppChains, connect to SKALE Chains, get block explorer links, endpoints, linked tokens and verified contracts info.'
},
apps: {
title: 'SKALE Portal - Apps',
description: 'Apps on SKALE Network. Explore and interact with dApps on SKALE Network.'
ecosystem: {
title: 'SKALE Portal - Ecosystem',
description: 'Explore and interact with dApps on SKALE Network.'
},
faq: {
title: 'SKALE Portal - Bridge FAQ',
Expand All @@ -61,6 +62,10 @@ export const META_TAGS = {
title: 'SKALE Portal - Staking',
description: 'Delegate, review delegations and withdraw staking rewards'
},
validators: {
title: 'SKALE Portal - Validators',
description: 'List of validators on SKALE Network'
},
onramp: {
title: 'SKALE Portal - Onramp',
description: 'Purchase crypto directly on SKALE Europa Hub using the Transak onramp.'
Expand Down
4 changes: 3 additions & 1 deletion src/pages/Bridge.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ import BridgeBody from '../components/BridgeBody'
import { META_TAGS } from '../core/meta'
import Meson from '../components/Meson'
import { Button } from '@mui/material'
import SkPageInfoIcon from '../components/SkPageInfoIcon'

interface TokenParams {
keyname: string | null
Expand Down Expand Up @@ -177,12 +178,13 @@ export default function Bridge(props: { isXs: boolean; chainsMeta: types.ChainsM
<Link to="/bridge/history">
<Button
variant="contained"
className={cls('btnMd', styles.paperGrey, cmn.pPrim)}
className={cls('btnMd', styles.paperGrey, cmn.pPrim, cmn.mri10)}
startIcon={<HistoryIcon />}
>
History
</Button>
</Link>
<SkPageInfoIcon meta_tag={META_TAGS.bridge} />
</div>
</div>

Expand Down
15 changes: 9 additions & 6 deletions src/pages/Chains.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ import CategoryRoundedIcon from '@mui/icons-material/CategoryRounded'
import ChainsSection from '../components/chains/ChainsSection'
import { META_TAGS } from '../core/meta'
import { MAINNET_CHAIN_NAME } from '../core/constants'
import SkPageInfoIcon from '../components/SkPageInfoIcon'

export default function Chains(props: {
loadData: () => Promise<void>
Expand Down Expand Up @@ -92,13 +93,15 @@ export default function Chains(props: {
<meta property="og:description" content={META_TAGS.chains.description} />
</Helmet>
<Stack spacing={0}>
<div className={cls(cmn.flex)}>
<h2 className={cls(cmn.nom)}>SKALE Chains</h2>
<div className={cls(cmn.flex, cmn.flexcv)}>
<div className={cmn.flexg}>
<h2 className={cls(cmn.nom)}>SKALE Chains</h2>
<p className={cls(cmn.nom, cmn.p, cmn.p3, cmn.pSec)}>
Connect, get block explorer links and endpoints
</p>
</div>
<SkPageInfoIcon meta_tag={META_TAGS.chains} />
</div>
<p className={cls(cmn.nom, cmn.p, cmn.p3, cmn.pSec)}>
Connect, get block explorer links and endpoints
</p>

<ChainsSection
name="SKALE Hubs"
schains={props.schains.filter(
Expand Down
Loading

0 comments on commit 8ed684d

Please sign in to comment.