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

UI: Header component #13

Merged
merged 25 commits into from
Jan 25, 2024
Merged

UI: Header component #13

merged 25 commits into from
Jan 25, 2024

Conversation

kpyszkowski
Copy link
Contributor

@kpyszkowski kpyszkowski commented Dec 1, 2023

Ref: #2
Depends on: #12

This pull request introduces:

  • Logo component:
    localhost_3000_tBTC_mint_deposit_0x8571957df26d4c2f6e6e147d57d3eed76a0801c6edd45a01d706a442c1398a17 (1)

  • Header component:

    Desktop
    Tablet
    Mobile
  • SelectWallet component redesign:
    wynikowy_obraz

Additional changes:

  • Button component theme adjustments
  • Modal component theme adjustments

Note: Since this PR introduces changes widely used in the project eg. Modal or Button changes it's recommended to review it and merge primarily.

Rendered component in `App.tsx` entrypoint
Defined children components that composes Header's structure as separate
components for improved readability and ease of future code maintanace.

Left two TODOs:
 - it would be appropriate to utilise the fonts used in the project
 - it's unclear what is the BTC balance displayed in header from, for
   now it's mock value
Adjusted component's spacing accordingly to designs
Fixed spacings according to designs, fixed NavigationMenu container tag
to be semantically correct - div to ul
Added theme tokens
Customized `Button` and `Alert` themes, modified `DotsLoadingIndicator`
component.
Added control buttons: `AccountButton` and `NetworkButton`
@kpyszkowski kpyszkowski mentioned this pull request Jan 8, 2024
Completed TODO to read token balance from user wallet data.
Copy link
Contributor

@michalsmiarowski michalsmiarowski left a comment

Choose a reason for hiding this comment

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

Left some comments to look at before the merge, but overall good job 🔥

.env.example Outdated Show resolved Hide resolved
src/components/Logo/Logo.tsx Outdated Show resolved Hide resolved
src/components/Logo/Logo.tsx Outdated Show resolved Hide resolved
src/components/Logo/Logo.tsx Outdated Show resolved Hide resolved
@@ -0,0 +1 @@
export { default as Logo } from "./Logo"
Copy link
Contributor

Choose a reason for hiding this comment

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

Non-blocking:

If you agree with the above and remove the default import, then we could just:

Suggested change
export { default as Logo } from "./Logo"
import * from "./Header"

This would be helpful in the case where we would want to export LogoProps - we would only had to add export to the interface and it would be exported automatically from src/components/Logo

Copy link
Contributor Author

@kpyszkowski kpyszkowski Jan 22, 2024

Choose a reason for hiding this comment

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

I agree, but it breaks the overall idea of encapsulation and namespacing. The wildcard asterisk is in fact everything but that everything is undisclosed. The idea is to treat the index file as a "registry" of exported entities you can read through and have a clear view of the components' namespace at a first glance.
I added additional export declarations.

Ref commit: b9ed545

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 it was my mistake here, because we actually set the name of the default export to Logo. Still, I've mentioned that this could be better (although I admit, it's actually not) in case we would want to export LogoProps, but we don't need to export it right now.

I would propose to not export types if it's not necessary, and we don't use HeaderProps and LogoProps outside of the component. What do you think about that?

If you agree then we should remove the changes from b9ed545.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Reverted

Ref commit: 3b161e4

As a side note: exporting props type definition might be useful. In my opinion better approach would be to always export it instead of exporting on demand - just for consistency. Nevertheless the rules and guidelines of structuring the project are not formally standardized in any way so currently it's a matter of preference. I don't stickle against reverting changes at the moment. If we were to define such standards I would opt for my point of view, just for consistency as I said.

src/theme/index.ts Outdated Show resolved Hide resolved
@@ -1,5 +1,4 @@
import { extendTheme } from "@chakra-ui/react"
import { mode } from "@chakra-ui/theme-tools"
import { defaultTheme } from "@threshold-network/components"
Copy link
Contributor

Choose a reason for hiding this comment

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

Non-blocking:

This should be addressedi na separate PR, but ideally we should not use @threshold-network/components in this repo as teh designs are not related to threshold dashboard at all 😉 Just pointing that out to not forget about it and I want to know if you agree.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Correct. I agree. We just have to consider whether it's worth the effort if we want to start a completely new project anyway. I leave the decision up to you 🙇🏼

Copy link
Contributor

Choose a reason for hiding this comment

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

Probably not. We can always return to this issue if it turn out that we will continue from this codebase.

Comment on lines +30 to +31
color: "#66FFB6",
bg: "#1E1E1E",
Copy link
Contributor

Choose a reason for hiding this comment

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

Non-blocking but something to discuss in the future:

Ideally, we should put all the colors in the theme and name it. But I think this should be also specified in the designs.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Definitely. But I have no idea how to name/structure it. It's difficult to use incremental pattern here. Do you have any ideas?

