Skip to content

Commit 573c872

Browse files
committed
Improvement - Add useThemeCheck composable #267
1 parent b8a59f7 commit 573c872

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

src/useThemeCheck.js

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
import { computed } from "vue";
2+
3+
export function useThemeCheck() {
4+
const isThemeValid = computed(() => {
5+
return (config) => {
6+
if (!config || !config.theme) return false;
7+
return [
8+
'default',
9+
'dark',
10+
'celebration',
11+
'celebrationNight',
12+
'hack',
13+
'zen',
14+
'concrete'
15+
].includes(config.theme)
16+
}
17+
});
18+
19+
function warnInvalidTheme(config) {
20+
if (!config?.debug) return;
21+
console.warn(`Vue Data UI - "${config?.theme}" is not a valid theme.\n\nAvailable themes:\n\n- default (or "")\n- dark\n- celebration\n- celebrationNight \n- hack\n- zen\n- concrete`);
22+
}
23+
24+
return {
25+
isThemeValid,
26+
warnInvalidTheme
27+
}
28+
}

0 commit comments

Comments
 (0)