PluginProbe
The Innovative Form Builder – IvyForms / 0.7
The Innovative Form Builder – IvyForms v0.7
1.5.1 1.5 1.4.1 1.4 trunk 0.1.2 0.2 0.2.1 0.3 0.3.1 0.4 0.5 0.6 0.6.1 0.6.1-backup 0.6.1.1 0.7 0.8 0.8.1 0.8.2 0.9 0.9.1 1.0 1.1 1.1.1 All 27 releases
ivyforms / frontend / src / composables / useWcagColors.ts

useWcagColors.ts in The Innovative Form Builder – IvyForms 0.7, at frontend/src/composables/useWcagColors.ts

53 lines 1.2 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 import { watch } from 'vue'
2 import { useSettingsStore } from '@/stores/useSettingsStore'
3
4 /**
5 * Composable for managing WCAG-compliant color switching
6 * Dynamically updates CSS classes based on WCAG backend compliance setting
7 */
8 export const useWcagColors = () => {
9 const settingsStore = useSettingsStore()
10
11 /**
12 * Update CSS classes on document root based on WCAG compliance setting
13 */
14 const updateWcagClass = (useWcagColors: boolean) => {
15 const root = document.documentElement
16
17 if (useWcagColors) {
18 // Add WCAG class to root element
19 root.classList.add('wcag-compliant')
20 } else {
21 // Remove WCAG class from root element
22 root.classList.remove('wcag-compliant')
23 }
24 }
25
26 /**
27 * Initialize WCAG color system
28 */
29 const initializeWcagColors = () => {
30 // Apply initial class based on current setting
31 updateWcagClass(settingsStore.wcagBackendCompliance)
32 }
33
34 /**
35 * Watch for changes in WCAG compliance setting
36 */
37 const startWatching = () => {
38 return watch(
39 () => settingsStore.wcagBackendCompliance,
40 (newValue) => {
41 updateWcagClass(newValue)
42 },
43 { immediate: true },
44 )
45 }
46
47 return {
48 updateWcagClass,
49 initializeWcagColors,
50 startWatching,
51 }
52 }
53