@swr-data-lab/components 2.36.0 → 2.38.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -45,7 +45,6 @@ const tokens = {
45
45
  };
46
46
  const { landuse } = makeLanduse(tokens);
47
47
  const { placeLabels, boundaryLabels } = makePlaceLabels(tokens);
48
- const { admin } = makeAdmin(tokens);
49
48
  const { airports, transitBridges, transitSurface, transitTunnels } = makeTransit(tokens);
50
49
  const { walkingLabels, walkingTunnels, walkingSurface, walkingBridges } = makeWalking(tokens);
51
50
  const { roadLabels, roadBridges, roadSurface, roadTunnels } = makeRoads(tokens);
@@ -56,6 +55,7 @@ const style = (opts) => {
56
55
  ...defaultOptions,
57
56
  ...opts
58
57
  };
58
+ const { admin } = makeAdmin(tokens, options?.admin);
59
59
  return {
60
60
  version: 8,
61
61
  name: 'swr-datalab-dark',
@@ -140,7 +140,7 @@ const style = (opts) => {
140
140
  // 10. Point labels
141
141
  ...(options.places?.showLabels ? placeLabels : []),
142
142
  // 11. Admin boundary labels
143
- ...boundaryLabels
143
+ ...(options.admin?.showLabels ? boundaryLabels : [])
144
144
  ]
145
145
  };
146
146
  };
@@ -45,7 +45,6 @@ const tokens = {
45
45
  };
46
46
  const { landuse } = makeLanduse(tokens);
47
47
  const { placeLabels, boundaryLabels } = makePlaceLabels(tokens);
48
- const { admin } = makeAdmin(tokens);
49
48
  const { airports, transitBridges, transitSurface, transitTunnels } = makeTransit(tokens);
50
49
  const { walkingLabels, walkingTunnels, walkingSurface, walkingBridges } = makeWalking(tokens);
51
50
  const { roadLabels, roadBridges, roadSurface, roadTunnels } = makeRoads(tokens);
@@ -56,6 +55,7 @@ const style = (opts) => {
56
55
  ...defaultOptions,
57
56
  ...opts
58
57
  };
58
+ const { admin } = makeAdmin(tokens, options?.admin);
59
59
  return {
60
60
  version: 8,
61
61
  name: 'swr-datalab-light',
@@ -140,7 +140,7 @@ const style = (opts) => {
140
140
  // 10. Point labels
141
141
  ...(options.places?.showLabels ? placeLabels : []),
142
142
  // 11. Admin boundary labels
143
- ...boundaryLabels
143
+ ...(options.admin?.showLabels ? boundaryLabels : [])
144
144
  ]
145
145
  };
146
146
  };
@@ -1 +1 @@
1
- export default function makeAdmin(tokens: any): any;
1
+ export default function makeAdmin(tokens: any, options: any): any;
@@ -1,5 +1,5 @@
1
1
  import {} from '../../types';
2
- export default function makeAdmin(tokens) {
2
+ export default function makeAdmin(tokens, options) {
3
3
  const admin = [
4
4
  {
5
5
  id: 'boundary-country:case',
@@ -133,7 +133,21 @@ export default function makeAdmin(tokens) {
133
133
  }
134
134
  }
135
135
  }
136
- ].map((el) => {
136
+ ]
137
+ .filter((el) => {
138
+ if (!options || options.show === true) {
139
+ return true;
140
+ }
141
+ else if (options.show === false) {
142
+ return false;
143
+ }
144
+ else {
145
+ return ((el.id.includes('country') && options.show.includes(2)) ||
146
+ (el.id.includes('state') && options.show.includes(4)));
147
+ }
148
+ return false;
149
+ })
150
+ .map((el) => {
137
151
  return {
138
152
  source: 'versatiles-osm',
139
153
  'source-layer': 'boundaries',
@@ -5,6 +5,10 @@ const opts = {
5
5
  },
6
6
  roads: {
7
7
  showLabels: true
8
+ },
9
+ admin: {
10
+ show: true,
11
+ showLabels: true
8
12
  }
9
13
  };
10
14
  export default opts;
@@ -1,9 +1,17 @@
1
+ declare enum AdminLevel {
2
+ COUNTRY = 2,
3
+ BUNDESLAND = 4
4
+ }
1
5
  interface StyleOptions {
2
6
  enableBuildingExtrusions?: boolean;
3
7
  enableHillshade?: boolean;
4
8
  places?: {
5
9
  showLabels?: boolean;
6
10
  };
11
+ admin?: {
12
+ show?: boolean | AdminLevel[];
13
+ showLabels?: boolean;
14
+ };
7
15
  roads?: {
8
16
  showLabels?: boolean;
9
17
  };
@@ -1 +1,6 @@
1
+ var AdminLevel;
2
+ (function (AdminLevel) {
3
+ AdminLevel[AdminLevel["COUNTRY"] = 2] = "COUNTRY";
4
+ AdminLevel[AdminLevel["BUNDESLAND"] = 4] = "BUNDESLAND";
5
+ })(AdminLevel || (AdminLevel = {}));
1
6
  export {};
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@swr-data-lab/components",
3
3
  "description": "SWR Data Lab component library",
4
- "version": "2.36.0",
4
+ "version": "2.38.0",
5
5
  "author": "SWR Data Lab",
6
6
  "license": "UNLICENSED",
7
7
  "type": "module",