Skip to content

Commit

Permalink
Map automatic coupled to ui theme
Browse files Browse the repository at this point in the history
  • Loading branch information
wkramer committed Mar 29, 2024
1 parent 128b6de commit c612dcd
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/services/useBaseLayers/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import type { MaybeRefOrGetter, ShallowRef } from 'vue'
import { shallowRef, toValue, watchEffect } from 'vue'
import Basemaps from '@/assets/base-layers.json'
import { MglDefaults } from 'vue-maplibre-gl'
import { usePreferredDark } from '@vueuse/core'
import { useDark } from '@vueuse/core'

export interface UseBaseLayersReturn {
baseLayerStyle: ShallowRef<string | object>
Expand All @@ -15,15 +15,15 @@ export function useBaseLayers(
const baseLayerStyle = shallowRef<string | object>(MglDefaults.style)
const baseLayers = shallowRef<(string | object)[]>(Basemaps.baseLayers)

const prefersDark = usePreferredDark()
const isDark = useDark()

watchEffect(() => {
const _layerId = toValue(layerId)
const layerDefinition = Basemaps.baseLayers.find(
(layer: any) => layer.id === _layerId,
)
if (layerDefinition?.automatic) {
if (prefersDark.value === true) {
if (isDark.value === true) {
const themedLayer = Basemaps.baseLayers.find(
(layer: any) => layer.id === layerDefinition.automatic.dark,
)
Expand Down

0 comments on commit c612dcd

Please sign in to comment.