Skip to content

Commit

Permalink
Add coming soon caption for layer on mobile
Browse files Browse the repository at this point in the history
  • Loading branch information
lubej committed Jun 19, 2023
1 parent e673965 commit f334f45
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 8 deletions.
1 change: 1 addition & 0 deletions .changelog/482.feature.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Mobile ParaTime picker
27 changes: 19 additions & 8 deletions src/app/components/ParaTimePicker/LayerMenu.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { FC, useState } from 'react'
import { FC, PropsWithChildren, useState } from 'react'
import { useTranslation } from 'react-i18next'
import Typography from '@mui/material/Typography'
import KeyboardArrowRightIcon from '@mui/icons-material/KeyboardArrowRight'
Expand All @@ -12,13 +12,24 @@ import { getLayerLabels } from '../../utils/content'
import { RouteUtils } from '../../utils/route-utils'
import { Network } from '../../../types/network'
import { orderByLayer } from '../../../types/layers'
import { useScreenSize } from '../../hooks/useScreensize'

type BaseLayerMenuItemProps = {
divider: boolean
layer: Layer
}

const LayerMenuItemCaption: FC<PropsWithChildren> = ({ children }) => (
<Typography
component="span"
sx={{ fontSize: '10px', fontStyle: 'italic', color: COLORS.grayMedium, ml: 2 }}
>
{children}
</Typography>
)

export const DisabledLayerMenuItem: FC<BaseLayerMenuItemProps> = ({ divider, layer }) => {
const { isTablet } = useScreenSize()
const { t } = useTranslation()
const labels = getLayerLabels(t)

Expand All @@ -27,7 +38,10 @@ export const DisabledLayerMenuItem: FC<BaseLayerMenuItemProps> = ({ divider, lay
{/* Div is needed because we need an element with enabled pointer-events to make Tooltip work */}
<div>
<MenuItem disabled divider={divider}>
<ListItemText>{labels[layer]}</ListItemText>
<ListItemText>
{labels[layer]}
{isTablet && <LayerMenuItemCaption>{t('paraTimePicker.comingSoon')}</LayerMenuItemCaption>}
</ListItemText>
</MenuItem>
</div>
</Tooltip>
Expand Down Expand Up @@ -70,12 +84,9 @@ export const LayerMenuItem: FC<LayerMenuItemProps> = ({
>
<ListItemText>
{labels[layer]}
<Typography
component="span"
sx={{ fontSize: '10px', fontStyle: 'italic', color: COLORS.grayMedium, ml: 2 }}
>
{selectedNetwork === network && activeLayer === layer && t('paraTimePicker.selected')}
</Typography>
{selectedNetwork === network && activeLayer === layer && (
<LayerMenuItemCaption>{t('paraTimePicker.selected')}</LayerMenuItemCaption>
)}
</ListItemText>
{layer === selectedLayer && <KeyboardArrowRightIcon />}
</MenuItem>
Expand Down
1 change: 1 addition & 0 deletions src/locales/en/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,7 @@
"paraTimePicker": {
"chainId": "Chain ID:",
"decimal": "Decimal: {{ id }}",
"comingSoon": "(coming soon)",
"hex": "Hex: {{ id }}",
"less": "Show Less",
"more": "Show More",
Expand Down

0 comments on commit f334f45

Please sign in to comment.