From 28df5da925cb7ecb3baefafe1b732728765d4804 Mon Sep 17 00:00:00 2001 From: Max Kohler Date: Thu, 2 Oct 2025 14:33:12 +0200 Subject: [PATCH 1/2] Build feature --- .../MapStyle/SWRDataLabDark.stories.svelte | 15 +++++++++++++++ .../src/maplibre/MapStyle/SWRDataLabDark.ts | 10 +++++----- .../src/maplibre/MapStyle/SWRDataLabLight.ts | 5 +---- components/src/maplibre/MapStyle/types.ts | 8 ++++++++ 4 files changed, 29 insertions(+), 9 deletions(-) create mode 100644 components/src/maplibre/MapStyle/types.ts diff --git a/components/src/maplibre/MapStyle/SWRDataLabDark.stories.svelte b/components/src/maplibre/MapStyle/SWRDataLabDark.stories.svelte index ef4fdf93..9d41afd1 100644 --- a/components/src/maplibre/MapStyle/SWRDataLabDark.stories.svelte +++ b/components/src/maplibre/MapStyle/SWRDataLabDark.stories.svelte @@ -30,6 +30,21 @@ + + +
+
+ + + +
+
+
+
diff --git a/components/src/maplibre/MapStyle/SWRDataLabDark.ts b/components/src/maplibre/MapStyle/SWRDataLabDark.ts index cb9cfe1a..9f6e747a 100644 --- a/components/src/maplibre/MapStyle/SWRDataLabDark.ts +++ b/components/src/maplibre/MapStyle/SWRDataLabDark.ts @@ -7,6 +7,7 @@ import makeTransit from './components/Transit'; import makePlaceLabels from './components/PlaceLabels'; import makeWalking from './components/Walking'; import makeRoads from './components/Roads'; +import type { StyleOptions } from './types'; const tokens = { sans_regular: ['SWR Sans Regular'], @@ -49,10 +50,6 @@ const { walkingLabels, walkingTunnels, walkingSurface, walkingBridges } = makeWa const { roadLabels, roadBridges, roadSurface, roadTunnels } = makeRoads(tokens); const { buildingFootprints, buildingExtrusions, structureExtrusions } = makeBuildings(tokens); -interface StyleOptions { - enableBuildingExtrusions?: boolean; -} - interface styleFunction { (options?: StyleOptions): StyleSpecification; } @@ -60,6 +57,9 @@ interface styleFunction { const style: styleFunction = (opts) => { const options = { enableBuildingExtrusions: false, + roads: { + showLabels: true + }, ...opts } as StyleOptions; @@ -127,7 +127,7 @@ const style: styleFunction = (opts) => { // 7. Labels ...walkingLabels, - ...roadLabels, + ...(options.roads?.showLabels ? roadLabels : []), // 8. Building extrusions ...(options.enableBuildingExtrusions ? [buildingExtrusions] : []), diff --git a/components/src/maplibre/MapStyle/SWRDataLabLight.ts b/components/src/maplibre/MapStyle/SWRDataLabLight.ts index 0e666aee..b78845ca 100644 --- a/components/src/maplibre/MapStyle/SWRDataLabLight.ts +++ b/components/src/maplibre/MapStyle/SWRDataLabLight.ts @@ -7,6 +7,7 @@ import makeTransit from './components/Transit'; import makePlaceLabels from './components/PlaceLabels'; import makeWalking from './components/Walking'; import makeRoads from './components/Roads'; +import type { StyleOptions } from './types'; const tokens = { sans_regular: ['SWR Sans Regular'], @@ -49,10 +50,6 @@ const { walkingLabels, walkingTunnels, walkingSurface, walkingBridges } = makeWa const { roadLabels, roadBridges, roadSurface, roadTunnels } = makeRoads(tokens); const { buildingFootprints, buildingExtrusions, structureExtrusions } = makeBuildings(tokens); -interface StyleOptions { - enableBuildingExtrusions?: boolean; -} - interface styleFunction { (options?: StyleOptions): StyleSpecification; } diff --git a/components/src/maplibre/MapStyle/types.ts b/components/src/maplibre/MapStyle/types.ts new file mode 100644 index 00000000..34038225 --- /dev/null +++ b/components/src/maplibre/MapStyle/types.ts @@ -0,0 +1,8 @@ +interface StyleOptions { + enableBuildingExtrusions?: boolean; + roads?: { + showLabels?: boolean; + }; +} + +export type { StyleOptions }; From 8cdaa6db77ee9076195afa3bd783b880555120d6 Mon Sep 17 00:00:00 2001 From: Max Kohler Date: Thu, 2 Oct 2025 14:35:13 +0200 Subject: [PATCH 2/2] Extend docs --- components/src/maplibre/MapStyle/SWRDataLabLight.mdx | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/components/src/maplibre/MapStyle/SWRDataLabLight.mdx b/components/src/maplibre/MapStyle/SWRDataLabLight.mdx index 6a502c5e..4c66b524 100644 --- a/components/src/maplibre/MapStyle/SWRDataLabLight.mdx +++ b/components/src/maplibre/MapStyle/SWRDataLabLight.mdx @@ -82,6 +82,10 @@ Call `SWRDataLabLight()` to construct a style document and pass the result to th ```ts interface StyleOptions { enableBuildingExtrusions?: boolean; + roads?: { + showLabels?: boolean + } + } ```