Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions components/src/maplibre/MapStyle/SWRDataLabDark.stories.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,21 @@
</DesignTokens>
</Story>

<Story asChild name="Disable road labels (#190)">
<DesignTokens theme="dark">
<div class="grid">
<div class="container">
<Map
showDebug
style={SWRDataLabDark({ roads: { showLabels: false } })}
initialLocation={{ ...locations.berlin, zoom: 15 }}
>
<AttributionControl position="bottom-left" />
</Map>
</div>
</div>
</DesignTokens>
</Story>
<Story asChild name="fix/173">
<DesignTokens theme="dark">
<div class="grid">
Expand Down
10 changes: 5 additions & 5 deletions components/src/maplibre/MapStyle/SWRDataLabDark.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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'],
Expand Down Expand Up @@ -49,17 +50,16 @@ 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;
}

const style: styleFunction = (opts) => {
const options = {
enableBuildingExtrusions: false,
roads: {
showLabels: true
},
...opts
} as StyleOptions;

Expand Down Expand Up @@ -127,7 +127,7 @@ const style: styleFunction = (opts) => {

// 7. Labels
...walkingLabels,
...roadLabels,
...(options.roads?.showLabels ? roadLabels : []),

// 8. Building extrusions
...(options.enableBuildingExtrusions ? [buildingExtrusions] : []),
Expand Down
4 changes: 4 additions & 0 deletions components/src/maplibre/MapStyle/SWRDataLabLight.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

}
```

Expand Down
5 changes: 1 addition & 4 deletions components/src/maplibre/MapStyle/SWRDataLabLight.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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'],
Expand Down Expand Up @@ -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;
}
Expand Down
8 changes: 8 additions & 0 deletions components/src/maplibre/MapStyle/types.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
interface StyleOptions {
enableBuildingExtrusions?: boolean;
roads?: {
showLabels?: boolean;
};
}

export type { StyleOptions };