Skip to content
This repository has been archived by the owner on Jan 31, 2023. It is now read-only.

Tonyvanswet/ele 1371 map UI basic geometries and colors #19

Merged

Conversation

tonypls
Copy link

@tonypls tonypls commented Nov 4, 2022

Made a start on the map

@@ -45,10 +51,15 @@
"@testing-library/react": "13.4.0",
"@testing-library/user-event": "14.4.3",
"@types/css-mediaquery": "0.1.1",
"@types/d3-scale": "^4.0.2",
"@types/geojson": "^7946.0.10",
Copy link
Member

Choose a reason for hiding this comment

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

I hope they don't follow semver otherwise they break things way to often. 😅

@tonypls tonypls marked this pull request as ready for review November 9, 2022 10:36
@tonypls
Copy link
Author

tonypls commented Nov 9, 2022

I'm unsure it's the best way to apply the colours but we now have a map to build from 🎉

Copy link
Member

@madsnedergaard madsnedergaard left a comment

Choose a reason for hiding this comment

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

Some comments - approving so you can merge when they are addressed :)

web/src/api/getState.ts Show resolved Hide resolved

const mapZonesToGrid = ({ data, callerLocation }: GridState, getCo2colorScale: (co2intensity: number) => string) => {
const keys = Object.keys(data.zones) as Array<keyof GridState>;
const geographies = generateTopos();
Copy link
Member

Choose a reason for hiding this comment

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

It's weird that we're doing this runtime, but we also do so in current app - is there any reason for that, @Kongkille? 🤔

Choose a reason for hiding this comment

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

I don't think so. I actually also think generateTopos doesn't really do anything. We should probably be able to just import the topojson. I have not investigated. We could add a todo perhaps?

web/src/hooks/theme.ts Outdated Show resolved Hide resolved
web/src/features/map/map-utils/generateTopos.ts Outdated Show resolved Hide resolved
[theme]
);

const { isLoading, isError, error, data } = useGetState(TimeAverages.HOURLY, getCo2colorScale);
Copy link
Member

Choose a reason for hiding this comment

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

High-level comment: Should the map-related data manipulation live in the React Query hook? When we want to do the panel, tooltips, etc., we want to consume this too, but don't need the geometries, etc. :)

Copy link
Author

Choose a reason for hiding this comment

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

I think the panel will have it's own react query hook but I'm not sure on how the tool tip works. I thought the tooltip magically pulled the zonedata from the map ( const features = ref.current.queryRenderedFeatures(e.point);), this might not be the best way though

Choose a reason for hiding this comment

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

I guess it's fine to have multiple custom hooks related to the same tanstack-query.

For example the tooltip would not care about the entire state, so we could create a hook called 'useGetHoveredOverview' which returns a single overview.

For specificity we could call this hook useGetStateWithGeometries?

@tonypls tonypls merged commit 4164ff1 into master Nov 9, 2022
@tonypls tonypls deleted the tonyvanswet/ele-1371-map-ui-basic-geometries-and-colors branch November 9, 2022 13:12
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
4 participants