Skip to content

Commit ea3d4aa

Browse files
committed
fix(swap): mobile menu bar hide broken buttons (#6608)
1 parent dd05bb7 commit ea3d4aa

File tree

4 files changed

+44
-19
lines changed

4 files changed

+44
-19
lines changed

apps/cowswap-frontend/src/modules/application/containers/AppMenu/index.tsx

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { PropsWithChildren, ReactNode, useMemo } from 'react'
33
import { SUPPORTED_LOCALES } from '@cowprotocol/common-const'
44
import { useMediaQuery } from '@cowprotocol/common-hooks'
55
import { isInjectedWidget } from '@cowprotocol/common-utils'
6-
import { Color, Media, MenuBar } from '@cowprotocol/ui'
6+
import { Color, MenuBar } from '@cowprotocol/ui'
77
import { useWalletInfo } from '@cowprotocol/wallet'
88

99
import { useLingui } from '@lingui/react/macro'
@@ -19,6 +19,8 @@ import { useIsInternationalizationEnabled } from 'common/hooks/featureFlags/useI
1919
import { useCustomTheme } from 'common/hooks/useCustomTheme'
2020
import { useMenuItems } from 'common/hooks/useMenuItems'
2121

22+
import { HideMobile, isMobileQuery } from './styled'
23+
2224
import { NAV_ITEMS, PRODUCT_VARIANT } from '../App/menuConsts'
2325

2426
const LinkComponent = ({ href, children }: PropsWithChildren<{ href: string }>): ReactNode => {
@@ -41,7 +43,7 @@ export function AppMenu({ children }: AppMenuProps): ReactNode {
4143
const menuItems = useMenuItems()
4244
const [darkMode, toggleDarkMode] = useDarkModeManager()
4345
const { setLocale } = useUserLocaleManager()
44-
const isMobile = useMediaQuery(Media.upToMedium(false))
46+
const isMobile = useMediaQuery(isMobileQuery(false))
4547
const customTheme = useCustomTheme()
4648
const getTradeUrlParams = useGetTradeUrlParams()
4749
const { t } = useLingui()
@@ -108,7 +110,7 @@ export function AppMenu({ children }: AppMenuProps): ReactNode {
108110
id={APP_HEADER_ELEMENT_ID}
109111
languageNavItems={languageNavItems}
110112
navItems={navItems}
111-
persistentAdditionalContent={isMobile ? null : children} // This will stay at its original location
113+
persistentAdditionalContent={isMobile ? null : <HideMobile>{children}</HideMobile>} // This will stay at its original location
112114
productVariant={PRODUCT_VARIANT}
113115
settingsNavItems={settingsNavItems}
114116
showGlobalSettings
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import { Media } from '@cowprotocol/ui'
2+
3+
import styled from 'styled-components/macro'
4+
5+
export const isMobileQuery = Media.upToMedium
6+
7+
export const HideMobile = styled.div`
8+
${isMobileQuery(true)} {
9+
display: none;
10+
}
11+
`

libs/ui/src/pure/MenuBar/index.tsx

Lines changed: 19 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,8 @@ import {
4848
RightAligned,
4949
RootNavItem,
5050
StyledDropdownContentItem,
51+
HideMobile,
52+
isMobileQuery,
5153
} from './styled'
5254

5355
import { Media } from '../../consts'
@@ -933,7 +935,7 @@ export const MenuBar = (props: MenuBarProps) => {
933935
// eslint-disable-next-line @typescript-eslint/explicit-function-return-type
934936
const handleSettingsToggle = () => setIsSettingsOpen((prev) => !prev)
935937

936-
const isMobile = useMediaQuery(Media.upToLarge(false))
938+
const isMobile = useMediaQuery(isMobileQuery(false))
937939
const isMedium = useMediaQuery(Media.upToMedium(false))
938940

939941
useOnClickOutside([menuRef], () => setIsDaoOpen(false))
@@ -999,20 +1001,22 @@ export const MenuBar = (props: MenuBarProps) => {
9991001
<ProductLogo variant={productVariant} logoIconOnly={isMobile} height={30} href="/" theme={customTheme} />
10001002

10011003
{!isMobile && (
1002-
<NavItems ref={navItemsRef}>
1003-
{navItems.map((item, index) => (
1004-
<NavItem
1005-
key={index}
1006-
item={item}
1007-
LinkComponent={LinkComponent}
1008-
mobileMode={isMobile}
1009-
openDropdown={openDropdown}
1010-
closeDropdown={() => setOpenDropdown(null)}
1011-
setOpenDropdown={setOpenDropdown}
1012-
rootDomain={rootDomain}
1013-
/>
1014-
))}
1015-
</NavItems>
1004+
<HideMobile>
1005+
<NavItems ref={navItemsRef}>
1006+
{navItems.map((item, index) => (
1007+
<NavItem
1008+
key={index}
1009+
item={item}
1010+
LinkComponent={LinkComponent}
1011+
mobileMode={isMobile}
1012+
openDropdown={openDropdown}
1013+
closeDropdown={() => setOpenDropdown(null)}
1014+
setOpenDropdown={setOpenDropdown}
1015+
rootDomain={rootDomain}
1016+
/>
1017+
))}
1018+
</NavItems>
1019+
</HideMobile>
10161020
)}
10171021

10181022
<RightAligned mobileMode={isMedium} flexFlowMobile="row wrap">

libs/ui/src/pure/MenuBar/styled.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import styled, { css } from 'styled-components/macro'
22

3-
import { Font } from '../../consts'
3+
import { Font, Media } from '../../consts'
44
import { UI } from '../../enum'
55
import { CowSwapTheme } from '../../types'
66
import { ProductLogoWrapper } from '../ProductLogo'
@@ -769,3 +769,11 @@ export const GlobalSettingsButton = styled.button<{ mobileMode?: boolean }>`
769769
}
770770
}
771771
`
772+
773+
export const isMobileQuery = Media.upToLarge
774+
775+
export const HideMobile = styled.div`
776+
${isMobileQuery(true)} {
777+
display: none;
778+
}
779+
`

0 commit comments

Comments
 (0)