mirror of
https://github.com/lingble/chatwoot.git
synced 2025-11-01 19:48:08 +00:00
This PR adds RTL support to the web widget for improved right-to-left language compatibility, updates colors, and cleans up code. Fixes https://linear.app/chatwoot/issue/CW-4089/rtl-issues-on-widget https://github.com/chatwoot/chatwoot/issues/9791 Other PR: https://github.com/chatwoot/chatwoot/pull/11016
31 lines
868 B
JavaScript
31 lines
868 B
JavaScript
import { computed } from 'vue';
|
|
import { useMapGetter } from 'dashboard/composables/store';
|
|
|
|
const isDarkModeAuto = mode => mode === 'auto';
|
|
const isDarkMode = mode => mode === 'dark';
|
|
|
|
const getSystemPreference = () =>
|
|
window.matchMedia?.('(prefers-color-scheme: dark)').matches ?? false;
|
|
|
|
const calculatePrefersDarkMode = (mode, systemPreference) =>
|
|
isDarkModeAuto(mode) ? systemPreference : isDarkMode(mode);
|
|
|
|
/**
|
|
* Composable for handling dark mode.
|
|
* @returns {Object} An object containing computed properties and methods for dark mode.
|
|
*/
|
|
export function useDarkMode() {
|
|
const darkMode = useMapGetter('appConfig/darkMode');
|
|
|
|
const systemPreference = computed(getSystemPreference);
|
|
|
|
const prefersDarkMode = computed(() =>
|
|
calculatePrefersDarkMode(darkMode.value, systemPreference.value)
|
|
);
|
|
|
|
return {
|
|
darkMode,
|
|
prefersDarkMode,
|
|
};
|
|
}
|