Skip to content

Commit b3f8416

Browse files
authored
Merge pull request #1541 from geoadmin/feat-PB-1387-theme-scss-as-module
PB-1387: move Theme/Style/SCSS elements to a dedicated theme module
2 parents 83f7a2c + 6b17b44 commit b3f8416

File tree

205 files changed

+1046
-621
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

205 files changed

+1046
-621
lines changed

packages/config/staging/README.md

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,24 +17,26 @@ npm install @swissgeo/staging-config
1717
### Import Service Base URLs
1818

1919
```typescript
20-
import { servicesBaseUrl, type Staging, type BackendServices } from '@swissgeo/staging-config'
20+
import { type Staging, type BackendServices } from '@swissgeo/staging-config'
21+
import { getApi3BaseUrl, getWmsBaseUrl } from '@swissgeo/staging-config'
2122

2223
// Get WMS service URL for production environment
23-
const wmsUrl = servicesBaseUrl.wms.production
24+
const wmsUrl = getWmsBaseUrl() // default environment is 'production'
2425
// => 'https://wms.geo.admin.ch/'
2526

2627
// Get API3 service URL for development environment
27-
const api3Url = servicesBaseUrl.api3.development
28+
const api3Url = getApi3BaseUrl('development')
2829
// => 'https://sys-api3.dev.bgdi.ch/'
2930
```
3031

3132
### Environment-based URL Selection
3233

3334
```typescript
34-
import { servicesBaseUrl, type Staging } from '@swissgeo/staging-config'
35+
import type { Staging } from '@swissgeo/staging-config'
36+
import { getWmtsBaseUrl } from '@swissgeo/staging-config'
3537

3638
const environment: Staging = 'production' // or 'development', 'integration'
37-
const wmtsUrl = servicesBaseUrl.wmts[environment]
39+
const wmtsUrl = getWmtsBaseUrl(environment)
3840
```
3941

4042
## Available Services

packages/config/staging/package.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,11 @@
1313
"types": "./dist/index.d.ts",
1414
"import": "./dist/index.js",
1515
"require": "./dist/index.umd.cjs"
16+
},
17+
"./constants": {
18+
"types": "./dist/constants.d.ts",
19+
"import": "./dist/constants.js",
20+
"require": "./dist/constants.umd.cjs"
1621
}
1722
},
1823
"main": "./dist/index.umd.cjs",

packages/config/staging/src/baseUrl.ts

Lines changed: 95 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,4 +130,98 @@ export const servicesBaseUrl: ServicesBaseUrl = {
130130
},
131131
}
132132

