Skip to content

Commit f3966a8

Browse files
committed
chore: stabilized the globe, still needs night cycle on color mode toggle
1 parent 651c5f3 commit f3966a8

File tree

2 files changed

+32
-22
lines changed

2 files changed

+32
-22
lines changed

docs/.vitepress/theme/components/Landing/Globe.vue

Lines changed: 28 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -3,30 +3,36 @@
33
</template>
44

55
<script setup lang="ts">
6-
import { ref, onMounted, onUnmounted, watch } from 'vue'
7-
import { usePreferredDark } from '@vueuse/core' // VueUse composable to detect dark mode
6+
import { ref, onMounted, onUnmounted, watch, watchEffect} from 'vue'
7+
import { useColorMode } from '@vueuse/core' // VueUse composable to detect dark mode
8+
9+
const props = defineProps<{
10+
isDarkMode: string
11+
}>()
812
913
const globeContainer = ref<HTMLElement | null>(null)
1014
let Globe: any
1115
let globeInstance: any = null
1216
13-
// Detect dark mode
14-
const isDarkMode = usePreferredDark()
17+
// Function to update globe texture
18+
const updateGlobeTexture = () => {
19+
if (globeInstance) {
20+
const newTextureUrl = props.isDarkMode === 'dark'
21+
? '//unpkg.com/three-globe/example/img/earth-night.jpg'
22+
: '//unpkg.com/three-globe/example/img/earth-day.jpg';
23+
console.log('Updating globe texture to:', newTextureUrl);
24+
globeInstance.globeImageUrl(newTextureUrl);
25+
} else {
26+
console.warn('globeInstance is not initialized yet.');
27+
}
28+
}
1529
1630
// Import Globe.gl dynamically only on client-side
1731
onMounted(async () => {
18-
Globe = (await import('globe.gl')).default
19-
initGlobe()
20-
})
21-
22-
// Watch for changes in dark mode and update globe texture
23-
watch(isDarkMode, (newVal) => {
24-
if (globeInstance) {
25-
globeInstance.globeImageUrl(newVal
26-
? '//unpkg.com/three-globe/example/img/earth-night.jpg'
27-
: '//unpkg.com/three-globe/example/img/earth-day.jpg')
28-
}
29-
})
32+
Globe = (await import('globe.gl')).default;
33+
initGlobe();
34+
updateGlobeTexture();
35+
});
3036
3137
// Constants for arc animation
3238
const ARC_REL_LEN = 0.4
@@ -151,8 +157,8 @@ const initGlobe = () => {
151157
if (!globeContainer.value) return
152158
// @ts-ignore
153159
globeInstance = new Globe()
154-
.globeImageUrl(isDarkMode.value
155-
? '//unpkg.com/three-globe/example/img/earth-night.jpg'
160+
.globeImageUrl(props.isDarkMode === 'dark'
161+
? '//unpkg.com/three-globe/example/img/earth-night.jpg'
156162
: '//unpkg.com/three-globe/example/img/earth-day.jpg')
157163
.backgroundColor('rgba(0,0,0,0)')
158164
.width(globeContainer.value.offsetWidth)
@@ -188,6 +194,10 @@ const initGlobe = () => {
188194
// Regular emission interval
189195
const interval = setInterval(emitArcs, FLIGHT_TIME * 1.5)
190196
globeInstance.__interval = interval
197+
198+
console.log('Globe initialized with texture:', props.isDarkMode
199+
? '//unpkg.com/three-globe/example/img/earth-night.jpg'
200+
: '//unpkg.com/three-globe/example/img/earth-day.jpg')
191201
}
192202
193203
onUnmounted(() => {

docs/.vitepress/theme/components/Landing/Referral.vue

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -98,8 +98,8 @@
9898
</span>
9999
</p>
100100
<ClientOnly>
101-
<div class="transition duration-1000 ease-in-out absolute top-24 dark:top-0 left-0 w-full h-full flex justify-center items-center blur-xl dark:blur-none">
102-
<Globe />
101+
<div class="transition duration-1000 ease-in-out absolute top-24 left-0 w-full h-full flex justify-center items-center blur-xl dark:blur-none">
102+
<Globe :is-dark-mode="colorMode" />
103103
</div>
104104
</ClientOnly>
105105

@@ -109,13 +109,13 @@
109109
<script setup lang="ts">
110110
import { ref } from 'vue'
111111
import { VPBadge } from 'vitepress/theme'
112-
import { useClipboard } from '@vueuse/core'
112+
import { useClipboard, useColorMode } from '@vueuse/core'
113113
import { useData } from 'vitepress'
114114
import Globe from './Globe.vue'
115115
116116
// Get frontmatter data
117117
const { frontmatter } = useData()
118-
118+
const colorMode = useColorMode()
119119
// Default values
120120
const referralTitle = frontmatter.value.referral?.title ?? 'Referral Program'
121121
const referralUrl = frontmatter.value.referral?.url ?? 'https://coolify.io/hetzner'

0 commit comments

Comments
 (0)