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

chore: style navigation tabs #57

Merged
merged 15 commits into from
Dec 13, 2024
Merged

chore: style navigation tabs #57

merged 15 commits into from
Dec 13, 2024

Conversation

ErikSin
Copy link
Contributor

@ErikSin ErikSin commented Dec 11, 2024

Styled the navigation tabs to prep for the map component.

image

@ErikSin ErikSin requested a review from cimigree December 11, 2024 23:32
Copy link
Contributor

@cimigree cimigree left a comment

Choose a reason for hiding this comment

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

Is this related to this issue? chore-style-tabs

I am getting tons of errors / warnings both in the terminal when running tests and the developer console (especially when clicking on the tabs) These relate to invalid props on Dom elements (fullWidth, indicator, selectionFollowsFocus, and textColor) that we are not using explicitly so not sure what is going on here. Did you look into it? It seems like it is something we should try to fix. If for no other reason than that any [other] errors we need to address will be invisible among all the other noise.

The other warning I get repeatedly is:
chunk-GYPSVNDI.js?v=08559733:674 MUI: The value provided to the Tabs component is invalid.
None of the Tabs' children match with "undefined".
You can provide one of the following values: /tab1, 1, /tab2.

Also, I don't seem to be passing through the index file at all.
src/renderer/src/routes/index.tsx
Do you know why?
I thought I would see the onboarding screens but I am not.

I understand that this is a foundation, but I wonder if it could be cleaned up and clarified a little more before it is merged based on some of the comments below and in here.

src/renderer/src/routes/(MapTabs)/_Map.tsx Show resolved Hide resolved
src/renderer/src/routes/(MapTabs)/_Map.tsx Outdated Show resolved Hide resolved
</Text>
}
value={'/tab2'}
/>
Copy link
Contributor

Choose a reason for hiding this comment

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

If you add an sx here with paddingBottom the about icon won't be so close to the bottom of the screen...

Copy link
Contributor Author

Choose a reason for hiding this comment

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

icon={<PostAddIcon />}
value={'/tab1'}
/>
<Box flexGrow={1} />
Copy link
Contributor

@cimigree cimigree Dec 12, 2024

Choose a reason for hiding this comment

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

This is kind of unfortunate that you had to do this to put the tabs at the bottom. Just noticing. Nothing I am suggesting you change.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

THIS BOX IS CAUSING ALL THE CONSOLE ERRORS

</div>
<Suspense fallback={<CircularProgress />}>
<div>map component here</div>
</Suspense>
Copy link
Contributor

Choose a reason for hiding this comment

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

This component seems very complex. It handles routing, tab rendering, Suspense and layout. Could there be a separate function or hook to handle the logic of determining which tab is selected?
It would be nice if MapLayout could just focus on Layout

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Im open to simplfying this. Im just not fully sure how we do that. Do you have any suggestions?

Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe a useMapTabs hook to determine what tab to show? But maybe that is unnecessary. Just a suggestion.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

So, because the tabs needed a value prop it had to be aware of the navigation name. This requires the use of useLocation hook. This was causing the entire layout screen and all its children (aka the whole app) to rerender on every change in location. So I had to encapsulate the tabs into its own component. I think it simplifies the component?

I think this brings up the question of what is the scope of a component. Gregor has argued that the parent component should contain all the logic, and while it is messier, it does expose everything. And while i don't fully agree, he has some good points. I think there needs to be a more in depth conversation about what are the standards for components.

Regardless, I think the optimization of encapsulating the logic makes sense here because navigation touches everything, and this is a layout component that is the parent for the rest of the app. So the optimization is a necessary as opposed to an over optimization.

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 does too. Thanks. I think we will be glad of this later.

src/renderer/src/routes/(MapTabs)/_Map.tsx Show resolved Hide resolved
@ErikSin
Copy link
Contributor Author

ErikSin commented Dec 12, 2024

Is this related to this issue? chore-style-tabs

I am getting tons of errors / warnings both in the terminal when running tests and the developer console (especially when clicking on the tabs) These relate to invalid props on Dom elements (fullWidth, indicator, selectionFollowsFocus, and textColor) that we are not using explicitly so not sure what is going on here. Did you look into it? It seems like it is something we should try to fix. If for no other reason than that any [other] errors we need to address will be invisible among all the other noise.

Oooh, i didnt open up my console so i didnt see any of these. Will look into them now

@ErikSin
Copy link
Contributor Author

ErikSin commented Dec 12, 2024

I fixed all the errors. I had to do some hacky things BUT i think these hacky things are better than the alternatives.

  1. to deal with the spacing of the tabs, i was originally using a < box/>. This box was causing all the console errors because the tabs was trying to pass it props that didn't exist. So I replaced it with a < Tab />, disabled it, and didnt give it a label or icon. Its techincally in the react tree, but it is not seen or interact-able. I couldn't think of another alternative. The api just doesn't allow for the styling customization that we want
  2. the / route technically return null as the component. But, the useLayoutEffect redirects the user to the approriate page. While this is not ideal code, the other alternative is to use the beforeLoading prop in tanstack. But the router then needs use of the hook useDeviceInfo to determine where to navigate too. In order to pass this into the router, we need to use a the router provider which needs to initialized on creation of the router. Its quite a lot of complex code for a simple redirect. I think this is a better and cleaner alternative.

@ErikSin ErikSin requested a review from cimigree December 12, 2024 21:08
@@ -86,6 +86,7 @@ const theme = createTheme({
},
},
},
spacing: 1,
Copy link
Contributor Author

Choose a reason for hiding this comment

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

a bunch of spacing was being multipied by 8 because of the way the theme api. So setting the spacing to 1 means any padding or margin is multiplied by one. I don't think we have any utility in one defined default spacing

Copy link
Contributor

Choose a reason for hiding this comment

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

Good find! Sorry about that. I probably added that back in the summer and totally forgot why!

Copy link
Contributor

@cimigree cimigree left a comment

Choose a reason for hiding this comment

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

Nice work fixing all of those errors! Very impressive!

@@ -3,7 +3,6 @@ import { CssBaseline, ThemeProvider } from '@mui/material'
import CircularProgress from '@mui/material/CircularProgress'
import { QueryClient, QueryClientProvider } from '@tanstack/react-query'
import { Outlet, createRootRoute } from '@tanstack/react-router'
import { TanStackRouterDevtools } from '@tanstack/router-devtools'
Copy link
Contributor

Choose a reason for hiding this comment

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

Do you want to remove the actual Devtools also? It is commented out right now.

</div>
<Suspense fallback={<CircularProgress />}>
<div>map component here</div>
</Suspense>
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 does too. Thanks. I think we will be glad of this later.

@ErikSin ErikSin merged commit 4b6302f into main Dec 13, 2024
2 checks passed
@ErikSin ErikSin deleted the chore-style-tabs branch December 13, 2024 02:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants