Skip to content

Commit 15ef6c1

Browse files
authored
chore: add legacy switch to menu (#2967)
1 parent 0c86c54 commit 15ef6c1

6 files changed

Lines changed: 53 additions & 11 deletions

File tree

src/components/MarketSwitcher.tsx

Lines changed: 44 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import {
1010
InputAdornment,
1111
Popover,
1212
SvgIcon,
13+
Switch,
1314
TextField,
1415
Tooltip,
1516
Typography,
@@ -185,6 +186,7 @@ const getMarketOrder = (marketId: CustomMarket): number => {
185186
export const MarketSwitcher = () => {
186187
const [anchorEl, setAnchorEl] = useState<HTMLElement | null>(null);
187188
const [searchQuery, setSearchQuery] = useState('');
189+
const [showLegacy, setShowLegacy] = useState(false);
188190
const searchRef = useRef<HTMLInputElement>(null);
189191
const open = Boolean(anchorEl);
190192

@@ -489,8 +491,13 @@ export const MarketSwitcher = () => {
489491
/>
490492
</Box>
491493

492-
{/* Scrollable content */}
493-
<Box sx={{ overflowY: 'auto', flex: 1, pb: 1 }}>
494+
{/* Content (scrolls on mobile, extends on desktop) */}
495+
<Box
496+
sx={{
497+
pb: 1,
498+
...(mobile && { overflowY: 'auto', flex: 1 }),
499+
}}
500+
>
494501
{/* Favourites */}
495502
{pinned.length > 0 && (
496503
<Box>
@@ -520,7 +527,9 @@ export const MarketSwitcher = () => {
520527
<Box sx={{ display: 'flex', flexWrap: 'wrap', px: 1.5 }}>
521528
{ethereum.map((id) => renderGridItem(id, mobile))}
522529
</Box>
523-
<Divider sx={{ my: 1 }} />
530+
{(other.length > 0 || l2.length > 0 || (showLegacy && legacy.length > 0)) && (
531+
<Divider sx={{ my: 1 }} />
532+
)}
524533
</Box>
525534
)}
526535

@@ -531,7 +540,7 @@ export const MarketSwitcher = () => {
531540
<Box sx={{ display: 'flex', flexWrap: 'wrap', px: 1.5 }}>
532541
{other.map((id) => renderGridItem(id, mobile))}
533542
</Box>
534-
<Divider sx={{ my: 1 }} />
543+
{(l2.length > 0 || (showLegacy && legacy.length > 0)) && <Divider sx={{ my: 1 }} />}
535544
</Box>
536545
)}
537546

@@ -542,12 +551,12 @@ export const MarketSwitcher = () => {
542551
<Box sx={{ display: 'flex', flexWrap: 'wrap', px: 1.5 }}>
543552
{l2.map((id) => renderGridItem(id, mobile))}
544553
</Box>
545-
<Divider sx={{ my: 1 }} />
554+
{showLegacy && legacy.length > 0 && <Divider sx={{ my: 1 }} />}
546555
</Box>
547556
)}
548557

549558
{/* Legacy */}
550-
{legacy.length > 0 && (
559+
{showLegacy && legacy.length > 0 && (
551560
<Box>
552561
{sectionHeader(<Trans>Legacy</Trans>)}
553562
<Box sx={{ display: 'flex', flexWrap: 'wrap', px: 1.5 }}>
@@ -565,6 +574,35 @@ export const MarketSwitcher = () => {
565574
</Box>
566575
)}
567576
</Box>
577+
578+
{/* Legacy markets toggle */}
579+
<Box
580+
sx={{
581+
borderTop: '1px solid',
582+
borderColor: 'divider',
583+
px: '24px',
584+
py: 1,
585+
display: 'flex',
586+
alignItems: 'center',
587+
gap: 1,
588+
}}
589+
>
590+
<Typography
591+
sx={{
592+
fontSize: '14px',
593+
fontWeight: 500,
594+
letterSpacing: '0.15px',
595+
color: 'text.secondary',
596+
}}
597+
>
598+
<Trans>Show legacy markets</Trans>
599+
</Typography>
600+
<Switch
601+
checked={showLegacy}
602+
onChange={(e) => setShowLegacy(e.target.checked)}
603+
inputProps={{ 'aria-label': t`Show legacy markets` }}
604+
/>
605+
</Box>
568606
</>
569607
);
570608

@@ -722,7 +760,6 @@ export const MarketSwitcher = () => {
722760
elevation: 0,
723761
sx: {
724762
width: 535,
725-
maxHeight: 520,
726763
overflow: 'hidden',
727764
display: 'flex',
728765
flexDirection: 'column',

src/locales/el/messages.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/locales/en/messages.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/locales/en/messages.po

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4216,6 +4216,11 @@ msgstr "Isolated Debt Ceiling"
42164216
msgid "Protocol supply cap is at 100% for this asset. Further supply unavailable."
42174217
msgstr "Protocol supply cap is at 100% for this asset. Further supply unavailable."
42184218

4219+
#: src/components/MarketSwitcher.tsx
4220+
#: src/components/MarketSwitcher.tsx
4221+
msgid "Show legacy markets"
4222+
msgstr "Show legacy markets"
4223+
42194224
#: src/layouts/SupportModal.tsx
42204225
msgid "Submission did not work, please try again later or contact wecare@avara.xyz"
42214226
msgstr "Submission did not work, please try again later or contact wecare@avara.xyz"

src/locales/es/messages.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/locales/fr/messages.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)