133-
export default servicesBaseUrl
133+
/** Adds a slash at the end of the URL if there is none */
134+
function enforceEndingSlashInUrl(url?: string): string | undefined {
135+
if (url && !url.endsWith('/')) {
136+
return `${url}/`
137+
}
138+
return url
139+
}
140+
141+
export function getDefaultBaseUrl(service: BackendServices, staging: Staging = 'production') {
142+
return servicesBaseUrl[service][staging]
143+
}
144+
145+
const baseUrlOverrides: Record<BackendServices, string | undefined> = {
146+
wms: undefined,
147+
wmts: undefined,
148+
api3: undefined,
149+
data: undefined,
150+
kml: undefined,
151+
shortlink: undefined,
152+
tiles3D: undefined,
153+
vectorTiles: undefined,
154+
proxy: undefined,
155+
viewerSpecific: undefined,
156+
}
157+
158+
export function hasBaseUrlOverrides(): boolean {
159+
return Object.values(baseUrlOverrides).some((value) => value !== undefined)
160+
}
161+
162+
export function getBaseUrlOverride(service: BackendServices): string | undefined {
163+
return baseUrlOverrides[service]
164+
}
165+
166+
export function setBaseUrlOverrides(service: BackendServices, value?: string) {
167+
baseUrlOverrides[service] = enforceEndingSlashInUrl(value)
168+
}
169+
170+
export function getBaseUrl(service: BackendServices, staging: Staging = 'production'): string {
171+
return baseUrlOverrides[service] ?? getDefaultBaseUrl(service, staging)
172+
}
173+
174+
export function getApi3BaseUrl(staging: Staging = 'production'): string {
175+
return getBaseUrl('api3', staging)
176+
}
177+
178+
export function getViewerDedicatedServicesBaseUrl(staging: Staging = 'production'): string {
179+
return getBaseUrl('viewerSpecific', staging)
180+
}
181+
182+
export function getServiceKmlBaseUrl(staging: Staging = 'production'): string {
183+
return getBaseUrl('kml', staging)
184+
}
185+
186+
export function getServiceProxyBaseUrl(staging: Staging = 'production'): string {
187+
return getBaseUrl('proxy', staging)
188+
}
189+
190+
export function getServiceShortLinkBaseUrl(staging: Staging = 'production'): string {
191+
return getBaseUrl('shortlink', staging)
192+
}
193+
194+
export function getDataBaseUrl(staging: Staging = 'production'): string {
195+
return getBaseUrl('data', staging)
196+
}
197+
198+
export function getWmsBaseUrl(staging: Staging = 'production'): string {
199+
return getBaseUrl('wms', staging)
200+
}
201+
202+
export function getWmtsBaseUrl(staging: Staging = 'production'): string {
203+
return getBaseUrl('wmts', staging)
204+
}
205+
206+
export function get3dTilesBaseUrl(staging: Staging = 'production'): string {
207+
return getBaseUrl('tiles3D', staging)
208+
}
209+
210+
export function getVectorTilesBaseUrl(staging: Staging = 'production'): string {
211+
return getBaseUrl('vectorTiles', staging)
212+
}
213+
214+
export default {
215+
setBaseUrlOverrides,
216+
getBaseUrl,
217+
getApi3BaseUrl,
218+
getViewerDedicatedServicesBaseUrl,
219+
getServiceKmlBaseUrl,
220+
getServiceProxyBaseUrl,
221+
getServiceShortLinkBaseUrl,
222+
getDataBaseUrl,
223+
getWmsBaseUrl,
224+
getWmtsBaseUrl,
225+
get3dTilesBaseUrl,
226+
getVectorTilesBaseUrl,
227+
}

packages/viewer/src/config/cesium.config.ts renamed to packages/config/staging/src/constants/cesium.config.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { get3dTilesBaseUrl } from '@/config/baseUrl.config'
1+
import { get3dTilesBaseUrl } from '@/baseUrl'
22

33
/** 3D terrain URL */
44
export const TERRAIN_URL: string = `${get3dTilesBaseUrl()}/ch.swisstopo.terrain.3d/v1/`
File renamed without changes.
File renamed without changes.
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
export * from '@/constants/cesium.config'
2+
export * from '@/constants/feedback.config'
3+
export * from '@/constants/icons.config'
4+
export * from '@/constants/map.config'
5+
export * from '@/constants/print.config'
6+
export * from '@/constants/regex.config'
7+
export * from '@/constants/responsive.config'
8+
export * from '@/constants/security.config'
9+
export * from '@/constants/staging.config'
10+
export * from '@/constants/time.config'
11+
export * from '@/constants/vectortiles.config'

packages/viewer/src/config/map.config.ts renamed to packages/config/staging/src/constants/map.config.ts

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,3 @@
1-
import type { CoordinateSystem } from '@swissgeo/coordinates'
2-
3-
import { LV95 } from '@swissgeo/coordinates'
4-
5-
/** Default projection to be used throughout the application */
6-
export const DEFAULT_PROJECTION: CoordinateSystem = LV95
7-
81
/**
92
* Default tile size to use when requesting WMS tiles with our internal WMSs (512px)
103
*
@@ -51,8 +44,5 @@ export const DEFAULT_FEATURE_COUNT_SINGLE_POINT: number = 10
5144
*/
5245
export const DEFAULT_FEATURE_COUNT_RECTANGLE_SELECTION: number = 50
5346

54-
/** Path to the cesium static assets */
55-
export const CESIUM_STATIC_PATH: string = __CESIUM_STATIC_PATH__
56-
5747
/** In pixels */
5848
export const DEFAULT_FEATURE_IDENTIFICATION_TOLERANCE: number = 10
File renamed without changes.
File renamed without changes.

0 commit comments

Comments
 (0)