-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #67 from Vizzuality/develop
Update staging
- Loading branch information
Showing
62 changed files
with
1,073 additions
and
474 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,40 @@ | ||
import Datasets from "@/containers/datasets"; | ||
import Map from "@/containers/map"; | ||
import Sidebar from "@/containers/sidebar"; | ||
import getQueryClient from "@/lib/react-query/getQueryClient"; | ||
import { getGetDatasetsQueryOptions } from "@/types/generated/dataset"; | ||
import { dehydrate, HydrationBoundary } from "@tanstack/react-query"; | ||
|
||
async function prefetchQueries() { | ||
const queryClient = getQueryClient(); | ||
try { | ||
const { queryKey, queryFn } = getGetDatasetsQueryOptions({ | ||
populate: ["layers", "layers.layer", "sources", "citations"], | ||
sort: "id:asc", | ||
locale: "all", | ||
}); | ||
|
||
await queryClient.prefetchQuery({ | ||
queryKey, | ||
queryFn, | ||
}); | ||
return dehydrate(queryClient); | ||
} catch (error) { | ||
console.info(error); | ||
return null; | ||
} | ||
} | ||
|
||
export default async function Home() { | ||
const dehydratedState = await prefetchQueries(); | ||
return ( | ||
// The map is a client component, so it needs to be wrapped in the NextIntlClientProvider to provide the translations | ||
<div className="flex"> | ||
<Sidebar> | ||
<Datasets /> | ||
</Sidebar> | ||
<Map /> | ||
</div> | ||
<HydrationBoundary state={dehydratedState}> | ||
<div className="flex h-[var(--content-height)] w-full overflow-y-hidden"> | ||
<Sidebar> | ||
<Datasets /> | ||
</Sidebar> | ||
<Map /> | ||
</div> | ||
</HydrationBoundary> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,11 @@ | ||
import { useTranslations } from "@/i18n"; | ||
import Footer from "@/containers/footer"; | ||
import HomeComponent from "@/containers/home"; | ||
|
||
export default function Home() { | ||
const t = useTranslations(); | ||
return ( | ||
<main className="flex min-h-screen flex-col items-center justify-between p-24"> | ||
<div>{t("Rangelands Data Platform")}</div> | ||
<div>{t("Exploring Rangelands")}</div> | ||
<div>{t("Test string")}</div> | ||
<main className="h-auto min-h-screen w-[100vsw] overflow-x-hidden"> | ||
<HomeComponent /> | ||
<Footer /> | ||
</main> | ||
); | ||
} |
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
71 changes: 71 additions & 0 deletions
71
client/src/components/map/layers/deck-layer/rangeland-component.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
import { MVTLayer } from "@deck.gl/geo-layers"; | ||
import { useDeckMapboxOverlayContext } from "../../provider"; | ||
import { env } from "@/env.mjs"; | ||
import { useEffect, useMemo, useState } from "react"; | ||
|
||
export interface RangelandsLayerComponentProps { | ||
id: string; | ||
data: string; | ||
opacity?: number; | ||
visibility?: boolean; | ||
colorProperty: string; | ||
lineWidth?: number; | ||
} | ||
|
||
const RangelandsLayerComponent = ({ | ||
id, | ||
data, | ||
opacity, | ||
visibility, | ||
colorProperty, | ||
lineWidth = 1, | ||
...props | ||
}: RangelandsLayerComponentProps) => { | ||
const dataWithMapboxToken = data + `?access_token=${env.NEXT_PUBLIC_MAPBOX_TOKEN}`; | ||
const [hoveredProperty, setHoveredProperty] = useState(null); | ||
const i = `${id}-deck`; | ||
const { addLayer, removeLayer } = useDeckMapboxOverlayContext(); | ||
const config = useMemo( | ||
() => | ||
new MVTLayer({ | ||
id: i, | ||
data: dataWithMapboxToken, | ||
opacity: opacity ?? 1, | ||
visible: visibility ?? true, | ||
pickable: true, | ||
onHover: (info) => { | ||
setHoveredProperty(info?.object?.properties?.[colorProperty]); | ||
}, | ||
getLineWidth: (f) => { | ||
return f?.properties?.[colorProperty] === hoveredProperty ? lineWidth : 0; | ||
}, | ||
lineWidthUnits: "pixels", | ||
getLineColor: [255, 255, 255], | ||
updateTriggers: { | ||
getLineWidth: hoveredProperty, | ||
}, | ||
...props, | ||
}), | ||
[id, dataWithMapboxToken, opacity, visibility, props], | ||
); | ||
|
||
useEffect(() => { | ||
if (!config) return; | ||
// Give the map a chance to load the background layer before adding the Deck layer | ||
setTimeout(() => { | ||
// https://github.com/visgl/deck.gl/blob/c2ba79b08b0ea807c6779d8fe1aaa307ebc22f91/modules/mapbox/src/resolve-layers.ts#L66 | ||
addLayer(config); | ||
}, 10); | ||
}, [i, id, config, addLayer]); | ||
|
||
useEffect(() => { | ||
if (!config) return; | ||
return () => { | ||
removeLayer(i); | ||
}; | ||
}, []); // eslint-disable-line react-hooks/exhaustive-deps | ||
|
||
return null; | ||
}; | ||
|
||
export default RangelandsLayerComponent; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
import React from "react"; | ||
|
||
import { LegendComponent } from "../../types"; | ||
|
||
type LegendComponentProps = { | ||
items: LegendComponent["items"]; | ||
}; | ||
|
||
export const LegendChoropleth: React.FC<LegendComponentProps> = ({ items }) => { | ||
return ( | ||
<div> | ||
<ul className="flex w-full overflow-hidden rounded-full"> | ||
{items.map(({ color }) => ( | ||
<li | ||
key={`${color}`} | ||
className="h-2 flex-shrink-0" | ||
style={{ | ||
width: `${100 / items.length}%`, | ||
backgroundColor: color, | ||
}} | ||
/> | ||
))} | ||
</ul> | ||
|
||
<ul className="mt-1 flex w-full"> | ||
{items.map(({ name }) => ( | ||
<li | ||
key={`${name}`} | ||
className="flex-shrink-0 text-center text-xs" | ||
style={{ | ||
width: `${100 / items.length}%`, | ||
}} | ||
> | ||
{name} | ||
</li> | ||
))} | ||
</ul> | ||
</div> | ||
); | ||
}; | ||
|
||
export default LegendChoropleth; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.