doxa-maps/library/components/map-controls/ThemeToggleButton.vue
Doxa Maps 726b11ae79 A lazy view that fails to load says so and offers Retry; map controls carry data-control
retryableAsyncComponent: after the three retries the pane rendered blank. It now shows
"This view couldn't load." with a Retry button (messages keys, 11 locales). Retry swaps in a
fresh async component, since Vue keeps a rejected load for the life of the page.

Each map control wrapper passes data-control (zoom-in, zoom-out, fullscreen, theme, location,
help, share) to its button: an untranslated hook for probes, where title and aria-label are
localised.
2026-09-28 11:42:54 +00:00

42 lines
1.4 KiB
Vue
Raw Permalink Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<!--
ThemeToggleButton.vue — Switches the app between light and dark mode.
The component itself only emits `toggle`; the heavier work of swapping the
Mapbox style and re-adding custom layers lives in the parent
(doxa-simple-map.vue) where the layer references are available.
Props:
isDark — current theme state (controls icon: 🌙 = go dark, ☀️ = go light)
Emits:
toggle — fires on click; parent is responsible for calling
uiStore.toggleTheme() and map.setStyle(...)
-->
<script setup>
import { useI18n } from 'vue-i18n'
import MapControlButton from './MapControlButton.vue'
// FEATURE FLAG (single source of truth in useMapTheme.js). When THEME_TOGGLE is
// false this control renders NOTHING — gating it HERE hides it from every profile
// at once (research-map + simple-map) without editing either profile.
import { THEME_TOGGLE } from '@map/composables/useMapTheme.js'
const { t } = useI18n()
defineProps({
isDark: { type: Boolean, default: false }
})
defineEmits(['toggle'])
</script>
<template>
<MapControlButton
v-if="THEME_TOGGLE"
data-control="theme"
:is-dark="isDark"
:title="isDark ? t('buttons.switchToLightMode') : t('buttons.switchToDarkMode')"
@click="$emit('toggle')"
>
<span style="font-size:16px;line-height:1;">{{ isDark ? '☀️' : '🌙' }}</span>
</MapControlButton>
</template>