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

Dashboard: PageLayout component #409

Merged
merged 11 commits into from
May 15, 2024
Merged

Dashboard: PageLayout component #409

merged 11 commits into from
May 15, 2024

Conversation

kpyszkowski
Copy link
Contributor

@kpyszkowski kpyszkowski commented May 9, 2024

Ref: #396

Goal:

To implement PageLayout component

Features:

  • responsive with alternative layouts for smaller viewports

Copy link

netlify bot commented May 9, 2024

Deploy Preview for acre-dapp-testnet ready!

Name Link
🔨 Latest commit b11367c
🔍 Latest deploy log https://app.netlify.com/sites/acre-dapp-testnet/deploys/6643727f0fc89c00086a7c72
😎 Deploy Preview https://deploy-preview-409--acre-dapp-testnet.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

Copy link
Contributor

@r-czajkowski r-czajkowski left a comment

Choose a reason for hiding this comment

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

Left a few comments to take a look before the merge.

dapp/src/pages/OverviewPage/PageLayout/PageLayout.tsx Outdated Show resolved Hide resolved
Comment on lines 7 to 8
leftSidebar: React.ReactNode
rightSidebar: React.ReactNode
Copy link
Contributor

@r-czajkowski r-czajkowski May 9, 2024

Choose a reason for hiding this comment

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

I'm not a fan of props like this. Do we need these props? Since we are going to only use this layout in the OverviewPage I think we can render it directly and there is no need to pass them as props. Eg.

<Grid ...>
 <Box> {children} </Box>
 <PageLaypuSideBar>
   <SideBarComponent1 />
 </PageLayoutSideBar>
<PageLaypuSideBar>
   <SideBarComponent2 />
 </PageLayoutSideBar>
</Grid>

If we want to follow your approach, I suggest splitting them into even smaller components.

PageLayoutWrapper => Grid
PageLayoutMainContent => Box + children
PageLayoutSideBar => VStack

And then in OverviewPage:

<PageLayoutWrapper>
 <PageLayoutMainContent>
   Hello World
 </PageLayoutMainContent>
 <PageLayoutSideBar>
   Hello
 </PageLayoutSideBar>
<PageLayoutSideBar>
  World
</PageLayoutSideBar>
</PageLayoutWrapper>

Copy link
Contributor Author

@kpyszkowski kpyszkowski May 9, 2024

Choose a reason for hiding this comment

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

With such approach you allow to render something else than expected in page layout which can break the layout. Render props is a useful pattern to ensure content to be rendered in specific place.

Wouldn't like to change it.

Copy link
Contributor

Choose a reason for hiding this comment

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

I agree with Rafał here. I feel that we are unnecessarily complicating this layout. As he mentioned we can render it directly in DashboardPage. It is a simple layout with three columns. Additionally, I feel that we should not use the word sidebar here. Sidebars are used more to display various types of supplementary information for users. What I mean by that is that when I look at the leftSidebar, I have a navigation bar popping up on the left side in my mind. But this may be my personal feelings.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

unnecessarily complicating this layout

What is complicated in a property which receives JSX that is rendered in a particular place?
The purpose of layout is to lay specific content out in specific place. By allowing PageLayout to render just children so literally anything - it will no longer be a layout component - it will be a dummy wrapper.

should not use the word sidebar here

Agree, PageLayoutAside works here better.

Copy link
Contributor

@r-czajkowski r-czajkowski May 10, 2024

Choose a reason for hiding this comment

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

What is complicated in a property which receives JSX that is rendered in a particular place?

IMO in the layout components props like left*/right*/bottom* etc. are misleading because it's not true for mobile-first approach. We do not render these components on the left or right but both on the bottom. If we render this layout directly in the DashboardPage/OverviewPage we can understand from the code what is displayed, where and when. Of course, there are cases where this makes sense, but I don't think that's the case here.

With such approach you allow to render something else than expected in page layout which can break the layout.

This is more of an advantage than a disadvantage as it gives us flexibility if this is to be a reusable component 😄.

By allowing PageLayout to render just children so literally anything - it will no longer be a layout component - it will be a dummy wrapper.

Why? It forces us to use a specific grid layout. You exactly do the same thing in PageLayoutSidebar. Unless I misunderstood something.

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: a533fbb

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.

Replied to comments

dapp/src/pages/OverviewPage/PageLayout/PageLayout.tsx Outdated Show resolved Hide resolved
Comment on lines 7 to 8
leftSidebar: React.ReactNode
rightSidebar: React.ReactNode
Copy link
Contributor Author

@kpyszkowski kpyszkowski May 9, 2024

Choose a reason for hiding this comment

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

With such approach you allow to render something else than expected in page layout which can break the layout. Render props is a useful pattern to ensure content to be rendered in specific place.

Wouldn't like to change it.

Copy link
Contributor

@kkosiorowska kkosiorowska left a comment

Choose a reason for hiding this comment

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

It seems that the layout is not correct. We should have 3 columns in which the 3rd column should be left empty. Also, the component with the position should be in the middle column.

Screenshot 2024-05-10 at 14 04 52

Comment on lines 7 to 8
leftSidebar: React.ReactNode
rightSidebar: React.ReactNode
Copy link
Contributor

Choose a reason for hiding this comment

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

I agree with Rafał here. I feel that we are unnecessarily complicating this layout. As he mentioned we can render it directly in DashboardPage. It is a simple layout with three columns. Additionally, I feel that we should not use the word sidebar here. Sidebars are used more to display various types of supplementary information for users. What I mean by that is that when I look at the leftSidebar, I have a navigation bar popping up on the left side in my mind. But this may be my personal feelings.

dapp/src/pages/DashboardPage/index.tsx Outdated Show resolved Hide resolved
dapp/src/pages/DashboardPage/PageLayout/PageLayout.tsx Outdated Show resolved Hide resolved
@kpyszkowski
Copy link
Contributor Author

kpyszkowski commented May 10, 2024

It seems that the layout is not correct. We should have 3 columns in which the 3rd column should be left empty. Also, the component with the position should be in the middle column.

I prepared alternative variants for smaller viewports basing on widths from designs. On smaller screens the viewport is too narrow do display 3 columns side by side.
We can move breakpoints to change layout later than currently.

Moved breakpoints

@kkosiorowska
Copy link
Contributor

I prepared alternative variants for smaller viewports basing on widths from designs. On smaller screens the viewport is too narrow do display 3 columns side by side.
We can move breakpoints to change layout later than currently.

Oh now I see it. 🤔 The two columns are displayed when I use my laptop screen, not an external monitor. It seems to me that most users will use the app on a laptop. Could we adapt the layout to also display 3 columns for a bit larger laptops?

@kpyszkowski
Copy link
Contributor Author

Oh now I see it. 🤔 The two columns are displayed when I use my laptop screen, not an external monitor. It seems to me that most users will use the app on a laptop. Could we adapt the layout to also display 3 columns for a bit larger laptops?

Ref commit: 2a72fc3

Copy link
Contributor

@r-czajkowski r-czajkowski left a comment

Choose a reason for hiding this comment

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

🔥

Copy link
Contributor

@kkosiorowska kkosiorowska left a comment

Choose a reason for hiding this comment

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

Looks great! 🚀

@kkosiorowska kkosiorowska merged commit e6f4ec3 into main May 15, 2024
25 checks passed
@kkosiorowska kkosiorowska deleted the dashboard/page-layout branch May 15, 2024 05:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants