Skip to content

Commit 4a24587

Browse files
committed
refactor(v3-uplift): shared market switcher on staking, flush page titles, themed analytics banner
- Staking header now renders the shared `MarketSwitcher` via new context-aware props (`hideTitleChrome`, `titlePrefix`) instead of the stale bespoke fork; delete `UmbrellaMarketSwitcher`. "Staking" is part of the clickable trigger. - Navbar Staking menu: drop the hardcoded Paper border (use the standardized menu surface); hold the hover/underline while open via `[aria-expanded]` in navLinkSx. - Remove leftover title left-margins (orphaned by commented-out logos) on the Staking, Safety Module, and Governance headers so titles sit flush-left. - Rebuild AnalyticsBanner with theme-native MUI: bg-2 + shadow-stroke-2/shadow-high surface, outlined/contained buttons, h5 title + fg tokens; drop the react-cookie-consent rendering (consent still runs on the store + localStorage). Also bundled (entangled in-progress work from parallel sessions): P3 color tokenization across headers/theme (ChainAvailabilityText, SGhoHeader, TopBarNotify, figmaColors, theme.tsx), the StakingMenu route-active class, and the governance ProposalListHeader size="small".
1 parent 7f8cad3 commit 4a24587

15 files changed

Lines changed: 134 additions & 524 deletions
Lines changed: 53 additions & 92 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
1-
import { Box, Typography, useMediaQuery, useTheme } from '@mui/material';
1+
import { Box, Button, Typography, useMediaQuery, useTheme } from '@mui/material';
22
import * as Sentry from '@sentry/nextjs';
33
import React, { useEffect, useState } from 'react';
4-
import { CookieConsent as AnalyticsConsentBanner } from 'react-cookie-consent';
54
import { Link } from 'src/components/primitives/Link';
65
import { CONSENT_KEY } from 'src/store/analyticsSlice';
76
import { useRootStore } from 'src/store/root';
@@ -30,8 +29,6 @@ export default function AnalyticsBanner() {
3029
return () => clearTimeout(timerId);
3130
}, []);
3231

33-
const theme = useTheme();
34-
3532
const { breakpoints } = useTheme();
3633
const isMobile = useMediaQuery(breakpoints.down('sm'));
3734

