Skip to content

Commit

Permalink
Run lint
Browse files Browse the repository at this point in the history
  • Loading branch information
RafaelSzmarowski committed Nov 20, 2023
1 parent a693fa8 commit be1ad63
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -430,7 +430,7 @@
}
/* Add a more opacity and blur effect on map when cooperative gesture is shown */
.map-card :global(.maplibregl-cooperative-gesture-screen) {
background: rgba(0,0,0,0.6);
background: rgba(0, 0, 0, 0.6);
backdrop-filter: blur(2px);
}
.main {
Expand Down
13 changes: 9 additions & 4 deletions packages/visualizations/src/components/Map/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -222,10 +222,15 @@ export const getFixedTooltips = (
/** Transform a filter object from the options into a Maplibre filter expression */
export const computeFilterExpression = (filterConfig: MapFilter): ExpressionSpecification => {
const { key, value } = filterConfig;
const filterMatchExpression: ExpressionSpecification = ['in', ['downcase', ['get', key]], ['literal', []]];
const filterMatchExpression: ExpressionSpecification = [
'in',
['downcase', ['get', key]],
['literal', []],
];

const matchingValues: string[] = Array.isArray(value)
? value.map(v => v.toString().toLowerCase()) : [value.toString().toLowerCase()];
? value.map((v) => v.toString().toLowerCase())
: [value.toString().toLowerCase()];

filterMatchExpression[2] = ['literal', matchingValues];
return filterMatchExpression;
Expand Down Expand Up @@ -287,13 +292,13 @@ export const computeMatchExpression = (
matchKey: string,
emptyValueColor: Color
): ExpressionSpecification => {
const matchExpression: ["match", ExpressionSpecification] = ['match', ['get', matchKey]];
const matchExpression: ['match', ExpressionSpecification] = ['match', ['get', matchKey]];
const groupByColors: ExpressionInputType[] = [];
Object.entries(colors).forEach((e) => groupByColors.push(...e));
groupByColors.push(emptyValueColor); // Default fallback color
// We constructed a match expression so we can cast here the final type
return [
...matchExpression,
...groupByColors as [ExpressionInputType, ExpressionInputType, ExpressionInputType]
...(groupByColors as [ExpressionInputType, ExpressionInputType, ExpressionInputType]),
];
};
10 changes: 8 additions & 2 deletions packages/visualizations/src/components/MapPoi/MapRender.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,13 @@

<script lang="ts">
import type { BBox } from 'geojson';
import type { LngLatBoundsLike, LngLatLike, MapOptions, StyleSpecification, GestureOptions } from 'maplibre-gl';
import type {
LngLatBoundsLike,
LngLatLike,
MapOptions,
StyleSpecification,
GestureOptions,
} from 'maplibre-gl';
import { onDestroy, onMount } from 'svelte';
import CategoryLegend from '../Legend/CategoryLegend.svelte';
import type { CategoryLegend as CategoryLegendType } from '../Legend/types';
Expand Down Expand Up @@ -149,7 +155,7 @@
}
/* Add a more opacity and blur effect on map when cooperative gesture is shown */
.map-card :global(.maplibregl-cooperative-gesture-screen) {
background: rgba(0,0,0,0.6);
background: rgba(0, 0, 0, 0.6);
backdrop-filter: blur(2px);
}
.main {
Expand Down
22 changes: 16 additions & 6 deletions packages/visualizations/src/components/MapPoi/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,24 +45,30 @@ export const getMapLayers = (layers?: Layer[]): CircleLayerSpecification[] => {
} = layer;

let circleColor: ExpressionSpecification | Color = layerColor;
let circleBorderColor: ExpressionSpecification | Color | undefined =
layerBorderColor;
let circleBorderColor: ExpressionSpecification | Color | undefined = layerBorderColor;

if (colorMatch) {
const { key, colors, borderColors } = colorMatch;
const matchExpression: ["match", ExpressionSpecification] = ['match', ['get', key]];
const matchExpression: ['match', ExpressionSpecification] = ['match', ['get', key]];
const groupByColors: ExpressionInputType[] = [];
Object.keys(colors).forEach((color) => {
groupByColors.push(color, colors[color]);
});
groupByColors.push(layerColor);
circleColor = [
...matchExpression,
...groupByColors as [ExpressionInputType, ExpressionInputType, ExpressionInputType]
...(groupByColors as [
ExpressionInputType,
ExpressionInputType,
ExpressionInputType
]),
];

if (borderColors) {
const matchBorderExpression: ["match", ExpressionSpecification] = ['match', ['get', key]];
const matchBorderExpression: ['match', ExpressionSpecification] = [
'match',
['get', key],
];
const groupByBorderColors: ExpressionInputType[] = [];
Object.keys(borderColors).forEach((borderColor) => {
groupByBorderColors.push(borderColor, borderColors[borderColor]);
Expand All @@ -71,7 +77,11 @@ export const getMapLayers = (layers?: Layer[]): CircleLayerSpecification[] => {
// We constructed a match expression so we can cast here the final type
circleBorderColor = [
...matchBorderExpression,
...groupByBorderColors as [ExpressionInputType, ExpressionInputType, ExpressionInputType]
...(groupByBorderColors as [
ExpressionInputType,
ExpressionInputType,
ExpressionInputType
]),
];
}
}
Expand Down

0 comments on commit be1ad63

Please sign in to comment.