@rakeyshgidwani/roger-ui-bank-theme-stan-design 0.2.8 → 0.2.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +1 -1
- package/dist/components/ui/accessibility-demo.esm.js +30 -24
- package/dist/components/ui/accessibility-demo.js +30 -24
- package/dist/components/ui/advanced-component-architecture-demo.esm.js +235 -179
- package/dist/components/ui/advanced-component-architecture-demo.js +235 -179
- package/dist/components/ui/advanced-transition-system-demo.esm.js +110 -64
- package/dist/components/ui/advanced-transition-system-demo.js +110 -64
- package/dist/components/ui/advanced-transition-system.esm.js +166 -122
- package/dist/components/ui/advanced-transition-system.js +166 -122
- package/dist/components/ui/animation/animated-container.esm.js +52 -29
- package/dist/components/ui/animation/animated-container.js +52 -29
- package/dist/components/ui/animation/staggered-container.esm.js +18 -9
- package/dist/components/ui/animation/staggered-container.js +18 -9
- package/dist/components/ui/animation-demo.esm.js +67 -35
- package/dist/components/ui/animation-demo.js +67 -35
- package/dist/components/ui/badge.esm.js +9 -6
- package/dist/components/ui/badge.js +9 -6
- package/dist/components/ui/battery-conscious-animation-demo.esm.js +122 -87
- package/dist/components/ui/battery-conscious-animation-demo.js +122 -87
- package/dist/components/ui/border-radius-shadow-demo.esm.js +23 -12
- package/dist/components/ui/border-radius-shadow-demo.js +23 -12
- package/dist/components/ui/button.esm.js +8 -2
- package/dist/components/ui/button.js +8 -2
- package/dist/components/ui/card.esm.js +33 -8
- package/dist/components/ui/card.js +33 -8
- package/dist/components/ui/checkbox.esm.js +3 -3
- package/dist/components/ui/checkbox.js +3 -3
- package/dist/components/ui/color-preview.esm.js +68 -45
- package/dist/components/ui/color-preview.js +68 -45
- package/dist/components/ui/data-display/chart.esm.js +112 -84
- package/dist/components/ui/data-display/chart.js +112 -84
- package/dist/components/ui/data-display/data-grid-simple.esm.js +1 -1
- package/dist/components/ui/data-display/data-grid-simple.js +1 -1
- package/dist/components/ui/data-display/data-grid.esm.js +80 -67
- package/dist/components/ui/data-display/data-grid.js +80 -67
- package/dist/components/ui/data-display/list.esm.js +53 -45
- package/dist/components/ui/data-display/list.js +53 -45
- package/dist/components/ui/data-display/table.esm.js +62 -54
- package/dist/components/ui/data-display/table.js +62 -54
- package/dist/components/ui/data-display/timeline.esm.js +39 -34
- package/dist/components/ui/data-display/timeline.js +39 -34
- package/dist/components/ui/data-display/tree.esm.js +116 -84
- package/dist/components/ui/data-display/tree.js +116 -84
- package/dist/components/ui/data-display/types.esm.js +389 -364
- package/dist/components/ui/data-display/types.js +389 -364
- package/dist/components/ui/enterprise-mobile-experience-demo.esm.js +120 -70
- package/dist/components/ui/enterprise-mobile-experience-demo.js +120 -70
- package/dist/components/ui/enterprise-mobile-experience.esm.js +124 -73
- package/dist/components/ui/enterprise-mobile-experience.js +124 -73
- package/dist/components/ui/feedback/alert.esm.js +22 -15
- package/dist/components/ui/feedback/alert.js +22 -15
- package/dist/components/ui/feedback/progress.esm.js +47 -24
- package/dist/components/ui/feedback/progress.js +47 -24
- package/dist/components/ui/feedback/skeleton.esm.js +39 -29
- package/dist/components/ui/feedback/skeleton.js +39 -29
- package/dist/components/ui/feedback/toast.esm.js +62 -38
- package/dist/components/ui/feedback/toast.js +62 -38
- package/dist/components/ui/feedback/types.esm.js +83 -83
- package/dist/components/ui/feedback/types.js +83 -83
- package/dist/components/ui/font-preview.esm.js +41 -39
- package/dist/components/ui/font-preview.js +41 -39
- package/dist/components/ui/form-demo.esm.js +150 -113
- package/dist/components/ui/form-demo.js +150 -113
- package/dist/components/ui/hardware-acceleration-demo.esm.js +137 -87
- package/dist/components/ui/hardware-acceleration-demo.js +137 -87
- package/dist/components/ui/input.esm.js +4 -1
- package/dist/components/ui/input.js +4 -1
- package/dist/components/ui/layout-demo.esm.js +81 -56
- package/dist/components/ui/layout-demo.js +81 -56
- package/dist/components/ui/layouts/adaptive-layout.esm.js +27 -8
- package/dist/components/ui/layouts/adaptive-layout.js +27 -8
- package/dist/components/ui/layouts/desktop-layout.esm.js +39 -19
- package/dist/components/ui/layouts/desktop-layout.js +39 -19
- package/dist/components/ui/layouts/mobile-layout.esm.js +19 -9
- package/dist/components/ui/layouts/mobile-layout.js +19 -9
- package/dist/components/ui/layouts/tablet-layout.esm.js +28 -14
- package/dist/components/ui/layouts/tablet-layout.js +28 -14
- package/dist/components/ui/mobile-form-validation.esm.js +120 -87
- package/dist/components/ui/mobile-form-validation.js +120 -87
- package/dist/components/ui/mobile-input-demo.esm.js +19 -13
- package/dist/components/ui/mobile-input-demo.js +19 -13
- package/dist/components/ui/mobile-input.esm.js +185 -120
- package/dist/components/ui/mobile-input.js +185 -120
- package/dist/components/ui/mobile-skeleton-loading-demo.esm.js +128 -111
- package/dist/components/ui/mobile-skeleton-loading-demo.js +128 -111
- package/dist/components/ui/navigation/breadcrumb.esm.js +17 -14
- package/dist/components/ui/navigation/breadcrumb.js +17 -14
- package/dist/components/ui/navigation/index.esm.js +23 -1
- package/dist/components/ui/navigation/index.js +23 -1
- package/dist/components/ui/navigation/menu.esm.js +49 -35
- package/dist/components/ui/navigation/menu.js +49 -35
- package/dist/components/ui/navigation/navigation-demo.esm.js +81 -74
- package/dist/components/ui/navigation/navigation-demo.js +81 -74
- package/dist/components/ui/navigation/pagination.esm.js +62 -50
- package/dist/components/ui/navigation/pagination.js +62 -50
- package/dist/components/ui/navigation/sidebar.esm.js +56 -42
- package/dist/components/ui/navigation/sidebar.js +56 -42
- package/dist/components/ui/navigation/stepper.esm.js +34 -23
- package/dist/components/ui/navigation/stepper.js +34 -23
- package/dist/components/ui/navigation/tabs.esm.js +32 -21
- package/dist/components/ui/navigation/tabs.js +32 -21
- package/dist/components/ui/navigation/types.esm.js +196 -195
- package/dist/components/ui/navigation/types.js +196 -195
- package/dist/components/ui/overlay/backdrop.esm.js +17 -16
- package/dist/components/ui/overlay/backdrop.js +17 -16
- package/dist/components/ui/overlay/focus-manager.esm.js +21 -19
- package/dist/components/ui/overlay/focus-manager.js +21 -19
- package/dist/components/ui/overlay/index.esm.js +22 -2
- package/dist/components/ui/overlay/index.js +22 -2
- package/dist/components/ui/overlay/modal.esm.js +38 -34
- package/dist/components/ui/overlay/modal.js +38 -34
- package/dist/components/ui/overlay/overlay-manager.esm.js +25 -20
- package/dist/components/ui/overlay/overlay-manager.js +25 -20
- package/dist/components/ui/overlay/popover.esm.js +74 -58
- package/dist/components/ui/overlay/popover.js +74 -58
- package/dist/components/ui/overlay/portal.esm.js +7 -7
- package/dist/components/ui/overlay/portal.js +7 -7
- package/dist/components/ui/overlay/tooltip.esm.js +54 -39
- package/dist/components/ui/overlay/tooltip.js +54 -39
- package/dist/components/ui/overlay/types.esm.js +132 -131
- package/dist/components/ui/overlay/types.js +132 -131
- package/dist/components/ui/performance-demo.esm.js +135 -88
- package/dist/components/ui/performance-demo.js +135 -88
- package/dist/components/ui/semantic-input-system-demo.esm.js +117 -80
- package/dist/components/ui/semantic-input-system-demo.js +117 -80
- package/dist/components/ui/theme-customizer.esm.js +84 -52
- package/dist/components/ui/theme-customizer.js +84 -52
- package/dist/components/ui/theme-preview.esm.js +95 -43
- package/dist/components/ui/theme-preview.js +95 -43
- package/dist/components/ui/theme-switcher.esm.js +70 -44
- package/dist/components/ui/theme-switcher.js +70 -44
- package/dist/components/ui/theme-toggle.esm.js +3 -3
- package/dist/components/ui/theme-toggle.js +3 -3
- package/dist/components/ui/token-demo.esm.js +33 -21
- package/dist/components/ui/token-demo.js +33 -21
- package/dist/components/ui/touch-demo.esm.js +102 -73
- package/dist/components/ui/touch-demo.js +102 -73
- package/dist/components/ui/touch-friendly-interface-demo.esm.js +102 -64
- package/dist/components/ui/touch-friendly-interface-demo.js +102 -64
- package/dist/components/ui/touch-friendly-interface.esm.js +85 -61
- package/dist/components/ui/touch-friendly-interface.js +85 -61
- package/dist/hooks/use-accessibility-support.esm.js +115 -85
- package/dist/hooks/use-accessibility-support.js +115 -85
- package/dist/hooks/use-adaptive-layout.esm.js +56 -33
- package/dist/hooks/use-adaptive-layout.js +56 -33
- package/dist/hooks/use-advanced-patterns.esm.js +57 -42
- package/dist/hooks/use-advanced-patterns.js +57 -42
- package/dist/hooks/use-advanced-transition-system.esm.js +112 -71
- package/dist/hooks/use-advanced-transition-system.js +112 -71
- package/dist/hooks/use-animation-profile.esm.js +63 -34
- package/dist/hooks/use-animation-profile.js +63 -34
- package/dist/hooks/use-battery-animations.esm.js +80 -55
- package/dist/hooks/use-battery-animations.js +80 -55
- package/dist/hooks/use-battery-conscious-loading.esm.js +166 -123
- package/dist/hooks/use-battery-conscious-loading.js +166 -123
- package/dist/hooks/use-battery-optimization.esm.js +78 -55
- package/dist/hooks/use-battery-optimization.js +78 -55
- package/dist/hooks/use-battery-status.esm.js +73 -51
- package/dist/hooks/use-battery-status.js +73 -51
- package/dist/hooks/use-component-performance.esm.js +62 -47
- package/dist/hooks/use-component-performance.js +62 -47
- package/dist/hooks/use-device-loading-states.esm.js +152 -109
- package/dist/hooks/use-device-loading-states.js +152 -109
- package/dist/hooks/use-device.esm.js +25 -14
- package/dist/hooks/use-device.js +25 -14
- package/dist/hooks/use-enterprise-mobile-experience.esm.js +137 -88
- package/dist/hooks/use-enterprise-mobile-experience.js +137 -88
- package/dist/hooks/use-form-feedback.esm.js +124 -81
- package/dist/hooks/use-form-feedback.js +124 -81
- package/dist/hooks/use-form-performance.esm.js +127 -92
- package/dist/hooks/use-form-performance.js +127 -92
- package/dist/hooks/use-frame-rate.esm.js +56 -37
- package/dist/hooks/use-frame-rate.js +56 -37
- package/dist/hooks/use-gestures.esm.js +96 -72
- package/dist/hooks/use-gestures.js +96 -72
- package/dist/hooks/use-hardware-acceleration.esm.js +65 -37
- package/dist/hooks/use-hardware-acceleration.js +65 -37
- package/dist/hooks/use-input-accessibility.esm.js +157 -119
- package/dist/hooks/use-input-accessibility.js +157 -119
- package/dist/hooks/use-input-performance.esm.js +139 -104
- package/dist/hooks/use-input-performance.js +139 -104
- package/dist/hooks/use-layout-performance.esm.js +50 -29
- package/dist/hooks/use-layout-performance.js +50 -29
- package/dist/hooks/use-loading-accessibility.esm.js +209 -169
- package/dist/hooks/use-loading-accessibility.js +209 -169
- package/dist/hooks/use-loading-performance.esm.js +117 -93
- package/dist/hooks/use-loading-performance.js +117 -93
- package/dist/hooks/use-memory-usage.esm.js +57 -38
- package/dist/hooks/use-memory-usage.js +57 -38
- package/dist/hooks/use-mobile-form-layout.esm.js +111 -74
- package/dist/hooks/use-mobile-form-layout.js +111 -74
- package/dist/hooks/use-mobile-form-validation.esm.js +211 -144
- package/dist/hooks/use-mobile-form-validation.js +211 -144
- package/dist/hooks/use-mobile-keyboard-optimization.esm.js +154 -113
- package/dist/hooks/use-mobile-keyboard-optimization.js +154 -113
- package/dist/hooks/use-mobile-layout.esm.js +73 -51
- package/dist/hooks/use-mobile-layout.js +73 -51
- package/dist/hooks/use-mobile-optimization.esm.js +72 -44
- package/dist/hooks/use-mobile-optimization.js +72 -44
- package/dist/hooks/use-mobile-skeleton.esm.js +97 -64
- package/dist/hooks/use-mobile-skeleton.js +97 -64
- package/dist/hooks/use-mobile-touch.esm.js +128 -93
- package/dist/hooks/use-mobile-touch.js +128 -93
- package/dist/hooks/use-performance-throttling.esm.js +72 -48
- package/dist/hooks/use-performance-throttling.js +72 -48
- package/dist/hooks/use-performance.esm.js +90 -52
- package/dist/hooks/use-performance.js +90 -52
- package/dist/hooks/use-reusable-architecture.esm.js +94 -65
- package/dist/hooks/use-reusable-architecture.js +94 -65
- package/dist/hooks/use-semantic-input-types.esm.js +166 -124
- package/dist/hooks/use-semantic-input-types.js +166 -124
- package/dist/hooks/use-semantic-input.esm.js +178 -126
- package/dist/hooks/use-semantic-input.js +178 -126
- package/dist/hooks/use-tablet-layout.esm.js +67 -38
- package/dist/hooks/use-tablet-layout.js +67 -38
- package/dist/hooks/use-touch-friendly-input.esm.js +193 -149
- package/dist/hooks/use-touch-friendly-input.js +193 -149
- package/dist/hooks/use-touch-friendly-interface.esm.js +99 -67
- package/dist/hooks/use-touch-friendly-interface.js +99 -67
- package/dist/hooks/use-touch-optimization.esm.js +99 -72
- package/dist/hooks/use-touch-optimization.js +99 -72
- package/dist/index.esm.js +289 -280
- package/dist/index.js +289 -280
- package/dist/lib/utils.esm.js +1 -1
- package/dist/lib/utils.js +1 -1
- package/dist/plugins/theme-css-generator.esm.js +104 -55
- package/dist/plugins/theme-css-generator.js +104 -55
- package/dist/provider.esm.js +4 -4
- package/dist/provider.js +4 -4
- package/dist/styles.css +1 -1
- package/dist/theme.esm.js +633 -468
- package/dist/theme.js +633 -468
- package/dist/themes/ThemeContext.esm.js +15 -15
- package/dist/themes/ThemeContext.js +15 -15
- package/dist/themes/ThemeProvider.esm.js +25 -22
- package/dist/themes/ThemeProvider.js +25 -22
- package/dist/themes/accessibility.esm.js +147 -108
- package/dist/themes/accessibility.js +147 -108
- package/dist/themes/aria-patterns.esm.js +198 -162
- package/dist/themes/aria-patterns.js +198 -162
- package/dist/themes/base-themes.esm.js +14 -11
- package/dist/themes/base-themes.js +14 -11
- package/dist/themes/colorManager.esm.js +101 -83
- package/dist/themes/colorManager.js +101 -83
- package/dist/themes/examples/dark-theme.esm.js +133 -103
- package/dist/themes/examples/dark-theme.js +133 -103
- package/dist/themes/examples/minimal-theme.esm.js +83 -61
- package/dist/themes/examples/minimal-theme.js +83 -61
- package/dist/themes/focus-management.esm.js +202 -143
- package/dist/themes/focus-management.js +202 -143
- package/dist/themes/fontLoader.esm.js +28 -19
- package/dist/themes/fontLoader.js +28 -19
- package/dist/themes/high-contrast.esm.js +152 -104
- package/dist/themes/high-contrast.js +152 -104
- package/dist/themes/inheritance.esm.js +35 -27
- package/dist/themes/inheritance.js +35 -27
- package/dist/themes/keyboard-navigation.esm.js +152 -123
- package/dist/themes/keyboard-navigation.js +152 -123
- package/dist/themes/motion-reduction.esm.js +193 -133
- package/dist/themes/motion-reduction.js +193 -133
- package/dist/themes/navigation.esm.js +146 -146
- package/dist/themes/navigation.js +146 -146
- package/dist/themes/screen-reader.esm.js +159 -94
- package/dist/themes/screen-reader.js +159 -94
- package/dist/themes/systemThemeDetector.esm.js +42 -34
- package/dist/themes/systemThemeDetector.js +42 -34
- package/dist/themes/themeCSSUpdater.esm.js +21 -9
- package/dist/themes/themeCSSUpdater.js +21 -9
- package/dist/themes/themePersistence.esm.js +68 -47
- package/dist/themes/themePersistence.js +68 -47
- package/dist/themes/themes/stan-design.esm.js +633 -468
- package/dist/themes/themes/stan-design.js +633 -468
- package/dist/themes/types.esm.js +301 -287
- package/dist/themes/types.js +301 -287
- package/dist/themes/useSystemTheme.esm.js +4 -4
- package/dist/themes/useSystemTheme.js +4 -4
- package/dist/themes/useTheme.esm.js +4 -4
- package/dist/themes/useTheme.js +4 -4
- package/dist/themes/validation.esm.js +128 -77
- package/dist/themes/validation.js +128 -77
- package/dist/tokens/index.esm.js +15 -4
- package/dist/tokens/index.js +15 -4
- package/dist/tokens/tokenExporter.esm.js +87 -61
- package/dist/tokens/tokenExporter.js +87 -61
- package/dist/tokens/tokenGenerator.esm.js +86 -77
- package/dist/tokens/tokenGenerator.js +86 -77
- package/dist/tokens/tokenManager.esm.js +64 -51
- package/dist/tokens/tokenManager.js +64 -51
- package/dist/tokens/tokenValidator.esm.js +193 -147
- package/dist/tokens/tokenValidator.js +193 -147
- package/dist/tokens/types.esm.js +49 -35
- package/dist/tokens/types.js +49 -35
- package/dist/utils/bundle-analyzer.esm.js +83 -65
- package/dist/utils/bundle-analyzer.js +83 -65
- package/dist/utils/bundle-splitting.esm.js +142 -117
- package/dist/utils/bundle-splitting.js +142 -117
- package/dist/utils/lazy-loading.esm.js +132 -106
- package/dist/utils/lazy-loading.js +132 -106
- package/dist/utils/performance-monitor.esm.js +170 -129
- package/dist/utils/performance-monitor.js +170 -129
- package/dist/utils/tree-shaking.esm.js +69 -61
- package/dist/utils/tree-shaking.js +69 -61
- package/package.json +1 -1
- package/src/index.ts +146 -146
|
@@ -2,22 +2,27 @@ import { screenReaderOptimizer } from './screen-reader';
|
|
|
2
2
|
|
|
3
3
|
// Motion reduction theme configuration
|
|
4
4
|
export interface MotionReductionThemeConfig {
|
|
5
|
-
motion
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
5
|
+
motion: {
|
|
6
|
+
reduced: boolean;
|
|
7
|
+
duration: {
|
|
8
|
+
fast: string;
|
|
9
|
+
normal: string;
|
|
10
|
+
slow: string;
|
|
9
11
|
};
|
|
10
|
-
easing
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
12
|
+
easing: {
|
|
13
|
+
ease: string;
|
|
14
|
+
easeIn: string;
|
|
15
|
+
easeOut: string;
|
|
16
|
+
easeInOut: string;
|
|
14
17
|
};
|
|
15
|
-
animations
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
18
|
+
animations: {
|
|
19
|
+
enabled: boolean;
|
|
20
|
+
type: 'none' | 'reduced' | 'full';
|
|
21
|
+
preferences: {
|
|
22
|
+
reduceMotion: boolean;
|
|
23
|
+
reduceAnimation: boolean;
|
|
24
|
+
reduceTransition: boolean;
|
|
25
|
+
reduceTransform: boolean;
|
|
21
26
|
};
|
|
22
27
|
};
|
|
23
28
|
};
|
|
@@ -25,13 +30,13 @@ export interface MotionReductionThemeConfig {
|
|
|
25
30
|
|
|
26
31
|
// Motion reduction utilities
|
|
27
32
|
export class MotionReductionManager {
|
|
28
|
-
private isReducedMotion= false;
|
|
29
|
-
private isReducedAnimation= false;
|
|
30
|
-
private isReducedTransition= false;
|
|
31
|
-
private isReducedTransform= false;
|
|
32
|
-
// private motionPreferences= new Set(); // Unused for now
|
|
33
|
-
private originalStyles, string> = new Map();
|
|
34
|
-
private reducedMotionStyles, string> = new Map();
|
|
33
|
+
private isReducedMotion: boolean = false;
|
|
34
|
+
private isReducedAnimation: boolean = false;
|
|
35
|
+
private isReducedTransition: boolean = false;
|
|
36
|
+
private isReducedTransform: boolean = false;
|
|
37
|
+
// private motionPreferences: Set<string> = new Set(); // Unused for now
|
|
38
|
+
private originalStyles: Map<HTMLElement, string> = new Map();
|
|
39
|
+
private reducedMotionStyles: Map<HTMLElement, string> = new Map();
|
|
35
40
|
|
|
36
41
|
constructor() {
|
|
37
42
|
this.initializeSystemPreference();
|
|
@@ -39,8 +44,9 @@ export class MotionReductionManager {
|
|
|
39
44
|
}
|
|
40
45
|
|
|
41
46
|
// Initialize system preference detection
|
|
42
|
-
private initializeSystemPreference()
|
|
43
|
-
|
|
47
|
+
private initializeSystemPreference(): void {
|
|
48
|
+
if (typeof window !== 'undefined' && window.matchMedia) {
|
|
49
|
+
const reducedMotionQuery = window.matchMedia('(prefers-reduced-motion: reduce)');
|
|
44
50
|
this.isReducedMotion = reducedMotionQuery.matches;
|
|
45
51
|
|
|
46
52
|
reducedMotionQuery.addEventListener('change', (e) => {
|
|
@@ -51,7 +57,9 @@ export class MotionReductionManager {
|
|
|
51
57
|
}
|
|
52
58
|
|
|
53
59
|
// Setup event listeners
|
|
54
|
-
private setupEventListeners()
|
|
60
|
+
private setupEventListeners(): void {
|
|
61
|
+
// Listen for preference changes
|
|
62
|
+
if (typeof window !== 'undefined') {
|
|
55
63
|
window.addEventListener('storage', (e) => {
|
|
56
64
|
if (e.key === 'motion-reduction-preferences') {
|
|
57
65
|
this.loadPreferences();
|
|
@@ -61,17 +69,20 @@ export class MotionReductionManager {
|
|
|
61
69
|
}
|
|
62
70
|
|
|
63
71
|
// Enable motion reduction
|
|
64
|
-
enable()
|
|
72
|
+
enable(): void {
|
|
73
|
+
this.isReducedMotion = true;
|
|
65
74
|
this.applyMotionReduction();
|
|
66
75
|
}
|
|
67
76
|
|
|
68
77
|
// Disable motion reduction
|
|
69
|
-
disable()
|
|
78
|
+
disable(): void {
|
|
79
|
+
this.isReducedMotion = false;
|
|
70
80
|
this.removeMotionReduction();
|
|
71
81
|
}
|
|
72
82
|
|
|
73
83
|
// Toggle motion reduction
|
|
74
|
-
toggle()
|
|
84
|
+
toggle(): void {
|
|
85
|
+
if (this.isReducedMotion) {
|
|
75
86
|
this.disable();
|
|
76
87
|
} else {
|
|
77
88
|
this.enable();
|
|
@@ -79,14 +90,17 @@ export class MotionReductionManager {
|
|
|
79
90
|
}
|
|
80
91
|
|
|
81
92
|
// Check if motion reduction is enabled
|
|
82
|
-
isMotionReduced()
|
|
93
|
+
isMotionReduced(): boolean {
|
|
94
|
+
return this.isReducedMotion;
|
|
83
95
|
}
|
|
84
96
|
|
|
85
97
|
// Set specific motion reduction preferences
|
|
86
|
-
setPreferences(preferences
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
98
|
+
setPreferences(preferences: {
|
|
99
|
+
reduceAnimation?: boolean;
|
|
100
|
+
reduceTransition?: boolean;
|
|
101
|
+
reduceTransform?: boolean;
|
|
102
|
+
}): void {
|
|
103
|
+
if (preferences.reduceAnimation !== undefined) {
|
|
90
104
|
this.isReducedAnimation = preferences.reduceAnimation;
|
|
91
105
|
}
|
|
92
106
|
if (preferences.reduceTransition !== undefined) {
|
|
@@ -101,20 +115,23 @@ export class MotionReductionManager {
|
|
|
101
115
|
}
|
|
102
116
|
|
|
103
117
|
// Get current motion reduction preferences
|
|
104
|
-
getPreferences()
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
118
|
+
getPreferences(): {
|
|
119
|
+
reduceMotion: boolean;
|
|
120
|
+
reduceAnimation: boolean;
|
|
121
|
+
reduceTransition: boolean;
|
|
122
|
+
reduceTransform: boolean;
|
|
108
123
|
} {
|
|
109
124
|
return {
|
|
110
|
-
reduceMotion,
|
|
111
|
-
reduceAnimation,
|
|
112
|
-
reduceTransition,
|
|
113
|
-
reduceTransform
|
|
125
|
+
reduceMotion: this.isReducedMotion,
|
|
126
|
+
reduceAnimation: this.isReducedAnimation,
|
|
127
|
+
reduceTransition: this.isReducedTransition,
|
|
128
|
+
reduceTransform: this.isReducedTransform
|
|
129
|
+
};
|
|
114
130
|
}
|
|
115
131
|
|
|
116
132
|
// Apply motion reduction to the document
|
|
117
|
-
applyMotionReduction()
|
|
133
|
+
applyMotionReduction(): void {
|
|
134
|
+
if (!this.isReducedMotion) return;
|
|
118
135
|
|
|
119
136
|
// Add reduced motion class to document
|
|
120
137
|
document.documentElement.classList.add('reduced-motion');
|
|
@@ -132,7 +149,9 @@ export class MotionReductionManager {
|
|
|
132
149
|
}
|
|
133
150
|
|
|
134
151
|
// Remove motion reduction from the document
|
|
135
|
-
removeMotionReduction()
|
|
152
|
+
removeMotionReduction(): void {
|
|
153
|
+
// Remove reduced motion class
|
|
154
|
+
document.documentElement.classList.remove('reduced-motion');
|
|
136
155
|
|
|
137
156
|
// Remove reduced motion styles
|
|
138
157
|
this.removeReducedMotionStyles();
|
|
@@ -147,61 +166,62 @@ export class MotionReductionManager {
|
|
|
147
166
|
}
|
|
148
167
|
|
|
149
168
|
// Apply reduced motion styles
|
|
150
|
-
private applyReducedMotionStyles()
|
|
169
|
+
private applyReducedMotionStyles(): void {
|
|
170
|
+
const style = document.createElement('style');
|
|
151
171
|
style.id = 'reduced-motion-styles';
|
|
152
172
|
|
|
153
173
|
style.textContent = `
|
|
154
174
|
.reduced-motion,
|
|
155
175
|
.reduced-motion * {
|
|
156
176
|
/* Disable animations */
|
|
157
|
-
animation-duration;
|
|
158
|
-
animation-iteration-count;
|
|
159
|
-
animation-delay;
|
|
177
|
+
animation-duration: 0.01ms !important;
|
|
178
|
+
animation-iteration-count: 1 !important;
|
|
179
|
+
animation-delay: 0s !important;
|
|
160
180
|
|
|
161
181
|
/* Disable transitions */
|
|
162
|
-
transition-duration;
|
|
163
|
-
transition-delay;
|
|
182
|
+
transition-duration: 0.01ms !important;
|
|
183
|
+
transition-delay: 0s !important;
|
|
164
184
|
|
|
165
185
|
/* Disable transforms */
|
|
166
|
-
transform;
|
|
186
|
+
transform: none !important;
|
|
167
187
|
|
|
168
188
|
/* Disable scroll behavior */
|
|
169
|
-
scroll-behavior;
|
|
189
|
+
scroll-behavior: auto !important;
|
|
170
190
|
}
|
|
171
191
|
|
|
172
192
|
.reduced-motion .motion-safe,
|
|
173
193
|
.reduced-motion *[data-motion-safe="true"] {
|
|
174
194
|
/* Allow safe motion for essential animations */
|
|
175
|
-
animation-duration;
|
|
176
|
-
transition-duration;
|
|
195
|
+
animation-duration: 150ms !important;
|
|
196
|
+
transition-duration: 150ms !important;
|
|
177
197
|
}
|
|
178
198
|
|
|
179
199
|
.reduced-motion .motion-reduce,
|
|
180
200
|
.reduced-motion *[data-motion-reduce="true"] {
|
|
181
201
|
/* Apply reduced motion for non-essential animations */
|
|
182
|
-
animation-duration;
|
|
183
|
-
transition-duration;
|
|
202
|
+
animation-duration: 50ms !important;
|
|
203
|
+
transition-duration: 50ms !important;
|
|
184
204
|
}
|
|
185
205
|
|
|
186
206
|
/* Specific component overrides */
|
|
187
207
|
.reduced-motion .modal,
|
|
188
208
|
.reduced-motion .tooltip,
|
|
189
209
|
.reduced-motion .popover {
|
|
190
|
-
animation;
|
|
191
|
-
transition;
|
|
210
|
+
animation: none !important;
|
|
211
|
+
transition: none !important;
|
|
192
212
|
}
|
|
193
213
|
|
|
194
214
|
.reduced-motion .skeleton {
|
|
195
|
-
animation;
|
|
215
|
+
animation: none !important;
|
|
196
216
|
}
|
|
197
217
|
|
|
198
218
|
.reduced-motion .progress-bar {
|
|
199
|
-
transition;
|
|
219
|
+
transition: none !important;
|
|
200
220
|
}
|
|
201
221
|
|
|
202
222
|
.reduced-motion .carousel,
|
|
203
223
|
.reduced-motion .slider {
|
|
204
|
-
scroll-behavior;
|
|
224
|
+
scroll-behavior: auto !important;
|
|
205
225
|
}
|
|
206
226
|
`;
|
|
207
227
|
|
|
@@ -209,14 +229,17 @@ export class MotionReductionManager {
|
|
|
209
229
|
}
|
|
210
230
|
|
|
211
231
|
// Remove reduced motion styles
|
|
212
|
-
private removeReducedMotionStyles()
|
|
232
|
+
private removeReducedMotionStyles(): void {
|
|
233
|
+
const style = document.getElementById('reduced-motion-styles');
|
|
213
234
|
if (style) {
|
|
214
235
|
style.remove();
|
|
215
236
|
}
|
|
216
237
|
}
|
|
217
238
|
|
|
218
239
|
// Process existing elements
|
|
219
|
-
private processExistingElements()
|
|
240
|
+
private processExistingElements(): void {
|
|
241
|
+
// Process elements with animations
|
|
242
|
+
const animatedElements = document.querySelectorAll('[class*="animate"], [class*="transition"], [class*="transform"]');
|
|
220
243
|
animatedElements.forEach(element => {
|
|
221
244
|
this.processElement(element as HTMLElement);
|
|
222
245
|
});
|
|
@@ -229,7 +252,9 @@ export class MotionReductionManager {
|
|
|
229
252
|
}
|
|
230
253
|
|
|
231
254
|
// Process individual element
|
|
232
|
-
private processElement(element)
|
|
255
|
+
private processElement(element: HTMLElement): void {
|
|
256
|
+
// Store original styles if not already stored
|
|
257
|
+
if (!this.originalStyles.has(element)) {
|
|
233
258
|
this.originalStyles.set(element, element.style.cssText);
|
|
234
259
|
}
|
|
235
260
|
|
|
@@ -242,33 +267,35 @@ export class MotionReductionManager {
|
|
|
242
267
|
}
|
|
243
268
|
|
|
244
269
|
// Get reduced motion styles for element
|
|
245
|
-
private getReducedMotionStyles(element)
|
|
270
|
+
private getReducedMotionStyles(element: HTMLElement): string {
|
|
271
|
+
const originalStyles = element.style.cssText;
|
|
246
272
|
|
|
247
273
|
let reducedStyles = originalStyles;
|
|
248
274
|
|
|
249
275
|
// Remove animation properties
|
|
250
276
|
if (this.isReducedAnimation) {
|
|
251
277
|
reducedStyles = reducedStyles.replace(/animation[^;]*;?/g, '');
|
|
252
|
-
reducedStyles += 'animation;';
|
|
278
|
+
reducedStyles += 'animation: none !important;';
|
|
253
279
|
}
|
|
254
280
|
|
|
255
281
|
// Remove transition properties
|
|
256
282
|
if (this.isReducedTransition) {
|
|
257
283
|
reducedStyles = reducedStyles.replace(/transition[^;]*;?/g, '');
|
|
258
|
-
reducedStyles += 'transition;';
|
|
284
|
+
reducedStyles += 'transition: none !important;';
|
|
259
285
|
}
|
|
260
286
|
|
|
261
287
|
// Remove transform properties
|
|
262
288
|
if (this.isReducedTransform) {
|
|
263
289
|
reducedStyles = reducedStyles.replace(/transform[^;]*;?/g, '');
|
|
264
|
-
reducedStyles += 'transform;';
|
|
290
|
+
reducedStyles += 'transform: none !important;';
|
|
265
291
|
}
|
|
266
292
|
|
|
267
293
|
return reducedStyles;
|
|
268
294
|
}
|
|
269
295
|
|
|
270
296
|
// Restore original styles
|
|
271
|
-
private restoreOriginalStyles()
|
|
297
|
+
private restoreOriginalStyles(): void {
|
|
298
|
+
this.originalStyles.forEach((originalStyle, element) => {
|
|
272
299
|
if (element && element.offsetParent !== null) {
|
|
273
300
|
element.style.cssText = originalStyle;
|
|
274
301
|
}
|
|
@@ -279,12 +306,13 @@ export class MotionReductionManager {
|
|
|
279
306
|
}
|
|
280
307
|
|
|
281
308
|
// Save preferences to localStorage
|
|
282
|
-
private savePreferences()
|
|
309
|
+
private savePreferences(): void {
|
|
310
|
+
if (typeof window !== 'undefined' && window.localStorage) {
|
|
283
311
|
const preferences = {
|
|
284
|
-
reduceAnimation,
|
|
285
|
-
reduceTransition,
|
|
286
|
-
reduceTransform,
|
|
287
|
-
timestamp)
|
|
312
|
+
reduceAnimation: this.isReducedAnimation,
|
|
313
|
+
reduceTransition: this.isReducedTransition,
|
|
314
|
+
reduceTransform: this.isReducedTransform,
|
|
315
|
+
timestamp: Date.now()
|
|
288
316
|
};
|
|
289
317
|
|
|
290
318
|
window.localStorage.setItem('motion-reduction-preferences', JSON.stringify(preferences));
|
|
@@ -292,7 +320,8 @@ export class MotionReductionManager {
|
|
|
292
320
|
}
|
|
293
321
|
|
|
294
322
|
// Load preferences from localStorage
|
|
295
|
-
private loadPreferences()
|
|
323
|
+
private loadPreferences(): void {
|
|
324
|
+
if (typeof window !== 'undefined' && window.localStorage) {
|
|
296
325
|
try {
|
|
297
326
|
const stored = window.localStorage.getItem('motion-reduction-preferences');
|
|
298
327
|
if (stored) {
|
|
@@ -303,13 +332,14 @@ export class MotionReductionManager {
|
|
|
303
332
|
this.isReducedTransform = preferences.reduceTransform || false;
|
|
304
333
|
}
|
|
305
334
|
} catch (error) {
|
|
306
|
-
console.warn('Failed to load motion reduction preferences, error);
|
|
335
|
+
console.warn('Failed to load motion reduction preferences:', error);
|
|
307
336
|
}
|
|
308
337
|
}
|
|
309
338
|
}
|
|
310
339
|
|
|
311
340
|
// Check if element should have motion reduced
|
|
312
|
-
shouldReduceMotion(element)
|
|
341
|
+
shouldReduceMotion(element: HTMLElement): boolean {
|
|
342
|
+
if (!this.isReducedMotion) return false;
|
|
313
343
|
|
|
314
344
|
// Check for motion-safe override
|
|
315
345
|
if (element.classList.contains('motion-safe') || element.getAttribute('data-motion-safe') === 'true') {
|
|
@@ -325,7 +355,8 @@ export class MotionReductionManager {
|
|
|
325
355
|
}
|
|
326
356
|
|
|
327
357
|
// Get appropriate duration for element
|
|
328
|
-
getDuration(element, defaultDuration, type)
|
|
358
|
+
getDuration(element: HTMLElement, defaultDuration: string, type: 'animation' | 'transition'): string {
|
|
359
|
+
if (!this.shouldReduceMotion(element)) {
|
|
329
360
|
return defaultDuration;
|
|
330
361
|
}
|
|
331
362
|
|
|
@@ -334,14 +365,15 @@ export class MotionReductionManager {
|
|
|
334
365
|
const unit = defaultDuration.replace(/[\d.]/g, '');
|
|
335
366
|
|
|
336
367
|
if (type === 'animation') {
|
|
337
|
-
return this.isReducedAnimation ? '0.01ms' , 50)}${unit}`;
|
|
368
|
+
return this.isReducedAnimation ? '0.01ms' : `${Math.min(duration * 0.1, 50)}${unit}`;
|
|
338
369
|
} else {
|
|
339
|
-
return this.isReducedTransition ? '0.01ms' , 50)}${unit}`;
|
|
370
|
+
return this.isReducedTransition ? '0.01ms' : `${Math.min(duration * 0.1, 50)}${unit}`;
|
|
340
371
|
}
|
|
341
372
|
}
|
|
342
373
|
|
|
343
374
|
// Get appropriate easing for element
|
|
344
|
-
getEasing(element, defaultEasing)
|
|
375
|
+
getEasing(element: HTMLElement, defaultEasing: string): string {
|
|
376
|
+
if (!this.shouldReduceMotion(element)) {
|
|
345
377
|
return defaultEasing;
|
|
346
378
|
}
|
|
347
379
|
|
|
@@ -350,7 +382,8 @@ export class MotionReductionManager {
|
|
|
350
382
|
}
|
|
351
383
|
|
|
352
384
|
// Create motion-safe wrapper
|
|
353
|
-
createMotionSafeWrapper(element, callback) => void)
|
|
385
|
+
createMotionSafeWrapper(element: HTMLElement, callback: () => void): void {
|
|
386
|
+
if (!this.shouldReduceMotion(element)) {
|
|
354
387
|
callback();
|
|
355
388
|
return;
|
|
356
389
|
}
|
|
@@ -368,14 +401,17 @@ export class MotionReductionManager {
|
|
|
368
401
|
|
|
369
402
|
// Animate element with motion reduction awareness
|
|
370
403
|
animateElement(
|
|
371
|
-
element,
|
|
372
|
-
keyframes],
|
|
373
|
-
options
|
|
404
|
+
element: HTMLElement,
|
|
405
|
+
keyframes: Keyframe[],
|
|
406
|
+
options: KeyframeAnimationOptions
|
|
407
|
+
): Animation {
|
|
408
|
+
if (this.shouldReduceMotion(element)) {
|
|
374
409
|
// Apply reduced motion options
|
|
375
410
|
const reducedOptions = {
|
|
376
411
|
...options,
|
|
377
|
-
duration=== 'number' ? options.duration , 50),
|
|
378
|
-
easing
|
|
412
|
+
duration: Math.min(typeof options.duration === 'number' ? options.duration : 300, 50),
|
|
413
|
+
easing: 'linear'
|
|
414
|
+
};
|
|
379
415
|
|
|
380
416
|
return element.animate(keyframes, reducedOptions);
|
|
381
417
|
}
|
|
@@ -384,14 +420,14 @@ export class MotionReductionManager {
|
|
|
384
420
|
}
|
|
385
421
|
|
|
386
422
|
// Add motion reduction observer
|
|
387
|
-
addMotionReductionObserver(callback) => void)) => void {
|
|
423
|
+
addMotionReductionObserver(callback: (isReduced: boolean) => void): () => void {
|
|
388
424
|
const observer = new MutationObserver(() => {
|
|
389
425
|
callback(this.isReducedMotion);
|
|
390
426
|
});
|
|
391
427
|
|
|
392
428
|
observer.observe(document.documentElement, {
|
|
393
|
-
attributes,
|
|
394
|
-
attributeFilter]
|
|
429
|
+
attributes: true,
|
|
430
|
+
attributeFilter: ['class']
|
|
395
431
|
});
|
|
396
432
|
|
|
397
433
|
// Return cleanup function
|
|
@@ -399,13 +435,15 @@ export class MotionReductionManager {
|
|
|
399
435
|
}
|
|
400
436
|
|
|
401
437
|
// Get motion reduction statistics
|
|
402
|
-
getStatistics()
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
438
|
+
getStatistics(): {
|
|
439
|
+
totalElements: number;
|
|
440
|
+
reducedElements: number;
|
|
441
|
+
safeElements: number;
|
|
442
|
+
preferences: {
|
|
443
|
+
reduceMotion: boolean;
|
|
444
|
+
reduceAnimation: boolean;
|
|
445
|
+
reduceTransition: boolean;
|
|
446
|
+
reduceTransform: boolean;
|
|
409
447
|
};
|
|
410
448
|
} {
|
|
411
449
|
const totalElements = document.querySelectorAll('*').length;
|
|
@@ -416,12 +454,13 @@ export class MotionReductionManager {
|
|
|
416
454
|
totalElements,
|
|
417
455
|
reducedElements,
|
|
418
456
|
safeElements,
|
|
419
|
-
preferences)
|
|
457
|
+
preferences: this.getPreferences()
|
|
420
458
|
};
|
|
421
459
|
}
|
|
422
460
|
|
|
423
461
|
// Reset all motion reduction settings
|
|
424
|
-
reset()
|
|
462
|
+
reset(): void {
|
|
463
|
+
this.isReducedMotion = false;
|
|
425
464
|
this.isReducedAnimation = false;
|
|
426
465
|
this.isReducedTransition = false;
|
|
427
466
|
this.isReducedTransform = false;
|
|
@@ -431,7 +470,8 @@ export class MotionReductionManager {
|
|
|
431
470
|
}
|
|
432
471
|
|
|
433
472
|
// Clear stored preferences
|
|
434
|
-
private clearPreferences()
|
|
473
|
+
private clearPreferences(): void {
|
|
474
|
+
if (typeof window !== 'undefined' && window.localStorage) {
|
|
435
475
|
window.localStorage.removeItem('motion-reduction-preferences');
|
|
436
476
|
}
|
|
437
477
|
|
|
@@ -440,7 +480,8 @@ export class MotionReductionManager {
|
|
|
440
480
|
}
|
|
441
481
|
|
|
442
482
|
// Destroy motion reduction manager
|
|
443
|
-
destroy()
|
|
483
|
+
destroy(): void {
|
|
484
|
+
this.removeMotionReduction();
|
|
444
485
|
this.clearPreferences();
|
|
445
486
|
|
|
446
487
|
// Remove event listeners
|
|
@@ -453,8 +494,10 @@ export class MotionReductionManager {
|
|
|
453
494
|
// Motion reduction utilities
|
|
454
495
|
export class MotionReductionUtils {
|
|
455
496
|
// Check if motion should be reduced for element
|
|
456
|
-
static shouldReduceMotion(element)
|
|
457
|
-
|
|
497
|
+
static shouldReduceMotion(element: HTMLElement): boolean {
|
|
498
|
+
// Check system preference
|
|
499
|
+
if (typeof window !== 'undefined' && window.matchMedia) {
|
|
500
|
+
const reducedMotionQuery = window.matchMedia('(prefers-reduced-motion: reduce)');
|
|
458
501
|
if (reducedMotionQuery.matches) return true;
|
|
459
502
|
}
|
|
460
503
|
|
|
@@ -471,21 +514,25 @@ export class MotionReductionUtils {
|
|
|
471
514
|
}
|
|
472
515
|
|
|
473
516
|
// Get reduced duration
|
|
474
|
-
static getReducedDuration(duration, reductionFactor= 0.1)
|
|
517
|
+
static getReducedDuration(duration: string, reductionFactor: number = 0.1): string {
|
|
518
|
+
const parsed = parseFloat(duration);
|
|
475
519
|
const unit = duration.replace(/[\d.]/g, '');
|
|
476
520
|
|
|
477
521
|
return `${Math.max(parsed * reductionFactor, 1)}${unit}`;
|
|
478
522
|
}
|
|
479
523
|
|
|
480
524
|
// Get reduced easing
|
|
481
|
-
static getReducedEasing(_easing)
|
|
525
|
+
static getReducedEasing(_easing: string): string {
|
|
526
|
+
return 'linear';
|
|
482
527
|
}
|
|
483
528
|
|
|
484
529
|
// Create motion-safe animation
|
|
485
530
|
static createMotionSafeAnimation(
|
|
486
|
-
element,
|
|
487
|
-
keyframes],
|
|
488
|
-
options
|
|
531
|
+
element: HTMLElement,
|
|
532
|
+
keyframes: Keyframe[],
|
|
533
|
+
options: KeyframeAnimationOptions
|
|
534
|
+
): Animation | null {
|
|
535
|
+
if (this.shouldReduceMotion(element)) {
|
|
489
536
|
// Return null to indicate no animation should be performed
|
|
490
537
|
return null;
|
|
491
538
|
}
|
|
@@ -494,7 +541,8 @@ export class MotionReductionUtils {
|
|
|
494
541
|
}
|
|
495
542
|
|
|
496
543
|
// Apply motion reduction to CSS custom properties
|
|
497
|
-
static applyMotionReductionToCSS(element)
|
|
544
|
+
static applyMotionReductionToCSS(element: HTMLElement): void {
|
|
545
|
+
if (!this.shouldReduceMotion(element)) return;
|
|
498
546
|
|
|
499
547
|
const style = element.style;
|
|
500
548
|
|
|
@@ -521,7 +569,8 @@ export class MotionReductionUtils {
|
|
|
521
569
|
}
|
|
522
570
|
|
|
523
571
|
// Remove motion reduction from CSS custom properties
|
|
524
|
-
static removeMotionReductionFromCSS(element)
|
|
572
|
+
static removeMotionReductionFromCSS(element: HTMLElement): void {
|
|
573
|
+
const style = element.style;
|
|
525
574
|
|
|
526
575
|
// Remove custom properties
|
|
527
576
|
style.removeProperty('--animation-duration');
|
|
@@ -531,7 +580,8 @@ export class MotionReductionUtils {
|
|
|
531
580
|
}
|
|
532
581
|
|
|
533
582
|
// Check if element has motion
|
|
534
|
-
static hasMotion(element)
|
|
583
|
+
static hasMotion(element: HTMLElement): boolean {
|
|
584
|
+
const computedStyle = window.getComputedStyle(element);
|
|
535
585
|
|
|
536
586
|
return (
|
|
537
587
|
computedStyle.animation !== 'none' ||
|
|
@@ -541,52 +591,62 @@ export class MotionReductionUtils {
|
|
|
541
591
|
}
|
|
542
592
|
|
|
543
593
|
// Get motion information for element
|
|
544
|
-
static getMotionInfo(element)
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
594
|
+
static getMotionInfo(element: HTMLElement): {
|
|
595
|
+
hasAnimation: boolean;
|
|
596
|
+
hasTransition: boolean;
|
|
597
|
+
hasTransform: boolean;
|
|
598
|
+
animationDuration: string;
|
|
599
|
+
transitionDuration: string;
|
|
600
|
+
transform: string;
|
|
550
601
|
} {
|
|
551
602
|
const computedStyle = window.getComputedStyle(element);
|
|
552
603
|
|
|
553
604
|
return {
|
|
554
|
-
hasAnimation
|
|
555
|
-
hasTransition
|
|
556
|
-
hasTransform
|
|
557
|
-
animationDuration,
|
|
558
|
-
transitionDuration,
|
|
559
|
-
transform
|
|
605
|
+
hasAnimation: computedStyle.animation !== 'none',
|
|
606
|
+
hasTransition: computedStyle.transition !== 'all 0s ease 0s',
|
|
607
|
+
hasTransform: computedStyle.transform !== 'none',
|
|
608
|
+
animationDuration: computedStyle.animationDuration,
|
|
609
|
+
transitionDuration: computedStyle.transitionDuration,
|
|
610
|
+
transform: computedStyle.transform
|
|
611
|
+
};
|
|
560
612
|
}
|
|
561
613
|
}
|
|
562
614
|
|
|
563
615
|
// Motion reduction hooks for React
|
|
564
616
|
export class MotionReductionHooks {
|
|
565
617
|
// Get motion reduction state
|
|
566
|
-
static useMotionReduction()
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
618
|
+
static useMotionReduction(): {
|
|
619
|
+
isReduced: boolean;
|
|
620
|
+
preferences: {
|
|
621
|
+
reduceAnimation: boolean;
|
|
622
|
+
reduceTransition: boolean;
|
|
623
|
+
reduceTransform: boolean;
|
|
570
624
|
};
|
|
571
|
-
shouldReduceMotion) => boolean;
|
|
625
|
+
shouldReduceMotion: (element: HTMLElement) => boolean;
|
|
572
626
|
} {
|
|
573
627
|
// This would be implemented in a React component
|
|
574
628
|
// For now, return a mock implementation
|
|
575
629
|
return {
|
|
576
|
-
isReduced,
|
|
577
|
-
preferences
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
630
|
+
isReduced: false,
|
|
631
|
+
preferences: {
|
|
632
|
+
reduceAnimation: false,
|
|
633
|
+
reduceTransition: false,
|
|
634
|
+
reduceTransform: false
|
|
635
|
+
},
|
|
636
|
+
shouldReduceMotion: () => false
|
|
581
637
|
};
|
|
582
638
|
}
|
|
583
639
|
|
|
584
640
|
// Get motion-safe duration
|
|
585
|
-
static useMotionSafeDuration(defaultDuration, _type)
|
|
641
|
+
static useMotionSafeDuration(defaultDuration: string, _type: 'animation' | 'transition'): string {
|
|
642
|
+
// This would be implemented in a React component
|
|
643
|
+
return defaultDuration;
|
|
586
644
|
}
|
|
587
645
|
|
|
588
646
|
// Get motion-safe easing
|
|
589
|
-
static useMotionSafeEasing(defaultEasing)
|
|
647
|
+
static useMotionSafeEasing(defaultEasing: string): string {
|
|
648
|
+
// This would be implemented in a React component
|
|
649
|
+
return defaultEasing;
|
|
590
650
|
}
|
|
591
651
|
}
|
|
592
652
|
|