File tree Expand file tree Collapse file tree 2 files changed +11
-6
lines changed Expand file tree Collapse file tree 2 files changed +11
-6
lines changed Original file line number Diff line number Diff line change 11<script setup lang="ts">
22import type { TooltipTheme } from ' @/types/tooltip'
33import { ref } from ' vue'
4- import { getTooltipGlobalTheme , injectThemeStyles , setTooltipGlobalTheme } from ' ../index'
4+ import { getTooltipGlobalTheme , setTooltipGlobalTheme } from ' ../index'
55
66// Theme switching logic
77const themeOptions = [
@@ -13,23 +13,26 @@ const currentTheme = ref<TooltipTheme>(getTooltipGlobalTheme() || 'default')
1313async function handleThemeChange(e : Event ) {
1414 const value = (e .target as HTMLSelectElement ).value as TooltipTheme
1515 setTooltipGlobalTheme (value )
16- await injectThemeStyles (value )
1716}
1817 </script >
1918
2019<template >
21- <div class =" inline-block" >
22- <!-- Preset Switcher Dropdown -->
20+ <div class =" relative inline-block" >
2321 <label for =" theme-switcher" class =" sr-only" >Tooltip Theme</label >
2422 <select
2523 id =" theme-switcher"
2624 v-model =" currentTheme"
27- class =" flex gap-2 px-2 h-10 items-center rounded-md border border-gray-300 dark:border-gray-700 bg-white dark:bg-gray-800 text-gray-700 dark:text-gray-200 text-sm focus:outline-none focus:ring-2 focus:ring-blue-500"
25+ class =" appearance-none flex gap-2 px-2 h-10 items-center rounded-md border border-gray-300 dark:border-gray-700 bg-white dark:bg-gray-800 text-gray-700 dark:text-gray-200 text-sm focus:outline-none focus:ring-2 focus:ring-blue-500 pr-8 "
2826 @change =" handleThemeChange"
2927 >
3028 <option v-for =" opt in themeOptions" :key =" opt.value" :value =" opt.value" >
3129 {{ opt.label }}
3230 </option >
3331 </select >
32+ <span class =" pointer-events-none absolute right-2 top-1/2 -translate-y-1/2 text-gray-400 dark:text-gray-500" >
33+ <svg width =" 18" height =" 18" fill =" none" viewBox =" 0 0 20 20" >
34+ <path d =" M6 8l4 4 4-4" stroke =" currentColor" stroke-width =" 2" stroke-linecap =" round" stroke-linejoin =" round" />
35+ </svg >
36+ </span >
3437 </div >
3538</template >
Original file line number Diff line number Diff line change 11import type { TooltipProps , TooltipTheme } from '@/types/tooltip'
22
33import { reactive , ref } from 'vue'
4+ import { injectThemeStyles } from '../index'
45
56/**
67 * Global reactive configuration for tooltips
@@ -28,8 +29,9 @@ export function setTooltipGlobalConfig(config: Partial<TooltipProps>): void {
2829/**
2930 * Set the global theme for all tooltips
3031 */
31- export function setTooltipGlobalTheme ( theme : TooltipTheme | undefined ) : void {
32+ export async function setTooltipGlobalTheme ( theme : TooltipTheme | undefined ) : Promise < void > {
3233 globalTheme . value = theme
34+ await injectThemeStyles ( theme || 'default' )
3335}
3436
3537/**
You can’t perform that action at this time.
0 commit comments