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

Current Map Feature Behind Feature Flag #96

Merged
merged 72 commits into from
Oct 9, 2024
Merged

Current Map Feature Behind Feature Flag #96

merged 72 commits into from
Oct 9, 2024

Conversation

AmiyaSX
Copy link
Contributor

@AmiyaSX AmiyaSX commented Sep 27, 2024

We need to merge the map feature into main before it goes too far.

Current functionalities:

  • Basic graphic visuals, fetch booths data
  • Basic interaction(switch floors, select booth/buildings)
  • Basic filtering function on the sidebar
  • Zoom in/out and auto focus on fair buildings
  • DetailView on the sidebar of the company
  • Edit mode for the map elements
  • Put map feature behind feature flag
  • Ability to set coordinates in url parameters

image

vmork and others added 30 commits July 13, 2024 16:37
color booths differently on hover
Was using the Drawer component for the sidebar for both small and large screens, but didnt work that well on desktop
and covered parts of map since it has to be positioned absolutely. Switched to just a div that can have
its width toggled to 0 with a button. Map width grows to fill remaining space
color booths differently on hover
Copy link
Member

@hampfh hampfh left a comment

Choose a reason for hiding this comment

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

Great work guys! Me and August has looked through the code, in general the feature is quite complete I think! The editor for the map seems to work really well and will be of great value for the person inputting the companies. The structure and logic of the map feels good! Nice!

There are quite a lot of smaller things through that needs to be addressed, not all of them necessarily has to be fixed now

Some general feedback:

  • Try not to nest components, that will create problems down the road with renders etc
  • There seem to be some dead code (out-commented code, unused files or just duplicated logic). Best practice would be to remove any code that is unused.
  • Thank you for doing code documentation for parts of the code that might be of a bit higher complexity. It helps everybody understand the code a lot more!

package.json Outdated Show resolved Hide resolved
@@ -1,3 +1,13 @@
@tailwind base;
@tailwind components;
@tailwind utilities;

/* doesnt seem to work */
Copy link
Member

Choose a reason for hiding this comment

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

If it doesn't work then we should not add it, are you sure its not doing anything?

Copy link
Contributor

Choose a reason for hiding this comment

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

That was for styling elements created by maplibre (the underlying map library used by react-map-gl) that can't be styled through react, like improving the look of the default popup and hiding the "attribution" thing that is always displayed in the bottom right corner of the map. But they don't seem to applied at all even though im pretty sure the selectors are correct, so thought it might be some tailwind-specific issue related to how global styles work (?), but couldn’t figure it out. Kept it because I was planning to come back to it later at some point

): FilterItem[] {
const distinct = new Map<FilterItem["id"], FilterItem>()
exhibitors.forEach(e => {
e[key].forEach(item => distinct.set(item.id, item))
Copy link
Member

Choose a reason for hiding this comment

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

Potential source for bug here, if you specify a field which isn't an array, you're going to iterate over undefined values. You have options, either, implement behavior that properly handles this, OR limit the keys that are available, for example only allow employments or industries

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 added an array check to make it safer. The key is defined at the beginning of the file and is limited to only employments or industries.

Copy link
Contributor

@vmork vmork Oct 4, 2024

Choose a reason for hiding this comment

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

Could be wrong but I don't think the runtime check is necessary since passing anything other than "employments" or "industries" will be a type error, and Exhibitor["employments" | "industries"] is known by typescript to be an array, so even adding non-array keys to the definition of FilterKey or changing the definition of Exhibitor would result in a type error in the filters file. So I ended up removing the check again, but let me know if you think this was incorrect

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 agree the checking might be not necessary here, since typescript already has the type check, and we already limited the key. Just to intentionally prevent the array to be null. But in the schema definition we don’t allow null value in Exhibitor object. So I think it is safe enough to not have the checking.

src/app/student/_components/MultiSelect.tsx Outdated Show resolved Hide resolved
zoom: 18
}

export const locations: Location[] = [
Copy link
Member

Choose a reason for hiding this comment

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

maybe call this floors?

Comment on lines +32 to +37
const boothsByLocation: Map<LocationId, BoothMap> = new Map(
locations.map(loc => [loc.id, new Map()])
)
boothsById.forEach((booth, id) => {
boothsByLocation.get(booth.location)!.set(id, booth)
})
Copy link
Member

Choose a reason for hiding this comment

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

Maybe this can be memoized?


return (
// TODO: pt-16 is to account for the navbar, will break if navbar size changes
<Suspense>
Copy link
Member

Choose a reason for hiding this comment

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

Since the entire page is in the suspense does it provide any value to have it? Maybe add a fallback, or extract parts of the page outside the suspense

Copy link
Contributor Author

@AmiyaSX AmiyaSX Oct 4, 2024

Choose a reason for hiding this comment

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

Yes the previous Vercel deployment error showed up when we didn't have it, that's why I added it here. It caused by calling useSearchParams() function in MainView.tsx, so basically the whole page is suspense, I could not come up a best extraction for only certain part of the page so far.

src/feature_flags.ts Outdated Show resolved Hide resolved
}
}
},
// eslint-disable-next-line @typescript-eslint/no-require-imports
plugins: [require("tailwindcss-animate")]
plugins: [tailwindcssAnimate, containerQueries]
Copy link
Member

Choose a reason for hiding this comment

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

Thank you for fixing this 🙏 We want to get rid of commonjs

vmork and others added 6 commits October 3, 2024 20:12
- removed ExhibitorListFilteringHeader which was not being used anymore
- moved ExhibitorFilters from student/components -> student/exhibitors/components since its not used outside exhibitors/
- renamed 'MapListFilteringHeader' -> 'MapFilters' to match 'ExhibitorFilters'
- removed map/components/Layers.tsx (code was already moved to map/lib/config.ts)
@hampfh
Copy link
Member

hampfh commented Oct 5, 2024

Great progress, I think we're close to being able to merge this, the blocking thing for me is just the nested components now. If all of those are addressed we can fix the rest at a later point

Copy link
Member

@hampfh hampfh left a comment

Choose a reason for hiding this comment

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

Great! I think this is good for now, we can continue to iterate after this is merged

@vmork vmork merged commit d5b499b into main Oct 9, 2024
6 checks passed
@vmork vmork deleted the feat/map branch October 9, 2024 09:21
@vmork vmork restored the feat/map branch October 9, 2024 09:22
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.

3 participants