mirror of
https://github.com/aljazceru/rabbit.git
synced 2025-12-18 06:24:25 +01:00
feat: color themes
This commit is contained in:
23
src/hooks/useColorTheme.ts
Normal file
23
src/hooks/useColorTheme.ts
Normal file
@@ -0,0 +1,23 @@
|
||||
import { createEffect, onCleanup } from 'solid-js';
|
||||
|
||||
import useConfig from '@/core/useConfig';
|
||||
|
||||
export const useColorTheme = (el: HTMLElement) => {
|
||||
const { getColorTheme } = useConfig();
|
||||
|
||||
createEffect(() => {
|
||||
const colorTheme = getColorTheme();
|
||||
if (colorTheme == null) return;
|
||||
|
||||
const { className } = colorTheme;
|
||||
if (className != null) {
|
||||
el.classList.add(className);
|
||||
|
||||
onCleanup(() => {
|
||||
el.classList.remove(className);
|
||||
});
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
export default useColorTheme;
|
||||
Reference in New Issue
Block a user