Skip to content

Commit

Permalink
Mobile temp proposal
Browse files Browse the repository at this point in the history
  • Loading branch information
buberdds committed Jun 23, 2023
1 parent 8707f6f commit 74948e5
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 72 deletions.
21 changes: 2 additions & 19 deletions src/app/components/PageLayout/Header.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { FC, useEffect, useRef } from 'react'
import { FC } from 'react'
import AppBar from '@mui/material/AppBar'
import Grid from '@mui/material/Unstable_Grid2'
import useScrollTrigger from '@mui/material/useScrollTrigger'
Expand All @@ -8,35 +8,18 @@ import { NetworkSelector } from './NetworkSelector'
import Box from '@mui/material/Box'
import { useScopeParam } from '../../hooks/useScopeParam'
import { useScreenSize } from '../../hooks/useScreensize'
import useResizeObserver from 'use-resize-observer'

export const Header: FC = () => {
const theme = useTheme()
const { isMobile, isTablet } = useScreenSize()
const { isMobile } = useScreenSize()
const scope = useScopeParam()
const scrollTrigger = useScrollTrigger({
disableHysteresis: true,
threshold: 0,
})
const headerRef = useRef<HTMLDivElement | null>(null)

const { height: headerHeight } = useResizeObserver<Element>({
ref: headerRef,
})

useEffect(() => {
if (!isTablet) {
return
}

if (headerRef.current !== null) {
document.body.style.setProperty('--app-header-height', `${headerHeight?.toFixed(2) || 0}px`)
}
}, [isTablet, headerHeight])

return (
<AppBar
ref={headerRef}
position="sticky"
sx={{
transitionProperty: 'background-color',
Expand Down
26 changes: 4 additions & 22 deletions src/app/components/PageLayout/index.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { FC, PropsWithChildren, ReactNode, useEffect, useRef } from 'react'
import { FC, PropsWithChildren, ReactNode } from 'react'
import { Header } from './Header'
import { Footer } from './Footer'
import Box from '@mui/material/Box'
Expand All @@ -10,7 +10,6 @@ import { NetworkOfflineBanner, RuntimeOfflineBanner } from '../OfflineBanner'
import { Search } from '../Search'
import { useIsApiReachable } from '../OfflineBanner/hook'
import { Network } from '../../../types/network'
import useResizeObserver from 'use-resize-observer'

interface PageLayoutProps {
mobileFooterAction?: ReactNode
Expand All @@ -25,29 +24,12 @@ export const PageLayout: FC<PropsWithChildren<PageLayoutProps>> = ({ children, m
const { isMobile, isTablet } = useScreenSize()
const scope = useScopeParam()
const isApiReachable = useIsApiReachable(scope?.network || Network.mainnet).reachable
const bannersRef = useRef<HTMLDivElement | null>(null)

const { height: bannersHeight } = useResizeObserver<Element>({
ref: bannersRef,
})

useEffect(() => {
if (!isTablet) {
return
}

if (bannersRef.current !== null) {
document.body.style.setProperty('--app-banners-height', `${bannersHeight?.toFixed(2) || 0}px`)
}
}, [isTablet, bannersHeight])

return (
<>
<Box ref={bannersRef}>
<BuildBanner />
<NetworkOfflineBanner />
{scope?.valid && <RuntimeOfflineBanner />}
</Box>
<BuildBanner />
<NetworkOfflineBanner />
{scope?.valid && <RuntimeOfflineBanner />}
<Box
sx={{
minHeight: '100vh',
Expand Down
22 changes: 7 additions & 15 deletions src/app/components/ParaTimePicker/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { FC, useState } from 'react'
import { useTranslation } from 'react-i18next'
import Box from '@mui/material/Box'
import Button from '@mui/material/Button'
import Drawer, { drawerClasses } from '@mui/material/Drawer'
import Drawer from '@mui/material/Drawer'
import Divider from '@mui/material/Divider'
import Grid from '@mui/material/Unstable_Grid2'
import { Logotype } from '../PageLayout/Logotype'
Expand All @@ -24,16 +24,10 @@ type ParaTimePickerProps = {
open: boolean
}

const ParaTimePickerDrawer = styled(Drawer)(() => ({
[`.${drawerClasses.root}`]: {
height: '100vh',
},
}))

export const ParaTimePicker: FC<ParaTimePickerProps> = ({ onClose, onConfirm, open }) => (
<ParaTimePickerDrawer anchor="top" open={open} onClose={onClose}>
<Drawer anchor="top" open={open} onClose={onClose}>
<ParaTimePickerContent onClose={onClose} onConfirm={onConfirm} />
</ParaTimePickerDrawer>
</Drawer>
)

const StyledParaTimePickerContent = styled(Box)(({ theme }) => ({
Expand Down Expand Up @@ -83,7 +77,7 @@ enum ParaTimePickerTabletStep {
}

const ParaTimePickerContent: FC<ParaTimePickerContentProps> = ({ onClose, onConfirm }) => {
const { isTablet } = useScreenSize()
const { isMobile, isTablet } = useScreenSize()
const { t } = useTranslation()
const { network, layer } = useRequiredScopeParam()
const [selectedLayer, setSelectedLayer] = useState<Layer>(layer)
Expand All @@ -99,11 +93,9 @@ const ParaTimePickerContent: FC<ParaTimePickerContentProps> = ({ onClose, onConf

return (
<StyledParaTimePickerContent>
{!isTablet && (
<Box sx={{ mb: 5, color: 'red', position: 'relative' }}>
<Logotype color={COLORS.brandExtraDark} showText={true} />
</Box>
)}
<Box sx={{ mb: isTablet ? 0 : 5, color: 'red', position: 'relative' }}>
<Logotype color={COLORS.brandExtraDark} showText={!isMobile} />
</Box>
{isTablet && (
<>
<TabletActionBar>
Expand Down
8 changes: 2 additions & 6 deletions src/styles/index.css
Original file line number Diff line number Diff line change
@@ -1,11 +1,6 @@
@import '../../node_modules/@fontsource-variable/figtree/index.css';
@import '../../node_modules/@fontsource-variable/roboto-mono/index.css';

:root {
--app-header-height: 0px;
--app-banners-height: 0px;
}

html {
scroll-behavior: smooth;
}
Expand All @@ -16,7 +11,8 @@ html {
font-style: normal;
font-display: swap;
font-weight: 100 700;
src: url('../../node_modules/@fontsource-variable/figtree/files/figtree-latin-wght-normal.woff2') format('woff2');
src: url('../../node_modules/@fontsource-variable/figtree/files/figtree-latin-wght-normal.woff2')
format('woff2');
unicode-range: U+2026;
}

Expand Down
11 changes: 1 addition & 10 deletions src/styles/theme/defaultTheme.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import { inputBaseClasses } from '@mui/material/InputBase'
import { inputAdornmentClasses } from '@mui/material/InputAdornment'
import { tabClasses } from '@mui/material/Tab'
import { menuItemClasses } from '@mui/material/MenuItem'
import { modalClasses } from '@mui/material/Modal'

declare module '@mui/material/styles' {
interface Palette {
Expand Down Expand Up @@ -504,17 +503,9 @@ export const defaultTheme = createTheme({
borderRadius: '0 0 12px 12px',
padding: `${theme.spacing(4)} 5%`,
}),
modal: ({ theme }) => ({
[theme.breakpoints.down('md')]: {
[`& .${modalClasses.backdrop}`]: {
background: 'transparent',
},
},
}),
paper: ({ theme }) => ({
[theme.breakpoints.down('md')]: {
height: `calc(100vh - var(--app-header-height) - var(--app-banners-height))`,
top: `calc(var(--app-header-height) + var(--app-banners-height))`,
height: '100vh',
},
}),
},
Expand Down

0 comments on commit 74948e5

Please sign in to comment.