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

Header/Menu improvement #607

Merged
merged 14 commits into from
Jun 14, 2022
Merged

Header/Menu improvement #607

merged 14 commits into from
Jun 14, 2022

Conversation

fairlighteth
Copy link
Contributor

Summary

@fairlighteth fairlighteth requested review from a team May 31, 2022 08:31
@github-actions
Copy link
Contributor

github-actions bot commented May 31, 2022

CLA Assistant Lite:
Thank you for your submission, we really appreciate it. Like many open-source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution. You can sign the CLA by just posting a Pull Request Comment same as the below format.


I have read the CLA Document and I hereby sign the CLA


You can retrigger the CLA Action by commenting recheckcla in this Pull Request

@github-actions
Copy link
Contributor

  • 🔭 GP Swap: CoW Protocol v2 Swap UI

Copy link
Contributor

@nenadV91 nenadV91 left a comment

Choose a reason for hiding this comment

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

Code wise LGTM. I just want to point out one UI issue I've noticed, if this is fixed in some of the following PR's please ignore this
Screenshot from 2022-05-31 14-27-01
Screenshot from 2022-05-31 14-27-47

* Move onclick for balance + wallet

* Improve header 3 (#605)

* Rename /profile to /account

* Improve header 4 (#604)

* Switch to custom MenuDropdown compontent and create a POC.

* Improve header 5 (#603)

* Improve FAQ text

* Improve header 6 (#602)

* connect button styling

* Further flyout menu styling

* Improve header 7 (#601)

* Further flyout menu styling

* Uniform menu items styling

* Move styled components to styled

* Add hamburger icon with animation component.

* Improve header 8 (#600)

* Add mediaQuery hook

* Improve header 9 (#599)

* Progress mobile responsive menu

* Progress mobile responsive menu

* Improve header 10 (#598)

* Move to helper function

* Optimise menu code

* Improve header 11 (#597)

* 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.
import styled, { css } from 'styled-components/macro'

const Wrapper = styled.div<{ isMobileMenuOpen: boolean; height?: number; width?: number; lineSize?: number }>`
z-index: 102;
Copy link
Contributor

Choose a reason for hiding this comment

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

102 😬😬😬

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 I know...I'd want to tackle the z-index thing in a separate PR. I think moving it to a const file, and then defining some general levels would be better.

margin: 0 6px 0 16px;
position: relative;
width: ${({ width }) => (width ? width + 'px' : '34px')};
height: ${({ height }) => (height ? height + 'px' : '18px')};
Copy link
Contributor

Choose a reason for hiding this comment

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

In these kinds of props i prefer setting the default in the function param destructuring like:

width: ${({ width = 18 }) => `${width}px`};

It just looks cleaner and is less code

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ah nice, of course this is way cleaner setting the default like that!

span {
background-color: ${({ theme }) => theme.text1};
border-radius: 3px;
height: ${({ lineSize }) => (lineSize ? lineSize + 'px' : '2px')};
Copy link
Contributor

Choose a reason for hiding this comment

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

I won't mention all of these instances but could also be replaced here


export default function MobileMenuIcon({ isMobileMenuOpen, width, height, lineSize, onClick }: IconProps) {
return (
<Wrapper isMobileMenuOpen={isMobileMenuOpen} width={width} height={height} lineSize={lineSize} onClick={onClick}>
Copy link
Contributor

Choose a reason for hiding this comment

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

Since all the prop names are the same you can just not destructure the props in the function signature and pass them to the component like <Component {...params} />

export function Menu({ title, children }: MenuProps) {
const isUpToLarge = useMediaQuery(upToLarge)
const [showMenu, setShowMenu] = useState(false)
const handleOnClick = () => isUpToLarge && setShowMenu(!showMenu)
Copy link
Contributor

Choose a reason for hiding this comment

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

SetStates allow passing a callback as a param so it's safer to do:

setShowMenu(menuState => !menuState)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Like this ?
const handleOnClick = () => isUpToLarge && setShowMenu((showMenu) => !showMenu)

Why is it safer?

@@ -0,0 +1,24 @@
// ENUM with routes
Copy link
Contributor

Choose a reason for hiding this comment

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

Woo nice good call!

@@ -0,0 +1,7 @@
export const toggleBodyClass = (className: string, isAdd: boolean) => {
Copy link
Contributor

Choose a reason for hiding this comment

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

toggle in the name implies inverting the current state so the isAdd param is redundant

this function can just be written as

export const toggleBodyClass = (className: string) => {
  if (!document.body.classList.contains(className)) {
    document.body.classList.add(className)
  } else {
    document.body.classList.remove(className)
  }
}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Makes sense yes. Actually I created also specific addBodyClass and removeBodyClass util functions, as that seems sometimes more convenient.

Copy link
Contributor

@W3stside W3stside left a comment

Choose a reason for hiding this comment

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

approving with minor comments

* Updating util function

* change onClick onTouchStart
@elena-zh
Copy link

elena-zh commented Jun 7, 2022

Hey @fairlighteth , great job!

Some issues I faced during testing:

  1. I noticed that some links remain to be underlined when navigate to another FAQ section:
    image
  2. Seems like 'Protocol' section is missing in the FAQ now: 'Token' section is opened when press on the 'Protocol'
    image

3 FAQ overview link is always highlighted, even if another section is selected
image

  1. WDYT about auto-closing dropdowns after selecting this or that option? Currently, dropdown remains opened unless I remove a mouse from it

  2. I can't open a menu in a tablet/mobile view (Win10+Chrome, FF, Brave)
    image

  3. Maybe we should display feedback window above the feedback icon, not from the right side? WDYT?
    image
    At least, it will not overlap Connect wallet button

  4. Footer in a tablet view hides contracts/block/gas price info
    image

  5. Connect to wallet button has a light boarder in the light mode
    image

  6. The issue with FAQ mobile sections' alignment 'Protocol' FAQ section is expanded more than the rest sections in a mobile view #486 is also reproducible in this PR

  7. It is almost impossible to scroll down the menu in iPhone with iOS 15.3

menu.mp4
  1. Account Affiliate section elements exceed the section's height in iPhone 12 mini (when a user is not connected)
    image
    in Android 'Connect wallet' button is shifted to the right

  2. Maybe just like a reminder: the issue with the feedback window for iOS wallets integration browsers is still broken ([iOS] - enable Feedback modal in imToken integrated browser #165)

  3. And as an enhancement I'd like to propose to show COW and ETH balances at the top of the menu (however, do not have a strong opinion on this)
    image

Thanks!

@fairlighteth
Copy link
Contributor Author

  1. Yes, this is to indicate the current active page in the sub-menu. In this case I will change it to a different color instead

Screen Shot 2022-06-07 at 12 44 14

2 and 3: Addressed this and point 1 now to better handle this.

  1. Yes makes sense. I now made sure that on click of any menu element is closes the dropdown menu. On click anywhere outside the menu > it closes as well. Also instead of mouse-over, I made it to open the dropdown on click of the parent element (with the arrow).

Addressed these in #650

@fairlighteth
Copy link
Contributor Author

  1. I think what happens is that the onClick events aren't refreshed when you change viewport. Can you try again by refreshing the page? If it does work then we need to address that issue.

@elena-zh
Copy link

elena-zh commented Jun 7, 2022

  1. I think what happens is that the onClick events aren't refreshed when you change viewport. Can you try again by refreshing the page? If it does work then we need to address that issue.

@fairlighteth , refreshing does not help :(
https://watch.screencastify.com/v/uuW5RvCrudYQR9kWMA81

fairlighteth and others added 5 commits June 7, 2022 16:23
* Fix iOS scrolling attempt and improve events

* Fix iOS scrolling attempt and improve events
* Resolve FAQ exact links and styling submenu.

* Unify FAQ menu links by importing them.

* close dropdowns on click and on click outside.
* Re-position Appzi modal on mobile.

* FAQ adjust modal

* FAQ adjust modal

* try catching Appzi root ID.

* try catching Appzi root ID.

* try catching Appzi root ID.

* try catching Appzi root ID.

* try catching Appzi root ID.

* fix account margin

* uncomment

* simple overrides

* restore original code
@elena-zh
Copy link

elena-zh commented Jun 9, 2022

Hey @fairlighteth , all issues are mostly fixed!
As I promised, I will create new tasks for unfixed issues, but I'd like to draw your attention to this one (I think, it is an important one): swap form boarders are missing in a mobile view:
no boarders on a reduced screen

  • there are no margins on small screen resolutions:
    no margins

Could you please take a look at it?

Thanks!

@fairlighteth
Copy link
Contributor Author

@elena-zh Thanks for checking again. The borders were intentionally removed to allow for more horizontal space. By doing that, the container/content area has more available width to display content/numbers.

@elena-zh
Copy link

elena-zh commented Jun 9, 2022

@fairlighteth , got it, thanks!
But maybe then we should remove the bottom boarder, WDYT?
image

@fairlighteth
Copy link
Contributor Author

@elena-zh Actually I would leave that one in place.

@elena-zh
Copy link

elena-zh commented Jun 9, 2022

@fairlighteth , I have created:
#668 : new issue
#669 : issue related to Account page Connect button

Btw, I'm still not sure if it is OK that we have a white boarder for the Connect button in the light mode?
image

Btw, where is Terms and Conditions page now?

Thanks

@fairlighteth
Copy link
Contributor Author

@elena-zh

  • Indeed forgot to add the terms and conditions -> add terms conditions #670
  • When merging the Accounts page PR at some point, I will also check the 'view orders' menu item.
  • In regard to the white border on the button, personally I think this is fine (intentional that is).

@elena-zh
Copy link

Hey @fairlighteth ,
after the final round of testing I have reported some new/missing issues:

Besides, I still vote for fixing #669 in the near future.

But for now, the current PR is approved.

Thanks!

@fairlighteth fairlighteth merged commit ffe64f9 into develop Jun 14, 2022
@github-actions github-actions bot locked and limited conversation to collaborators Jun 14, 2022
@alfetopito alfetopito deleted the improve-header-1 branch June 17, 2022 13:25
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.

5 participants