From 363e4cfb113caf93bc09a75c02a73244fe93bac7 Mon Sep 17 00:00:00 2001 From: Woody <109973128+Woody810@users.noreply.github.com> Date: Fri, 1 Dec 2023 17:31:01 +0800 Subject: [PATCH] chore(Menu): Display NewTag in the externalLink (#8491) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ### 🤖[[deprecated]](https://githubnext.com/copilot-for-prs-sunset) Generated by Copilot at 9bc4021 ### Summary 🎨🐛🚀 Refactored the `DropdownMenu` component and fixed a bug in `packages/uikit`. > _The `DropdownMenu` was a mess_ > _With a tag that it failed to address_ > _So it got a refactor_ > _And a `Flex` benefactor_ > _Now it looks and behaves with finesse_ ### Walkthrough * Reorder imports alphabetically and move `LinkStatus` component up to match styles file ([link](https://github.com/pancakeswap/pancake-frontend/pull/8491/files?diff=unified&w=0#diff-d5748bbba35280005dd7f9dae278f09e2205045d50e8230a00c8f9fd24d73225L2-R4), [link](https://github.com/pancakeswap/pancake-frontend/pull/8491/files?diff=unified&w=0#diff-d5748bbba35280005dd7f9dae278f09e2205045d50e8230a00c8f9fd24d73225L12-R13)) * Wrap `MenuItemContent` in `Flex` component to align label and status horizontally and add closing tag ([link](https://github.com/pancakeswap/pancake-frontend/pull/8491/files?diff=unified&w=0#diff-d5748bbba35280005dd7f9dae278f09e2205045d50e8230a00c8f9fd24d73225L108-R108), [link](https://github.com/pancakeswap/pancake-frontend/pull/8491/files?diff=unified&w=0#diff-d5748bbba35280005dd7f9dae278f09e2205045d50e8230a00c8f9fd24d73225L115-R115)) * Replace `label` prop with `MenuItemContent` variable to reuse rendering logic ([link](https://github.com/pancakeswap/pancake-frontend/pull/8491/files?diff=unified&w=0#diff-d5748bbba35280005dd7f9dae278f09e2205045d50e8230a00c8f9fd24d73225L157-R157)) Before: ![image](https://github.com/pancakeswap/pancake-frontend/assets/109973128/9b459dfc-d83a-4440-ac26-c75f320b54d1) After: ![image](https://github.com/pancakeswap/pancake-frontend/assets/109973128/f1c1ef6a-721e-4e36-975b-1558a1726659) --------- Co-authored-by: Woody --- .../widgets/__snapshots__/menu.test.tsx.snap | 225 +++++++++++++----- .../components/DropdownMenu/DropdownMenu.tsx | 12 +- 2 files changed, 177 insertions(+), 60 deletions(-) diff --git a/packages/uikit/src/__tests__/widgets/__snapshots__/menu.test.tsx.snap b/packages/uikit/src/__tests__/widgets/__snapshots__/menu.test.tsx.snap index 545582bce9f80..df74992cfd750 100644 --- a/packages/uikit/src/__tests__/widgets/__snapshots__/menu.test.tsx.snap +++ b/packages/uikit/src/__tests__/widgets/__snapshots__/menu.test.tsx.snap @@ -1,4 +1,4 @@ -// Vitest Snapshot v1 +// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html exports[`renders correctly 1`] = ` @@ -889,7 +889,11 @@ exports[`renders correctly 1`] = ` class="c13 c14" href="/swap" > - Exchange + + Exchange + - Liquidity + + Liquidity + @@ -932,7 +940,11 @@ exports[`renders correctly 1`] = ` class="c13 c14" href="/earn" > - Earn + + Earn + - Yield Farms + + Yield Farms + - Syrup pools + + Syrup pools + @@ -985,7 +1005,11 @@ exports[`renders correctly 1`] = ` class="c13 c14" href="/" > - Win + + Win + - Predictions - LIVE + Predictions + + LIVE + @@ -1010,7 +1038,11 @@ exports[`renders correctly 1`] = ` class="c13 c14" href="/" > - Lottery + + Lottery + @@ -1053,7 +1085,11 @@ exports[`renders correctly 1`] = ` class="c13 c14" href="/" > - Info & Analytics + + Info & Analytics + - IFO Token Sales - SOON + IFO Token Sales + + SOON + @@ -1085,7 +1125,11 @@ exports[`renders correctly 1`] = ` class="c13 c14" href="/" > - NFT Collectibles + + NFT Collectibles + - Team Leaderboard + + Team Leaderboard + - Blog + + Blog + - Docs & Guides + + Docs & Guides + - Exchange + + Exchange + - Liquidity + + Liquidity + @@ -3883,7 +3952,11 @@ html[data-useragent*="TokenPocket_iOS"] .c1 { class="c15 c16" href="/earn" > - Earn + + Earn + - Yield Farms + + Yield Farms + - Syrup pools + + Syrup pools + @@ -3974,7 +4055,7 @@ html[data-useragent*="TokenPocket_iOS"] .c1 { @@ -3991,7 +4072,11 @@ html[data-useragent*="TokenPocket_iOS"] .c1 { class="c15 c16" href="/" > - Win + + Win + - Predictions - LIVE + Predictions + + LIVE + @@ -4016,7 +4105,11 @@ html[data-useragent*="TokenPocket_iOS"] .c1 { class="c15 c16" href="/" > - Lottery + + Lottery + @@ -4042,7 +4135,7 @@ html[data-useragent*="TokenPocket_iOS"] .c1 { class="c4 c5" > @@ -4068,7 +4161,7 @@ html[data-useragent*="TokenPocket_iOS"] .c1 { @@ -4085,7 +4178,11 @@ html[data-useragent*="TokenPocket_iOS"] .c1 { class="c15 c16" href="/" > - Info & Analytics + + Info & Analytics + - IFO Token Sales - SOON + IFO Token Sales + + SOON + @@ -4107,7 +4208,7 @@ html[data-useragent*="TokenPocket_iOS"] .c1 { class="c14" > - NFT Collectibles + + NFT Collectibles + - Team Leaderboard + + Team Leaderboard + - Blog + + Blog + - Docs & Guides + + Docs & Guides + > = ({ itemItem ) => { const MenuItemContent = ( - <> + {label} {status && ( {status.text} )} - > + ); const isActive = href === activeItem; return ( @@ -154,7 +154,7 @@ const DropdownMenu: React.FC> = ({ {...itemProps} > - {label} + {MenuItemContent}