Skip to content

Commit

Permalink
fixed opacity for layers
Browse files Browse the repository at this point in the history
  • Loading branch information
davidsingal committed Mar 18, 2024
1 parent 913d35e commit 0462ff2
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 3 deletions.
2 changes: 1 addition & 1 deletion client/src/components/legend/item/info-modal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ const InfoModal = ({ info: { title, description, source } }: InfoModalProps) =>
const [open, setOpen] = useState(false);
return (
<>
<button type="button" className="px-0 py-0" onClick={() => setOpen(true)}>
<button type="button" className="cursor-pointer px-0 py-0" onClick={() => setOpen(true)}>
<InformationCircleIcon className="h-4 w-4" />
</button>
<Modal onDismiss={() => setOpen(false)} title={title || NO_DATA} open={open} size="narrow">
Expand Down
4 changes: 4 additions & 0 deletions client/src/containers/analysis-eudr/map/component.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ const EUDRMap = () => {
highlightColor: [63, 89, 224, 255],
visible: supplierLayer.active,
onHover: setHoverInfo,
opacity: supplierLayer.opacity,
});

const planetLayer = new TileLayer({
Expand Down Expand Up @@ -122,6 +123,7 @@ const EUDRMap = () => {
stroked: false,
getFillColor: [114, 169, 80],
lineWidthMinPixels: 1,
opacity: contextualLayers['forest-cover-2020-ec-jrc'].opacity,
visible: contextualLayers['forest-cover-2020-ec-jrc'].active,
credentials: {
apiVersion: API_VERSIONS.V3,
Expand All @@ -140,6 +142,7 @@ const EUDRMap = () => {
stroked: false,
getFillColor: [224, 191, 36],
lineWidthMinPixels: 1,
opacity: contextualLayers['deforestation-alerts-2020-2022-hansen'].opacity,
visible: contextualLayers['deforestation-alerts-2020-2022-hansen'].active,
credentials: {
apiVersion: API_VERSIONS.V3,
Expand All @@ -165,6 +168,7 @@ const EUDRMap = () => {
return [201, 42, 109];
},
lineWidthMinPixels: 1,
opacity: contextualLayers['real-time-deforestation-alerts-since-2020-radd'].opacity,
visible: contextualLayers['real-time-deforestation-alerts-since-2020-radd'].active,
credentials: {
apiVersion: API_VERSIONS.V3,
Expand Down
11 changes: 11 additions & 0 deletions client/src/containers/analysis-eudr/map/legend/component.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,9 @@ const EURDLegend = () => {
changeVisibility={() =>
dispatch(setSupplierLayer({ ...supplierLayer, active: !supplierLayer.active }))
}
changeOpacity={(opacity) =>
dispatch(setSupplierLayer({ ...supplierLayer, opacity }))
}
/>
</div>
<Collapsible open={isExpanded} onOpenChange={setIsExpanded}>
Expand Down Expand Up @@ -87,6 +90,14 @@ const EURDLegend = () => {
}),
)
}
changeOpacity={(opacity) =>
dispatch(
setContextualLayer({
layer: layer.id,
configuration: { opacity },
}),
)
}
>
<>
{layer.id === 'deforestation-alerts-2020-2022-hansen' &&
Expand Down
10 changes: 8 additions & 2 deletions client/src/containers/analysis-eudr/map/legend/item.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ type LegendItemProps = {
showSwitcher?: boolean;
isActive?: boolean;
changeVisibility?: (active: boolean) => void;
changeOpacity?: (opacity: number) => void;
};

const LegendItem: FC<PropsWithChildren<LegendItemProps>> = ({
Expand All @@ -34,6 +35,7 @@ const LegendItem: FC<PropsWithChildren<LegendItemProps>> = ({
showSwitcher = false,
isActive = true,
changeVisibility = () => null,
changeOpacity = () => null,
}) => {
return (
<div className="flex space-x-2 p-4">
Expand All @@ -50,12 +52,16 @@ const LegendItem: FC<PropsWithChildren<LegendItemProps>> = ({
<h3 className="text-xs font-normal">{title}</h3>
<div className="flex divide-x">
<div className="flex items-center space-x-1 pr-1">
<OpacityControl opacity={1} onChange={() => null} />
<OpacityControl opacity={1} onChange={changeOpacity} />
<InfoModal info={{ title, description: content, source }} />
</div>
{showVisibility && (
<div className="flex items-center pl-1">
<button type="button" onClick={() => changeVisibility(!isActive)}>
<button
type="button"
onClick={() => changeVisibility(!isActive)}
className="cursor-pointer"
>
{isActive ? (
<EyeOffIcon className="h-4 w-4"></EyeOffIcon>
) : (
Expand Down

0 comments on commit 0462ff2

Please sign in to comment.