Skip to content

Commit

Permalink
Add protomaps defaultTheme and labelRules (#158)
Browse files Browse the repository at this point in the history
  • Loading branch information
halocline authored Aug 12, 2024
1 parent f409845 commit 78740d4
Show file tree
Hide file tree
Showing 6 changed files with 764 additions and 305 deletions.
8 changes: 6 additions & 2 deletions grommet-leaflet/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,13 @@
],
"main": "./dist/grommet-leaflet.umd.cjs",
"module": "./dist/grommet-leaflet.js",
"types": "./dist/index.d.ts",
"exports": {
".": {
"import": "./dist/grommet-leaflet.js",
"import": {
"default": "./dist/grommet-leaflet.js",
"types": "./dist/index.d.ts"
},
"require": "./dist/grommet-leaflet.umd.cjs"
}
},
Expand Down Expand Up @@ -43,7 +47,7 @@
"leaflet": "^1.9.4",
"leaflet.markercluster": "^1.5.3",
"prop-types": "^15.8.1",
"protomaps-leaflet": "^2.0.1",
"protomaps-leaflet": "^4.0.0",
"react-leaflet": "^4.2.1",
"uuid": "^9.0.1"
},
Expand Down
6 changes: 4 additions & 2 deletions grommet-leaflet/src/layers/Map/index.d.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,18 @@
import * as React from 'react';
import * as L from 'leaflet';
import { GrommetLeafletThemeType } from 'grommet-leaflet';
import { TileLayerExtendedProps } from '../TileLayer';

export interface MapProps {
children?: any;
theme?: GrommetLeafletThemeType;
tileLayer: TileLayerExtendedProps
}

export interface MapExtendedProps
extends MapProps,
L.MapOptions,
Omit<JSX.IntrinsicElements['div'], keyof MapProps> {}
L.MapOptions,
Omit<JSX.IntrinsicElements['div'], keyof MapProps> { }

declare const Map: React.FC<MapExtendedProps>;

Expand Down
10 changes: 6 additions & 4 deletions grommet-leaflet/src/layers/TileLayer/TileLayer.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@ import PropTypes from 'prop-types';
import { ThemeContext } from 'styled-components';
import { TileLayer as LeafletTileLayer } from 'react-leaflet';
import { leafletLayer, paintRules, labelRules } from 'protomaps-leaflet';
import themes from 'protomaps-leaflet/dist/default_style/themes';
import {
// createElementObject,
createTileLayerComponent,
updateGridLayer,
} from '@react-leaflet/core';
import { themes } from '../../themes/protomaps/themes.ts';

const { light } = themes;
const defaultTheme = { ...themes.light };

const createElementObject = (instance, context, container) =>
Object.freeze({ instance, context, container });
Expand Down Expand Up @@ -42,10 +42,12 @@ export const TileLayer = ({ attribution, url, format, ...rest }) => {
attribution={attribution}
url={url}
paintRules={
theme.map?.tiles && paintRules({ ...light, ...theme.map.tiles })
theme.map?.tiles &&
paintRules({ ...defaultTheme, ...theme.map.tiles })
}
labelRules={
theme.map?.labels && labelRules({ ...light, ...theme.map.tiles })
theme.map?.tiles &&
labelRules({ ...defaultTheme, ...theme.map.tiles })
}
{...rest}
/>
Expand Down
4 changes: 2 additions & 2 deletions grommet-leaflet/src/layers/TileLayer/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ export interface TileLayerProps {

export interface TileLayerExtendedProps
extends TileLayerProps,
L.TileLayer,
Omit<JSX.IntrinsicElements['div'], keyof TileLayerProps> {}
L.TileLayer,
Omit<JSX.IntrinsicElements['div'], keyof TileLayerProps> { }

declare const TileLayer: React.FC<TileLayerExtendedProps>;

Expand Down
Loading

0 comments on commit 78740d4

Please sign in to comment.