src/theme/Alert.ts Show resolved Hide resolved
Copy link
Contributor Author

@kpyszkowski kpyszkowski left a comment

Choose a reason for hiding this comment

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

Addressed comments.

.env.example Outdated Show resolved Hide resolved
export function NavigationMenu(props: NavigationMenuProps) {
const { items } = props
return (
<Flex as={List} alignSelf={"stretch"} ml={146 - 20} mr={"auto"}>
Copy link
Contributor Author

@kpyszkowski kpyszkowski Jan 22, 2024

Choose a reason for hiding this comment

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

It should be 142 - 20. Fixed.
As you can see on screenshot I added horizontal padding for NavigationItems to make it more accessible - easier to click by enlarging the area. To keep it pixel perfect the margin between Logo and NavigationMenu must be reduced by the item padding so spacing is now 122px of menu margin + 20px of item padding which results as 142px as it states in designs.
image

I've added comment to explain the math behind the operation.
Ref commit: 3c9f8aa

src/components/Header/Header.children.tsx Outdated Show resolved Hide resolved
import { Logo } from "../Logo"
import { NavigationMenu, UserPanel } from "./Header.children"

// TODO: Load new fonts
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 think it's reasonable to do it in separate PR to prevent blocking this PR.
I wasn't able to make it - not sure how Chakra theming works in terms of font setting.
https://discord.com/channels/893441201628405760/1181551917332185148/1181634992409944204

src/components/Header/Header.tsx Outdated Show resolved Hide resolved
src/theme/Alert.ts Show resolved Hide resolved
Comment on lines +30 to +31
color: "#66FFB6",
bg: "#1E1E1E",
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Definitely. But I have no idea how to name/structure it. It's difficult to use incremental pattern here. Do you have any ideas?

src/theme/index.ts Outdated Show resolved Hide resolved
@@ -1,5 +1,4 @@
import { extendTheme } from "@chakra-ui/react"
import { mode } from "@chakra-ui/theme-tools"
import { defaultTheme } from "@threshold-network/components"
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Correct. I agree. We just have to consider whether it's worth the effort if we want to start a completely new project anyway. I leave the decision up to you 🙇🏼

Implemented responsive Navigation menu with toggleable drawer menu,
backdrop and animations. Maximum width of the drawer is `sm` breakpoint.
The chain indicator is hidden for mobile, it appears when `md`
breakpoint is passed. Added alternative smaller variant of logo size.
Also excluded logo from blurred backdrops so now it goes on top
remaining visible. It's a catchy detail reminding user what application
is used.
After adding responsive menu the .children file became lengthy. I
decided to restructure the namespace dividing components that form the
`Header` component into separate files.
Copy link
Contributor

@michalsmiarowski michalsmiarowski left a comment

Choose a reason for hiding this comment

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

Left some comments to look at before the merge

Comment on lines 63 to 65
stroke-width={1}
stroke-linecap="round"
stroke-linejoin="round"
Copy link
Contributor

Choose a reason for hiding this comment

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

Should be:

Suggested change
stroke-width={1}
stroke-linecap="round"
stroke-linejoin="round"
strokeWidth={1}
strokeLinecap="round"
strokeLinejoin="round"

The actual implementation produces warnings in the console.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ref commit: 7bb9859

@@ -1,5 +1,4 @@
import { extendTheme } from "@chakra-ui/react"
import { mode } from "@chakra-ui/theme-tools"
import { defaultTheme } from "@threshold-network/components"
Copy link
Contributor

Choose a reason for hiding this comment

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

Probably not. We can always return to this issue if it turn out that we will continue from this codebase.

Copy link
Contributor Author

@kpyszkowski kpyszkowski left a comment

Choose a reason for hiding this comment

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

Addressed comments

Comment on lines 63 to 65
stroke-width={1}
stroke-linecap="round"
stroke-linejoin="round"
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ref commit: 7bb9859

import { Logo } from "../Logo"
import { NavigationMenu, UserPanel } from "./Header.children"

// TODO: Load new fonts
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Already applied font changes. Ref PR: #30

@@ -0,0 +1 @@
export { default as Logo } from "./Logo"
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Reverted

Ref commit: 3b161e4

As a side note: exporting props type definition might be useful. In my opinion better approach would be to always export it instead of exporting on demand - just for consistency. Nevertheless the rules and guidelines of structuring the project are not formally standardized in any way so currently it's a matter of preference. I don't stickle against reverting changes at the moment. If we were to define such standards I would opt for my point of view, just for consistency as I said.

Copy link
Contributor

@michalsmiarowski michalsmiarowski left a comment

Choose a reason for hiding this comment

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

LGTM 🔥

@michalsmiarowski michalsmiarowski merged commit 3db2d75 into main Jan 25, 2024
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants