Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve header 10 #598

Merged
merged 3 commits into from
Jun 2, 2022
Merged

Improve header 10 #598

merged 3 commits into from
Jun 2, 2022

Conversation

fairlighteth
Copy link
Contributor

Summary

  • Part of a waterfall PR, the final one being Header/Menu improvement (waterfall PR FINAL)  #596
  • General styling
  • Defines a general constant for the main menu content in mainMenu.ts. A single file which can be used to define the main menu as a while.
  • Define a const getMainMenu structure with conditional logic supporting the mainMenu.ts constant data structure.
  • Added a util function toggleBodyClass.ts to toggle the document.body class, with the class provided as an argument. Used to toggle the 'noScroll` class whenever an overlay (like the main menu on mobile) is active.

@fairlighteth fairlighteth requested review from a team May 30, 2022 15:42
@github-actions
Copy link
Contributor

CLA Assistant Lite All Contributors have signed the CLA.

@github-actions
Copy link
Contributor

  • 🔭 GP Swap: CoW Protocol v2 Swap UI

}, [isOrdersPanelOpen, isMobileMenuOpen, isUpToLarge])

const getMainMenu = useMemo(
() =>
MAIN_MENU.map(({ title, url, externalURL, items }: MAIN_MENU_TYPE, index) =>
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm sure @anxolin will love this part 😅

Anyway, would you be able to simplify this a bit?
Maybe use intermediate components or callbacks to reduce a bit the conditional chaining

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@alfetopito If we can simplify it further, that'd be great. Would any of you mind checking PR #596 (the current last one) and suggest how to further simplify? I know I did some changes up to the last PR.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, this is way too complex...

we can break it up a bit into smaller pieces. A map inside another map and with all these ternary operators are big red 🚩

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll try to break it down into smaller functions 👍🏼

* Move URLS to an ENUM

* Fix enum issue.

* Styling and route fixes.

* Styling.

* Styling.

* Header/Menu improvement (waterfall PR FINAL)  (#596)

* Styling.

* Styling footer and bridge banner.

* Improve header 13 (#610)

* Fix network selector position.

* Fix exports/imports for network selector.

* Only open ordersPanel if account is true.
@fairlighteth fairlighteth merged commit ba65966 into improve-header-9 Jun 2, 2022
@github-actions github-actions bot locked and limited conversation to collaborators Jun 2, 2022
@alfetopito alfetopito deleted the improve-header-10 branch June 3, 2022 07:41
Copy link
Contributor

@anxolin anxolin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lots of things in this PR :)

@@ -48,7 +49,7 @@ function RequestCancellationModal(props: RequestCancellationModalProps): JSX.Ele
<p>
This means that a solver might already have included the order in a solution even if this cancellation
is successful. Read more in the{' '}
<a target="_blank" href="/#/faq/trading#can-i-cancel-an-order">
<a target="_blank" rel="noreferrer" href={`${Routes.FAQ_TRADING}#can-i-cancel-an-order`}>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we usually create the links using or <ExternalLink

is not part of this PR, but just curious if we know why this is like this?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah would need to change for sure. In this case I had simply changed the URL but should use the component 👍🏼

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just tested this one out when the cancellation modal is open:

  • using the component it opens the page below, which is not great.
  • using the component I tried not to specify the root domain, but the URL gets malformed: http://localhost:3000/faq/trading#/can-i-cancel-an-order?chain=rinkeby

thinking to leave as is for now in this iteration

}, [isOrdersPanelOpen, isMobileMenuOpen, isUpToLarge])

const getMainMenu = useMemo(
() =>
MAIN_MENU.map(({ title, url, externalURL, items }: MAIN_MENU_TYPE, index) =>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, this is way too complex...

we can break it up a bit into smaller pieces. A map inside another map and with all these ternary operators are big red 🚩

import IMAGE_SLICER from 'assets/cow-swap/ninja-cow.png'
import IMAGE_GAME from 'assets/cow-swap/game.gif'

export interface MAIN_MENU_TYPE {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if these constants should be instead near the menu component, instead of in the general constants

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In this case the icons are specific to the menu tree structure, which comes from the mainMenu types. So my thinking is it should be closely tied to the menu structure. WDYT?

@@ -0,0 +1,24 @@
// ENUM with routes
export enum Routes {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@fairlighteth this I like 👍
we should make sure the all our links start to use this enums. Maybe we can even create a Link which only accepts this enum as the path parameter

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍🏼

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants