forked from ietf-tools/datatracker
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathn-theme.vue
More file actions
45 lines (35 loc) · 845 Bytes
/
n-theme.vue
File metadata and controls
45 lines (35 loc) · 845 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
<template lang='pug'>
n-config-provider(
:theme='currentTheme'
:theme-overrides='state.themeOverrides'
)
slot
</template>
<script setup>
import { computed, reactive, watch } from 'vue'
import { darkTheme, NConfigProvider } from 'naive-ui'
import { useSiteStore } from '../shared/store'
// STORES
const siteStore = useSiteStore()
// DATA
const state = reactive({
themeOverrides: {
common: {
primaryColor: '#0d6efd',
primaryColorHover: '#0d6efd'
}
}
})
// COMPUTED
const currentTheme = computed(() => {
return siteStore.theme === 'dark' ? darkTheme : null
})
// APPLY BODY THEME CLASS
watch(() => siteStore.theme, (newValue) => {
if (newValue === 'dark') {
document.body.classList.add('theme-dark')
} else {
document.body.classList.remove('theme-dark')
}
}, { immediate: true })
</script>