@@ -52,98 +49,62 @@ export default function AnalyticsBanner() {
5249
const hasUserMadeChoice =
5350
typeof window !== 'undefined' && localStorage.getItem(CONSENT_KEY) !== null;
5451

55-
// Note: If they have already chosen don't show again unless configured from footer
56-
if (hasUserMadeChoice) return null;
52+
// Hide once the user has made a choice. Reopening from the footer clears the stored choice and
53+
// reopens analyticsConfigOpen, which brings the banner back.
54+
if (hasUserMadeChoice || !analyticsConfigOpen) return null;
5755

5856
return (
59-
<>
60-
<AnalyticsConsentBanner
61-
buttonText={<Typography>Allow analytics </Typography>}
62-
declineButtonText={<Typography>Opt-out</Typography>}
63-
disableStyles={true}
64-
visible={analyticsConfigOpen ? 'show' : 'hidden'}
65-
flipButtons
66-
style={{
67-
background: figVars['surface-elevated'],
68-
bottom: isMobile ? '24px' : '24px',
69-
right: isMobile ? '50%' : '24px',
70-
left: isMobile ? '50%' : 'auto',
71-
position: 'fixed',
72-
width: '400px',
73-
// height: '184px',
74-
gap: '16px',
75-
display: 'flex',
76-
flexDirection: 'column',
77-
flexFlow: 'column',
78-
justifyContent: 'space-between',
79-
alignItems: 'center',
80-
color: figVars['fg-1'],
81-
marginBottom: '16px',
82-
fontSize: '14px',
83-
lineHeight: '20.02px',
84-
padding: '16px 16px',
85-
zIndex: 100,
86-
borderRadius: '12px',
87-
border: '0.5px solid rgba(235, 235, 239, 0.42)',
88-
boxShadow: '0px 0px 2px rgba(0, 0, 0, 0.2), 0px 2px 10px rgba(0, 0, 0, 0.1)',
89-
transition: 'transform 0.5s ease-out', // Add this
90-
91-
transform: bannerVisible
92-
? isMobile
93-
? 'translateX(-50%)'
94-
: 'none'
95-
: 'translateX(100%) translateY(100%)',
96-
}}
97-
buttonStyle={{
98-
background: theme.palette.mode === 'dark' ? '#F7F7F9' : '#383D51',
99-
color: theme.palette.mode === 'dark' ? '#383D51' : '#F7F7F9',
100-
101-
fontSize: '14px',
102-
borderRadius: '4px',
103-
margin: '0px',
104-
border: '1px solid #000',
105-
width: '172px',
106-
height: '36px',
107-
fontWeight: '700',
108-
cursor: 'pointer',
109-
}}
110-
declineButtonStyle={{
111-
// background: '#F7F7F9',
112-
background: theme.palette.mode === 'dark' ? '#383D51' : '#F7F7F9',
113-
color: theme.palette.mode === 'dark' ? '#EAEBEF' : '#383D51',
114-
115-
fontFamily: 'Inter',
116-
fontWeight: '500',
117-
lineHeight: '24px',
118-
fontSize: '14px',
119-
borderRadius: '4px',
120-
margin: '10px',
121-
// padding: '10px 20px',
122-
border: `1px solid ${theme.palette.mode === 'dark' ? '#383D51' : '#EAEBEF'}`,
123-
width: '172px',
124-
height: '36px',
125-
// padding: '0px',
126-
cursor: 'pointer',
127-
}}
128-
enableDeclineButton
129-
onDecline={() => {
130-
optOutAnalytics();
131-
}}
132-
onAccept={() => {
133-
optInAnalytics();
134-
}}
135-
cookieName={CONSENT_KEY}
136-
>
137-
<Box>
57+
<Box
58+
sx={{
59+
position: 'fixed',
60+
zIndex: 100,
61+
bottom: '24px',
62+
...(isMobile ? { left: '50%' } : { right: '24px' }),
63+
width: '400px',
64+
maxWidth: 'calc(100vw - 48px)',
65+
p: '1.25rem',
66+
display: 'flex',
67+
flexDirection: 'column',
68+
gap: '1.25rem',
69+
borderRadius: '0.625rem',
70+
backgroundColor: figVars['bg-2'],
71+
boxShadow: `0 0 0 1px ${figVars['shadow-stroke-2']}, 0 6px 32px 0 ${figVars['shadow-high']}`,
72+
transition: 'transform 0.5s ease-out',
73+
transform: bannerVisible
74+
? isMobile
75+
? 'translateX(-50%)'
76+
: 'none'
77+
: 'translateX(100%) translateY(100%)',
78+
}}
79+
>
80+
<Box sx={{ display: 'flex', flexDirection: 'column', gap: '0.5rem' }}>
81+
<Typography variant="h5" sx={{ color: 'fg-1' }}>
82+
We value your privacy
83+
</Typography>
84+
<Typography
85+
sx={{ color: 'fg-3', fontSize: '0.875rem', fontWeight: 400, lineHeight: '1.1875rem' }}
86+
>
13887
We may employ on-the-spot tracking techniques during your browsing session to collect data
13988
on your interactions, preferences, and behaviour. This data helps us personalise your
140-
experience and improve our services. See our
141-
<Link sx={{ color: 'info.main' }} href="https://aave.com/privacy-policy/">
142-
{' '}
143-
Privacy Policy.
89+
experience and improve our services. See our{' '}
90+
<Link
91+
href="https://aave.com/privacy-policy/"
92+
sx={{ textDecoration: 'underline', color: 'fg-3' }}
93+
>
94+
Privacy Policy
14495
</Link>
145-
</Box>
146-
</AnalyticsConsentBanner>
147-
</>
96+
.
97+
</Typography>
98+
</Box>
99+
100+
<Box sx={{ display: 'flex', gap: '1rem' }}>
101+
<Button variant="outlined" onClick={() => optOutAnalytics()} sx={{ flex: 1 }}>
102+
Opt-out
103+
</Button>
104+
<Button variant="contained" onClick={() => optInAnalytics()} sx={{ flex: 1 }}>
105+
Allow analytics
106+
</Button>
107+
</Box>
108+
</Box>
148109
);
149110
}

