-
Notifications
You must be signed in to change notification settings - Fork 146
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
WIP - refactoring containers and header #5223
Conversation
93b2af1
to
f1f5a12
Compare
f1f5a12
to
b5d3bd7
Compare
> | ||
{homePageModalRoutes} | ||
</Route> | ||
<Route> |
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.
@kyranjamie I made a slight change here as a suggestion of an approach we could take. It would involve grouping the routes we use based on their use case which may be a good idea anyway but I'm not sure if it would lead to some duplication.
Before, all routes had the same route container. I've changed it to add another level so we have:
<Route>
<Route element={<Container />}>
// everything in the main extension
</Route>
// Other routes for popup windows e.g. Approver
<Route path="approver" ... />
I just did this as a quick POC but would need to review all the routes.
A lot of the complicated code came from the variants for different types of pages but @fbwoolf had a good suggestion to have different containers for each which I am doing here.
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.
Interesting idea.
The problem currently is that we mix both functionality and container styles in the container.tsx
component.
What if we want the behaviour of
useOnWalletLock(() => closeWindow());
useOnSignOut(() => closeWindow());
but not the styles.
I think this refactor should decouple the container styles & logic. If so, then the router based approach to wrapping is a good idea I think.
|
||
<Route | ||
path={RouteUrls.ViewSecretKey} | ||
path="approver" |
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.
This is your Approver
but outside of the generic <Container
.
In this file I am wrapping it with ContainerLayout
so the Header
is wider to show how we could do this.
A good fit for this approach would be the OnBoarding
pages.
For Approver
I think we shouldn't wrap it but instead load the Header
inside that component as I have done here
By grouping routes better I believe we can simplify our logic and remove all the pathname switches I added to get us away from storing headers in state.
</AccountGate> | ||
<ContainerLayout | ||
header={ | ||
<Header |
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.
This <Header
component became overly complex when trying to be a do everything for everyone header.
In fact, once I had applied logic I reverse engineered from production and documented here it was decided that for most popups we would only show the logo anyway.
Steps I think we can take here are:
- refactor and organise our routes
- create simpler
Containers
andHeaders
This is just a POC. I'm thinking about how best to do this and also to include solving #5181 |
@@ -0,0 +1,59 @@ | |||
|
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.
to remove/add to gitignore
src/app/routes/app-routes.tsx
Outdated
@@ -79,144 +85,175 @@ export const homePageModalRoutes = ( | |||
); | |||
|
|||
function useAppRoutes() { | |||
// const navigate = useNavigate(); |
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.
to remove
> | ||
{homePageModalRoutes} | ||
</Route> | ||
<Route> |
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.
Interesting idea.
The problem currently is that we mix both functionality and container styles in the container.tsx
component.
What if we want the behaviour of
useOnWalletLock(() => closeWindow());
useOnSignOut(() => closeWindow());
but not the styles.
I think this refactor should decouple the container styles & logic. If so, then the router based approach to wrapping is a good idea I think.
This is a POC of how we can refactor our code to make it easier to add headers to the approval flow.
In the screenshot below you can see a double header:
ContainerLayout
wrapperApprover
component