-
Notifications
You must be signed in to change notification settings - Fork 2
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
Conversation
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`
Completed TODO to read token balance from user wallet data.
There was a problem hiding this 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 🔥
@@ -0,0 +1 @@ | |||
export { default as Logo } from "./Logo" |
There was a problem hiding this comment.
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:
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
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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/components/Modal/SelectWalletModal/components/WalletConnectionModalBase.tsx
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" |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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 🙇🏼
There was a problem hiding this comment.
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.
color: "#66FFB6", | ||
bg: "#1E1E1E", |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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?
Added comment to explain the value
`asLink` to `asLinkToHomepage`
Refactored component definitions for `Header` and `Logo` components.
`border` => `whiteAlpha`
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Addressed comments.
export function NavigationMenu(props: NavigationMenuProps) { | ||
const { items } = props | ||
return ( | ||
<Flex as={List} alignSelf={"stretch"} ml={146 - 20} mr={"auto"}> |
There was a problem hiding this comment.
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.
I've added comment to explain the math behind the operation.
Ref commit: 3c9f8aa
import { Logo } from "../Logo" | ||
import { NavigationMenu, UserPanel } from "./Header.children" | ||
|
||
// TODO: Load new fonts |
There was a problem hiding this comment.
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/Modal/SelectWalletModal/components/WalletConnectionModalBase.tsx
Outdated
Show resolved
Hide resolved
color: "#66FFB6", | ||
bg: "#1E1E1E", |
There was a problem hiding this comment.
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?
@@ -1,5 +1,4 @@ | |||
import { extendTheme } from "@chakra-ui/react" | |||
import { mode } from "@chakra-ui/theme-tools" | |||
import { defaultTheme } from "@threshold-network/components" |
There was a problem hiding this comment.
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.
There was a problem hiding this 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
stroke-width={1} | ||
stroke-linecap="round" | ||
stroke-linejoin="round" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should be:
stroke-width={1} | |
stroke-linecap="round" | |
stroke-linejoin="round" | |
strokeWidth={1} | |
strokeLinecap="round" | |
strokeLinejoin="round" |
The actual implementation produces warnings in the console.
There was a problem hiding this comment.
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" |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Addressed comments
stroke-width={1} | ||
stroke-linecap="round" | ||
stroke-linejoin="round" |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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" |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM 🔥
Ref: #2
Depends on: #12This pull request introduces:
Logo
component:Header
component:Desktop
Tablet
Mobile
SelectWallet
component redesign:Additional changes:
Button
component theme adjustmentsModal
component theme adjustmentsNote: Since this PR introduces changes widely used in the project eg.
Modal
orButton
changes it's recommended to review it and merge primarily.