src/components/ChainAvailabilityText.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ export const ChainAvailabilityText: React.FC<ChainAvailabilityTextProps> = ({
2525

2626
return (
2727
<Box sx={{ display: 'flex', alignItems: 'center', ...wrapperSx }}>
28-
<Typography variant="subheader2" sx={{ mr: 2, color: '#C0CBF6' }}>
28+
<Typography variant="subheader2" sx={{ mr: 2, color: 'purple-1' }}>
2929
<Trans>Available on</Trans>
3030
</Typography>
3131
<Box
@@ -36,7 +36,7 @@ export const ChainAvailabilityText: React.FC<ChainAvailabilityTextProps> = ({
3636
>
3737
<img src={network.networkLogoPath} height="100%" width="100%" alt="Ethereum Mainnet" />
3838
</Box>
39-
<Typography variant="subheader2" sx={{ ml: 1, color: '#C0CBF6' }}>
39+
<Typography variant="subheader2" sx={{ ml: 1, color: 'purple-1' }}>
4040
{networkToTextMapper(chainId, network)}
4141
</Typography>
4242
</Box>

src/components/MarketSwitcher.tsx

Lines changed: 31 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,23 @@ const getMarketOrder = (marketId: CustomMarket): number => {
189189
const AAVE_PRO_URL = 'https://pro.aave.com/';
190190
const AAVE_PRO_LOGO = '/icons/markets/aave-pro.png';
191191

192-
export const MarketSwitcher = () => {
192+
interface MarketSwitcherProps {
193+
/**
194+
* Hide the page-title-only chrome (the "Instance"/"Market" suffix and the market
195+
* description blurb) when the switcher sits next to an existing page title, e.g. the
196+
* Staking header. Default false = full title treatment (homepage).
197+
*/
198+
hideTitleChrome?: boolean;
199+
/**
200+
* Optional label rendered inside the trigger, before the market logo and at the same
201+
* size as the market name, so it reads and clicks as one unit (e.g. "Staking" on the
202+
* Staking header). Prefer this over a sibling <Typography> next to <MarketSwitcher />,
203+
* which would leave the label outside the clickable/hoverable trigger.
204+
*/
205+
titlePrefix?: React.ReactNode;
206+
}
207+
208+
export const MarketSwitcher = ({ hideTitleChrome = false, titlePrefix }: MarketSwitcherProps) => {
193209
const [anchorEl, setAnchorEl] = useState<HTMLElement | null>(null);
194210
const [searchQuery, setSearchQuery] = useState('');
195211
const [showLegacy, setShowLegacy] = useState(false);
@@ -775,6 +791,14 @@ export const MarketSwitcher = () => {
775791
}}
776792
>
777793
<Box sx={{ display: 'flex', alignItems: 'center' }}>
794+
{titlePrefix && (
795+
<Typography
796+
variant={upToLG ? 'display1' : 'h1'}
797+
sx={{ fontSize: downToXSM ? '1.55rem' : undefined, color: 'fg-1', mr: 3 }}
798+
>
799+
{titlePrefix}
800+
</Typography>
801+
)}
778802
<MarketLogo
779803
size={upToLG ? 32 : 28}
780804
logo={currentLogo}
@@ -790,9 +814,11 @@ export const MarketSwitcher = () => {
790814
}}
791815
>
792816
{currentMarketNaming.name} {currentMarketData.isFork ? 'Fork' : ''}
793-
{upToLG && (currentMarket === 'proto_mainnet_v3' || currentMarket === 'proto_lido_v3')
794-
? 'Instance'
795-
: ' Market'}
817+
{!hideTitleChrome &&
818+
(upToLG &&
819+
(currentMarket === 'proto_mainnet_v3' || currentMarket === 'proto_lido_v3')
820+
? 'Instance'
821+
: ' Market')}
796822
</Typography>
797823
<Box sx={{ display: 'flex', alignItems: 'center' }}>
798824
{currentMarketData.v3 ? (
@@ -827,7 +853,7 @@ export const MarketSwitcher = () => {
827853
</Box>
828854
</Box>
829855

830-
{marketBlurbs[currentMarket] && (
856+
{!hideTitleChrome && marketBlurbs[currentMarket] && (
831857
<Typography
832858
sx={{
833859
color: 'fg-2',

src/layouts/TopBarNotify.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,8 @@ export default function TopBarNotify({ campaigns, routeCampaigns }: TopBarNotify
7979
}
8080
}, [currentCampaign, currentChainId]);
8181

82+
console.log('currentCampaign', currentCampaign);
83+
8284
// If no campaign is configured for the current network, don't show anything
8385
if (!currentCampaign) {
8486
return null;

src/layouts/components/StakingMenu.tsx

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ import { Trans } from '@lingui/macro';
22
import { Button, SvgIcon, Typography } from '@mui/material';
33
import Menu from '@mui/material/Menu';
44
import MenuItem from '@mui/material/MenuItem';
5+
import { clsx } from 'clsx';
6+
import { useRouter } from 'next/router';
57
import React from 'react';
68
import { ChevronDownIcon } from 'src/components/icons/ChevronDownIcon';
79
import { useRootStore } from 'src/store/root';
@@ -18,6 +20,10 @@ interface StakingMenuProps {
1820

1921
export function StakingMenu({ isMobile = false, onClose }: StakingMenuProps) {
2022
const trackEvent = useRootStore((store) => store.trackEvent);
23+
const router = useRouter();
24+
// The trigger isn't a Link, so it never gets the route-aware `active` class on its own.
25+
// Mark it active when the current route is one of the menu's destinations.
26+
const isActive = router.pathname === ROUTES.staking || router.pathname === ROUTES.safetyModule;
2127

2228
const [anchorEl, setAnchorEl] = React.useState<Element | null>(null);
2329
const open = Boolean(anchorEl);
@@ -69,6 +75,7 @@ export function StakingMenu({ isMobile = false, onClose }: StakingMenuProps) {
6975
<Button
7076
aria-label="staking menu"
7177
id="staking-button"
78+
className={clsx({ active: isActive })}
7279
aria-controls={open ? 'staking-menu' : undefined}
7380
aria-expanded={open ? 'true' : undefined}
7481
aria-haspopup="true"
@@ -97,13 +104,6 @@ export function StakingMenu({ isMobile = false, onClose }: StakingMenuProps) {
97104
open={open}
98105
onClose={handleClose}
99106
keepMounted={true}
100-
sx={{
101-
'& .MuiPaper-root': {
102-
bgcolor: 'surface-elevated',
103-
border: '1px solid',
104-
borderColor: 'border-2',
105-
},
106-
}}
107107
>
108108
<MenuItem
109109
component={Link}

src/layouts/components/navLinkSx.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,12 @@ export const navLinkSx = (padding: string): SystemStyleObject<Theme> => ({
1515
'.active&': {
1616
color: figVars['fg-1'],
1717
},
18-
'&:hover': {
18+
// An open dropdown trigger ([aria-expanded="true"], e.g. the Staking menu) keeps the hovered look.
19+
'&:hover, &[aria-expanded="true"]': {
1920
backgroundColor: 'transparent',
2021
color: figVars['fg-1'],
2122
},
22-
'.active&:after, &:hover&:after': {
23+
'.active&:after, &:hover&:after, &[aria-expanded="true"]&:after': {
2324
transform: 'scaleX(1)',
2425
transformOrigin: 'bottom left',
2526
},

src/locales/en/messages.po

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1357,7 +1357,6 @@ msgstr "You have assets with zero LTV that are blocking this operation. Please w
13571357
#: src/modules/staking/SavingsGhoProgram.tsx
13581358
#: src/modules/umbrella/StakeCooldownModalContent.tsx
13591359
#: src/modules/umbrella/StakeCooldownModalContent.tsx
1360-
#: src/modules/umbrella/UmbrellaMarketSwitcher.tsx
13611360
msgid "{0}"
13621361
msgstr "{0}"
13631362

src/modules/governance/GovernanceTopPanel.tsx

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -51,16 +51,12 @@ export const GovernanceTopPanel = () => {
5151
<Box mb={4}>
5252
<ChainAvailabilityText wrapperSx={{ mb: 4 }} chainId={ChainId.mainnet} />
5353
<Box sx={{ display: 'flex', alignItems: 'center', mb: 4 }}>
54-
{/* <img src={`/aave.svg`} width="32px" height="32px" alt="" /> */}
55-
<Typography
56-
variant={downToXSM ? 'h2' : upToLG ? 'display1' : 'h1'}
57-
sx={{ ml: 2, mr: 3 }}
58-
>
54+
<Typography variant={downToXSM ? 'h2' : upToLG ? 'display1' : 'h1'}>
5955
<Trans>Aave Governance</Trans>
6056
</Typography>
6157
</Box>
6258

63-
<Typography sx={{ color: '#8E92A3', maxWidth: '824px' }}>
59+
<Typography sx={{ color: 'fg-3', maxWidth: '824px' }}>
6460
<Trans>
6561
Aave is a fully decentralized, community governed protocol by the AAVE token-holders.
6662
AAVE token-holders collectively discuss, propose, and vote on upgrades to the
@@ -70,7 +66,7 @@ export const GovernanceTopPanel = () => {
7066
<Link
7167
onClick={() => trackEvent(GENERAL.EXTERNAL_LINK, { Link: 'FAQ Docs Governance' })}
7268
href="https://aave.com/docs/ecosystem/governance"
73-
sx={{ textDecoration: 'underline', color: '#8E92A3' }}
69+
sx={{ textDecoration: 'underline', color: 'fg-3' }}
7470
>
7571
<Trans>documentation</Trans>
7672
</Link>

src/modules/governance/ProposalListHeader.tsx

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,13 @@ export const ProposalListHeaderDesktop: React.FC<ProposalListHeaderElementProps>
4040
<Typography>
4141
<Trans>Filter</Trans>
4242
</Typography>
43-
<Select id="filter" value={proposalFilter} sx={{ minWidth: 140 }} onChange={handleChange}>
43+
<Select
44+
id="filter"
45+
value={proposalFilter}
46+
sx={{ minWidth: 140 }}
47+
onChange={handleChange}
48+
size="small"
49+
>
4450
<MenuItem value="all">
4551
<Trans>All proposals</Trans>
4652
</MenuItem>
@@ -78,7 +84,13 @@ export const ProposalListHeaderMobile: React.FC<ProposalListHeaderElementProps>
7884
<Typography>
7985
<Trans>Filter</Trans>
8086
</Typography>
81-
<Select id="filter" value={proposalFilter} sx={{ minWidth: 140 }} onChange={handleChange}>
87+
<Select
88+
id="filter"
89+
value={proposalFilter}
90+
sx={{ minWidth: 140 }}
91+
onChange={handleChange}
92+
size="small"
93+
>
8294
<MenuItem value="all">
8395
<Trans>All proposals</Trans>
8496
</MenuItem>

src/modules/sGho/SGhoHeader.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ export const SGHOHeader: React.FC = () => {
6868
</Typography>
6969
</Box>
7070

71-
<Typography sx={{ color: '#8E92A3', maxWidth: '824px' }}>
71+
<Typography sx={{ color: 'fg-3', maxWidth: '824px' }}>
7272
<Trans>
7373
Deposit GHO into Savings GHO (sGHO) and earn{' '}
7474
<Box component="span" sx={{ color: '#338E3C', fontWeight: 'bold' }}>

0 commit comments

Comments
 (0)