doxa-maps/library/components/map-controls/ThemeToggleButton.vue
doxa-maps d5ba21fa76 doxa-maps — portable bundler for embeddable JAMstack maps
Standalone repo that builds embeddable JAMstack map bundles (web components),
composes them into a lazy-loaded SPA via layouts/, and optionally wraps a
Capacitor Android/iOS app — one build, choose your output/CDN. Diátaxis docs.

History reset to a single clean commit; no PII, IPs, or internal terms.
2026-09-10 01:53:07 +00:00

41 lines
1.3 KiB
Vue
Raw 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"
: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>