@rakeyshgidwani/roger-ui-bank-theme-stan-design 0.1.4 → 0.1.6
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/index.d.ts +131 -131
- package/dist/index.esm.js +148 -148
- package/dist/index.js +148 -148
- package/dist/styles.css +1 -1
- package/package.json +1 -1
- package/src/components/ui/accessibility-demo.tsx +271 -0
- package/src/components/ui/advanced-component-architecture-demo.tsx +916 -0
- package/src/components/ui/advanced-transition-system-demo.tsx +670 -0
- package/src/components/ui/advanced-transition-system.tsx +395 -0
- package/src/components/ui/animation/animated-container.tsx +166 -0
- package/src/components/ui/animation/index.ts +19 -0
- package/src/components/ui/animation/staggered-container.tsx +68 -0
- package/src/components/ui/animation-demo.tsx +250 -0
- package/src/components/ui/badge.tsx +33 -0
- package/src/components/ui/battery-conscious-animation-demo.tsx +568 -0
- package/src/components/ui/border-radius-shadow-demo.tsx +187 -0
- package/src/components/ui/button.tsx +36 -0
- package/src/components/ui/card.tsx +207 -0
- package/src/components/ui/checkbox.tsx +30 -0
- package/src/components/ui/color-preview.tsx +411 -0
- package/src/components/ui/data-display/chart.tsx +653 -0
- package/src/components/ui/data-display/data-grid-simple.tsx +76 -0
- package/src/components/ui/data-display/data-grid.tsx +680 -0
- package/src/components/ui/data-display/list.tsx +456 -0
- package/src/components/ui/data-display/table.tsx +482 -0
- package/src/components/ui/data-display/timeline.tsx +441 -0
- package/src/components/ui/data-display/tree.tsx +602 -0
- package/src/components/ui/data-display/types.ts +536 -0
- package/src/components/ui/enterprise-mobile-experience-demo.tsx +749 -0
- package/src/components/ui/enterprise-mobile-experience.tsx +464 -0
- package/src/components/ui/feedback/alert.tsx +157 -0
- package/src/components/ui/feedback/progress.tsx +292 -0
- package/src/components/ui/feedback/skeleton.tsx +185 -0
- package/src/components/ui/feedback/toast.tsx +280 -0
- package/src/components/ui/feedback/types.ts +125 -0
- package/src/components/ui/font-preview.tsx +288 -0
- package/src/components/ui/form-demo.tsx +553 -0
- package/src/components/ui/hardware-acceleration-demo.tsx +547 -0
- package/src/components/ui/input.tsx +35 -0
- package/src/components/ui/label.tsx +16 -0
- package/src/components/ui/layout-demo.tsx +367 -0
- package/src/components/ui/layouts/adaptive-layout.tsx +139 -0
- package/src/components/ui/layouts/desktop-layout.tsx +224 -0
- package/src/components/ui/layouts/index.ts +10 -0
- package/src/components/ui/layouts/mobile-layout.tsx +162 -0
- package/src/components/ui/layouts/tablet-layout.tsx +197 -0
- package/src/components/ui/mobile-form-validation.tsx +451 -0
- package/src/components/ui/mobile-input-demo.tsx +201 -0
- package/src/components/ui/mobile-input.tsx +281 -0
- package/src/components/ui/mobile-skeleton-loading-demo.tsx +638 -0
- package/src/components/ui/navigation/breadcrumb.tsx +158 -0
- package/src/components/ui/navigation/index.ts +36 -0
- package/src/components/ui/navigation/menu.tsx +374 -0
- package/src/components/ui/navigation/navigation-demo.tsx +324 -0
- package/src/components/ui/navigation/pagination.tsx +272 -0
- package/src/components/ui/navigation/sidebar.tsx +383 -0
- package/src/components/ui/navigation/stepper.tsx +303 -0
- package/src/components/ui/navigation/tabs.tsx +205 -0
- package/src/components/ui/navigation/types.ts +299 -0
- package/src/components/ui/overlay/backdrop.tsx +81 -0
- package/src/components/ui/overlay/focus-manager.tsx +143 -0
- package/src/components/ui/overlay/index.ts +36 -0
- package/src/components/ui/overlay/modal.tsx +270 -0
- package/src/components/ui/overlay/overlay-manager.tsx +110 -0
- package/src/components/ui/overlay/popover.tsx +462 -0
- package/src/components/ui/overlay/portal.tsx +79 -0
- package/src/components/ui/overlay/tooltip.tsx +303 -0
- package/src/components/ui/overlay/types.ts +196 -0
- package/src/components/ui/performance-demo.tsx +596 -0
- package/src/components/ui/semantic-input-system-demo.tsx +502 -0
- package/src/components/ui/semantic-input-system-demo.tsx.disabled +873 -0
- package/src/components/ui/tablet-layout.tsx +192 -0
- package/src/components/ui/theme-customizer.tsx +386 -0
- package/src/components/ui/theme-preview.tsx +310 -0
- package/src/components/ui/theme-switcher.tsx +264 -0
- package/src/components/ui/theme-toggle.tsx +38 -0
- package/src/components/ui/token-demo.tsx +195 -0
- package/src/components/ui/touch-demo.tsx +462 -0
- package/src/components/ui/touch-friendly-interface-demo.tsx +519 -0
- package/src/components/ui/touch-friendly-interface.tsx +296 -0
- package/src/hooks/index.ts +190 -0
- package/src/hooks/use-accessibility-support.ts +518 -0
- package/src/hooks/use-adaptive-layout.ts +289 -0
- package/src/hooks/use-advanced-patterns.ts +294 -0
- package/src/hooks/use-advanced-transition-system.ts +393 -0
- package/src/hooks/use-animation-profile.ts +288 -0
- package/src/hooks/use-battery-animations.ts +384 -0
- package/src/hooks/use-battery-conscious-loading.ts +475 -0
- package/src/hooks/use-battery-optimization.ts +330 -0
- package/src/hooks/use-battery-status.ts +299 -0
- package/src/hooks/use-component-performance.ts +344 -0
- package/src/hooks/use-device-loading-states.ts +459 -0
- package/src/hooks/use-device.tsx +110 -0
- package/src/hooks/use-enterprise-mobile-experience.ts +488 -0
- package/src/hooks/use-form-feedback.ts +403 -0
- package/src/hooks/use-form-performance.ts +513 -0
- package/src/hooks/use-frame-rate.ts +251 -0
- package/src/hooks/use-gestures.ts +338 -0
- package/src/hooks/use-hardware-acceleration.ts +341 -0
- package/src/hooks/use-input-accessibility.ts +455 -0
- package/src/hooks/use-input-performance.ts +506 -0
- package/src/hooks/use-layout-performance.ts +319 -0
- package/src/hooks/use-loading-accessibility.ts +535 -0
- package/src/hooks/use-loading-performance.ts +473 -0
- package/src/hooks/use-memory-usage.ts +287 -0
- package/src/hooks/use-mobile-form-layout.ts +464 -0
- package/src/hooks/use-mobile-form-validation.ts +518 -0
- package/src/hooks/use-mobile-keyboard-optimization.ts +472 -0
- package/src/hooks/use-mobile-layout.ts +302 -0
- package/src/hooks/use-mobile-optimization.ts +406 -0
- package/src/hooks/use-mobile-skeleton.ts +402 -0
- package/src/hooks/use-mobile-touch.ts +414 -0
- package/src/hooks/use-performance-throttling.ts +348 -0
- package/src/hooks/use-performance.ts +316 -0
- package/src/hooks/use-reusable-architecture.ts +414 -0
- package/src/hooks/use-semantic-input-types.ts +357 -0
- package/src/hooks/use-semantic-input.ts +565 -0
- package/src/hooks/use-tablet-layout.ts +384 -0
- package/src/hooks/use-touch-friendly-input.ts +524 -0
- package/src/hooks/use-touch-friendly-interface.ts +331 -0
- package/src/hooks/use-touch-optimization.ts +375 -0
- package/src/index.ts +279 -279
- package/src/lib/utils.ts +6 -0
- package/src/themes/README.md +272 -0
- package/src/themes/ThemeContext.tsx +31 -0
- package/src/themes/ThemeProvider.tsx +232 -0
- package/src/themes/accessibility/index.ts +27 -0
- package/src/themes/accessibility.ts +259 -0
- package/src/themes/aria-patterns.ts +420 -0
- package/src/themes/base-themes.ts +55 -0
- package/src/themes/colorManager.ts +380 -0
- package/src/themes/examples/dark-theme.ts +154 -0
- package/src/themes/examples/minimal-theme.ts +108 -0
- package/src/themes/focus-management.ts +701 -0
- package/src/themes/fontLoader.ts +201 -0
- package/src/themes/high-contrast.ts +621 -0
- package/src/themes/index.ts +19 -0
- package/src/themes/inheritance.ts +227 -0
- package/src/themes/keyboard-navigation.ts +550 -0
- package/src/themes/motion-reduction.ts +662 -0
- package/src/themes/navigation.ts +238 -0
- package/src/themes/screen-reader.ts +645 -0
- package/src/themes/systemThemeDetector.ts +182 -0
- package/src/themes/themeCSSUpdater.ts +262 -0
- package/src/themes/themePersistence.ts +238 -0
- package/src/themes/themes/default.ts +586 -0
- package/src/themes/themes/harvey.ts +554 -0
- package/src/themes/themes/stan-design.ts +683 -0
- package/src/themes/types.ts +460 -0
- package/src/themes/useSystemTheme.ts +48 -0
- package/src/themes/useTheme.ts +87 -0
- package/src/themes/validation.ts +462 -0
- package/src/tokens/index.ts +34 -0
- package/src/tokens/tokenExporter.ts +397 -0
- package/src/tokens/tokenGenerator.ts +276 -0
- package/src/tokens/tokenManager.ts +248 -0
- package/src/tokens/tokenValidator.ts +543 -0
- package/src/tokens/types.ts +78 -0
- package/src/utils/bundle-analyzer.ts +260 -0
- package/src/utils/bundle-splitting.ts +483 -0
- package/src/utils/lazy-loading.ts +441 -0
- package/src/utils/performance-monitor.ts +513 -0
- package/src/utils/tree-shaking.ts +274 -0
|
@@ -0,0 +1,568 @@
|
|
|
1
|
+
import React, { useState, useCallback } from 'react'
|
|
2
|
+
import { Card, CardContent, CardDescription, CardHeader, CardTitle } from './card'
|
|
3
|
+
import { Badge } from './badge'
|
|
4
|
+
import { Button } from './button'
|
|
5
|
+
import { useBatteryAnimations } from '../../hooks/use-battery-animations'
|
|
6
|
+
import { usePerformanceThrottling } from '../../hooks/use-performance-throttling'
|
|
7
|
+
|
|
8
|
+
export const BatteryConsciousAnimationDemo: React.FC = () => {
|
|
9
|
+
const [showBatteryInfo, setShowBatteryInfo] = useState(true)
|
|
10
|
+
const [showPerformanceInfo, setShowPerformanceInfo] = useState(true)
|
|
11
|
+
const [showAnimationDemo, setShowAnimationDemo] = useState(true)
|
|
12
|
+
const [showControls] = useState(true)
|
|
13
|
+
|
|
14
|
+
// Animation states
|
|
15
|
+
const [animationState, setAnimationState] = useState<'idle' | 'running' | 'paused'>('idle')
|
|
16
|
+
const [animationType, setAnimationType] = useState<'battery' | 'performance' | 'reduced-motion' | 'user-preference'>('battery')
|
|
17
|
+
const [animationComplexity, setAnimationComplexity] = useState<'low' | 'medium' | 'high'>('medium')
|
|
18
|
+
|
|
19
|
+
// Hooks
|
|
20
|
+
const batteryAnimations = useBatteryAnimations({
|
|
21
|
+
enableBatteryMonitoring: true,
|
|
22
|
+
enablePerformanceThrottling: true,
|
|
23
|
+
enableReducedMotion: true,
|
|
24
|
+
enableUserPreferences: true,
|
|
25
|
+
enableAutomaticOptimization: true
|
|
26
|
+
}, {
|
|
27
|
+
onBatteryLevelChange: (level, isLow) => console.log('Battery level changed:', level, isLow),
|
|
28
|
+
onPerformanceWarning: (score, shouldThrottle) => console.log('Performance warning:', score, shouldThrottle),
|
|
29
|
+
onAnimationThrottled: (level, reason) => console.log('Animation throttled:', level, reason),
|
|
30
|
+
onUserPreferenceChange: (preference) => console.log('User preference changed:', preference),
|
|
31
|
+
onReducedMotionChange: (enabled) => console.log('Reduced motion changed:', enabled)
|
|
32
|
+
})
|
|
33
|
+
|
|
34
|
+
const performanceThrottling = usePerformanceThrottling({
|
|
35
|
+
enablePerformanceMonitoring: true,
|
|
36
|
+
enableAutomaticThrottling: true,
|
|
37
|
+
enableUserExperienceOptimization: true,
|
|
38
|
+
enableBatteryPreservation: true
|
|
39
|
+
}, {
|
|
40
|
+
onPerformanceWarning: (metrics) => console.log('Performance warning:', metrics),
|
|
41
|
+
onThrottlingApplied: (level, reason) => console.log('Throttling applied:', level, reason),
|
|
42
|
+
onPerformanceRecovery: (metrics) => console.log('Performance recovery:', metrics),
|
|
43
|
+
onUserExperienceOptimized: (optimization) => console.log('User experience optimized:', optimization)
|
|
44
|
+
})
|
|
45
|
+
|
|
46
|
+
// Animation controls
|
|
47
|
+
const startAnimation = useCallback(() => {
|
|
48
|
+
setAnimationState('running')
|
|
49
|
+
setTimeout(() => setAnimationState('idle'), 3000)
|
|
50
|
+
}, [])
|
|
51
|
+
|
|
52
|
+
const pauseAnimation = useCallback(() => {
|
|
53
|
+
setAnimationState('paused')
|
|
54
|
+
}, [])
|
|
55
|
+
|
|
56
|
+
const resumeAnimation = useCallback(() => {
|
|
57
|
+
setAnimationState('running')
|
|
58
|
+
}, [])
|
|
59
|
+
|
|
60
|
+
// Get animation classes based on current state
|
|
61
|
+
const getAnimationClasses = useCallback(() => {
|
|
62
|
+
const baseClasses = 'w-32 h-32 rounded-lg transition-all duration-1000 ease-in-out'
|
|
63
|
+
|
|
64
|
+
// Base battery-conscious animation
|
|
65
|
+
let classes = `${baseClasses} battery-conscious-animation`
|
|
66
|
+
|
|
67
|
+
// Add battery-specific classes
|
|
68
|
+
if (batteryAnimations.state.isCriticalBattery) {
|
|
69
|
+
classes += ' battery-critical-animation'
|
|
70
|
+
} else if (batteryAnimations.state.isLowBattery) {
|
|
71
|
+
classes += ' battery-optimized-animation'
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
// Add performance throttling classes
|
|
75
|
+
if (performanceThrottling.throttleLevel === 'aggressive') {
|
|
76
|
+
classes += ' performance-throttled-aggressive'
|
|
77
|
+
} else if (performanceThrottling.throttleLevel === 'moderate') {
|
|
78
|
+
classes += ' performance-throttled-moderate'
|
|
79
|
+
} else if (performanceThrottling.throttleLevel === 'light') {
|
|
80
|
+
classes += ' performance-throttled-light'
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
// Add complexity classes
|
|
84
|
+
if (animationComplexity === 'low') {
|
|
85
|
+
classes += ' animation-complexity-low'
|
|
86
|
+
} else if (animationComplexity === 'high') {
|
|
87
|
+
classes += ' animation-complexity-high'
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
// Add user preference classes
|
|
91
|
+
classes += ` user-preference-${batteryAnimations.state.userPreference}`
|
|
92
|
+
|
|
93
|
+
// Add performance optimization classes
|
|
94
|
+
if (performanceThrottling.metrics.performanceScore < 50) {
|
|
95
|
+
classes += ' performance-poor'
|
|
96
|
+
} else if (performanceThrottling.metrics.performanceScore < 70) {
|
|
97
|
+
classes += ' performance-fair'
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
return classes
|
|
101
|
+
}, [batteryAnimations.state, performanceThrottling.throttleLevel, animationComplexity])
|
|
102
|
+
|
|
103
|
+
// Get animation styles based on state
|
|
104
|
+
const getAnimationStyles = useCallback(() => {
|
|
105
|
+
const settings = batteryAnimations.animationSettings
|
|
106
|
+
|
|
107
|
+
if (!settings.shouldAnimate || batteryAnimations.shouldDisableAnimations) {
|
|
108
|
+
return {
|
|
109
|
+
transform: 'translate3d(0, 0, 0) rotate(0deg) scale(1)',
|
|
110
|
+
opacity: 1
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
switch (animationState) {
|
|
115
|
+
case 'running':
|
|
116
|
+
return {
|
|
117
|
+
transform: `translate3d(100px, 0, 0) rotate(360deg) scale(1.2)`,
|
|
118
|
+
opacity: 0.8,
|
|
119
|
+
transitionDuration: `${settings.duration}ms`,
|
|
120
|
+
transitionTimingFunction: settings.easing
|
|
121
|
+
}
|
|
122
|
+
case 'paused':
|
|
123
|
+
return {
|
|
124
|
+
transform: `translate3d(50px, 0, 0) rotate(180deg) scale(1.1)`,
|
|
125
|
+
opacity: 0.9,
|
|
126
|
+
transitionDuration: `${settings.duration}ms`,
|
|
127
|
+
transitionTimingFunction: settings.easing
|
|
128
|
+
}
|
|
129
|
+
default:
|
|
130
|
+
return {
|
|
131
|
+
transform: 'translate3d(0, 0, 0) rotate(0deg) scale(1)',
|
|
132
|
+
opacity: 1,
|
|
133
|
+
transitionDuration: `${settings.duration}ms`,
|
|
134
|
+
transitionTimingFunction: settings.easing
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
}, [animationState, batteryAnimations.animationSettings, batteryAnimations.shouldDisableAnimations])
|
|
138
|
+
|
|
139
|
+
// Get background color based on battery level
|
|
140
|
+
const getBackgroundColor = useCallback(() => {
|
|
141
|
+
if (batteryAnimations.state.isCriticalBattery) return 'bg-red-500'
|
|
142
|
+
if (batteryAnimations.state.isLowBattery) return 'bg-yellow-500'
|
|
143
|
+
if (batteryAnimations.state.batteryLevel < 0.5) return 'bg-orange-500'
|
|
144
|
+
return 'bg-green-500'
|
|
145
|
+
}, [batteryAnimations.state])
|
|
146
|
+
|
|
147
|
+
return (
|
|
148
|
+
<div className="space-y-6">
|
|
149
|
+
<div className="text-center">
|
|
150
|
+
<h1 className="text-3xl font-bold text-cs-text-primary mb-2">
|
|
151
|
+
🔋 Battery-Conscious Mobile Animations
|
|
152
|
+
</h1>
|
|
153
|
+
<p className="text-lg text-cs-text-secondary mb-4">
|
|
154
|
+
Story 9 Implementation - Smart animation system that respects battery life, performance, and user preferences
|
|
155
|
+
</p>
|
|
156
|
+
<div className="flex items-center justify-center gap-2">
|
|
157
|
+
<Badge variant="default">Story 9</Badge>
|
|
158
|
+
<Badge variant="outline">Battery Conscious</Badge>
|
|
159
|
+
<Badge variant="secondary">Performance Optimized</Badge>
|
|
160
|
+
<Badge variant="outline">Accessibility First</Badge>
|
|
161
|
+
</div>
|
|
162
|
+
</div>
|
|
163
|
+
|
|
164
|
+
{/* Battery Information */}
|
|
165
|
+
{showBatteryInfo && (
|
|
166
|
+
<Card className="border-2 border-cs-primary">
|
|
167
|
+
<CardHeader>
|
|
168
|
+
<CardTitle className="text-xl flex items-center gap-2">
|
|
169
|
+
🔋 Battery Status
|
|
170
|
+
<Badge variant={batteryAnimations.state.isLowBattery ? 'secondary' : 'default'}>
|
|
171
|
+
{batteryAnimations.batteryPercentage}%
|
|
172
|
+
</Badge>
|
|
173
|
+
</CardTitle>
|
|
174
|
+
<CardDescription>
|
|
175
|
+
Real-time battery monitoring and animation optimization
|
|
176
|
+
</CardDescription>
|
|
177
|
+
</CardHeader>
|
|
178
|
+
<CardContent>
|
|
179
|
+
<div className="grid grid-cols-1 md:grid-cols-2 gap-6">
|
|
180
|
+
<div className="space-y-3">
|
|
181
|
+
<h4 className="font-medium">Battery Information</h4>
|
|
182
|
+
<div className="space-y-2">
|
|
183
|
+
<div className="flex justify-between">
|
|
184
|
+
<span className="text-sm">Level:</span>
|
|
185
|
+
<span className="text-sm text-cs-text-secondary">{batteryAnimations.batteryPercentage}%</span>
|
|
186
|
+
</div>
|
|
187
|
+
<div className="flex justify-between">
|
|
188
|
+
<span className="text-sm">Status:</span>
|
|
189
|
+
<Badge variant={batteryAnimations.state.isCharging ? 'default' : 'secondary'}>
|
|
190
|
+
{batteryAnimations.state.isCharging ? 'Charging' : 'Discharging'}
|
|
191
|
+
</Badge>
|
|
192
|
+
</div>
|
|
193
|
+
<div className="flex justify-between">
|
|
194
|
+
<span className="text-sm">Health:</span>
|
|
195
|
+
<Badge variant="outline">{batteryAnimations.getBatteryHealth()}</Badge>
|
|
196
|
+
</div>
|
|
197
|
+
<div className="flex justify-between">
|
|
198
|
+
<span className="text-sm">Throttle Level:</span>
|
|
199
|
+
<Badge variant="outline">{batteryAnimations.state.throttleLevel}</Badge>
|
|
200
|
+
</div>
|
|
201
|
+
</div>
|
|
202
|
+
</div>
|
|
203
|
+
|
|
204
|
+
<div className="space-y-3">
|
|
205
|
+
<h4 className="font-medium">Animation Settings</h4>
|
|
206
|
+
<div className="space-y-2">
|
|
207
|
+
<div className="flex justify-between">
|
|
208
|
+
<span className="text-sm">Duration:</span>
|
|
209
|
+
<span className="text-sm text-cs-text-secondary">{batteryAnimations.animationSettings.duration}ms</span>
|
|
210
|
+
</div>
|
|
211
|
+
<div className="flex justify-between">
|
|
212
|
+
<span className="text-sm">Easing:</span>
|
|
213
|
+
<span className="text-sm text-cs-text-secondary">{batteryAnimations.animationSettings.easing}</span>
|
|
214
|
+
</div>
|
|
215
|
+
<div className="flex justify-between">
|
|
216
|
+
<span className="text-sm">Complexity:</span>
|
|
217
|
+
<Badge variant="outline">{batteryAnimations.animationSettings.complexity}</Badge>
|
|
218
|
+
</div>
|
|
219
|
+
<div className="flex justify-between">
|
|
220
|
+
<span className="text-sm">Frame Rate:</span>
|
|
221
|
+
<span className="text-sm text-cs-text-secondary">{batteryAnimations.animationSettings.frameRate}fps</span>
|
|
222
|
+
</div>
|
|
223
|
+
</div>
|
|
224
|
+
</div>
|
|
225
|
+
</div>
|
|
226
|
+
|
|
227
|
+
{/* User Preference Controls */}
|
|
228
|
+
<div className="mt-4 p-3 bg-cs-accent/10 rounded-lg">
|
|
229
|
+
<h4 className="font-medium text-sm mb-2">User Preference:</h4>
|
|
230
|
+
<div className="flex gap-2">
|
|
231
|
+
<Button
|
|
232
|
+
variant={batteryAnimations.state.userPreference === 'performance' ? 'default' : 'outline'}
|
|
233
|
+
size="sm"
|
|
234
|
+
onClick={() => batteryAnimations.updateUserPreference('performance')}
|
|
235
|
+
>
|
|
236
|
+
Performance
|
|
237
|
+
</Button>
|
|
238
|
+
<Button
|
|
239
|
+
variant={batteryAnimations.state.userPreference === 'balanced' ? 'default' : 'outline'}
|
|
240
|
+
size="sm"
|
|
241
|
+
onClick={() => batteryAnimations.updateUserPreference('balanced')}
|
|
242
|
+
>
|
|
243
|
+
Balanced
|
|
244
|
+
</Button>
|
|
245
|
+
<Button
|
|
246
|
+
variant={batteryAnimations.state.userPreference === 'battery' ? 'default' : 'outline'}
|
|
247
|
+
size="sm"
|
|
248
|
+
onClick={() => batteryAnimations.updateUserPreference('battery')}
|
|
249
|
+
>
|
|
250
|
+
Battery
|
|
251
|
+
</Button>
|
|
252
|
+
<Button
|
|
253
|
+
variant={batteryAnimations.state.userPreference === 'accessibility' ? 'default' : 'outline'}
|
|
254
|
+
size="sm"
|
|
255
|
+
onClick={() => batteryAnimations.updateUserPreference('accessibility')}
|
|
256
|
+
>
|
|
257
|
+
Accessibility
|
|
258
|
+
</Button>
|
|
259
|
+
</div>
|
|
260
|
+
</div>
|
|
261
|
+
</CardContent>
|
|
262
|
+
</Card>
|
|
263
|
+
)}
|
|
264
|
+
|
|
265
|
+
{/* Performance Information */}
|
|
266
|
+
{showPerformanceInfo && (
|
|
267
|
+
<Card className="border-2 border-cs-secondary">
|
|
268
|
+
<CardHeader>
|
|
269
|
+
<CardTitle className="text-xl flex items-center gap-2">
|
|
270
|
+
📊 Performance Monitoring
|
|
271
|
+
<Badge variant={performanceThrottling.isThrottling ? 'secondary' : 'default'}>
|
|
272
|
+
{performanceThrottling.isThrottling ? 'Throttling' : 'Optimal'}
|
|
273
|
+
</Badge>
|
|
274
|
+
</CardTitle>
|
|
275
|
+
<CardDescription>
|
|
276
|
+
Real-time performance metrics and automatic throttling
|
|
277
|
+
</CardDescription>
|
|
278
|
+
</CardHeader>
|
|
279
|
+
<CardContent>
|
|
280
|
+
<div className="grid grid-cols-2 lg:grid-cols-4 gap-4 text-center">
|
|
281
|
+
<div>
|
|
282
|
+
<p className="text-2xl font-bold text-cs-primary">
|
|
283
|
+
{performanceThrottling.metrics.fps}
|
|
284
|
+
</p>
|
|
285
|
+
<p className="text-sm text-cs-text-secondary">FPS</p>
|
|
286
|
+
</div>
|
|
287
|
+
<div>
|
|
288
|
+
<p className="text-2xl font-bold text-cs-secondary">
|
|
289
|
+
{performanceThrottling.metrics.frameTime.toFixed(1)}ms
|
|
290
|
+
</p>
|
|
291
|
+
<p className="text-sm text-cs-text-secondary">Frame Time</p>
|
|
292
|
+
</div>
|
|
293
|
+
<div>
|
|
294
|
+
<p className="text-2xl font-bold text-cs-accent">
|
|
295
|
+
{performanceThrottling.metrics.performanceScore}
|
|
296
|
+
</p>
|
|
297
|
+
<p className="text-sm text-cs-text-secondary">Performance Score</p>
|
|
298
|
+
</div>
|
|
299
|
+
<div>
|
|
300
|
+
<p className="text-2xl font-bold text-cs-primary">
|
|
301
|
+
{performanceThrottling.throttleLevel}
|
|
302
|
+
</p>
|
|
303
|
+
<p className="text-sm text-cs-text-secondary">Throttle Level</p>
|
|
304
|
+
</div>
|
|
305
|
+
</div>
|
|
306
|
+
|
|
307
|
+
<div className="mt-4 p-3 bg-cs-accent/10 rounded-lg">
|
|
308
|
+
<div className="flex items-center justify-between mb-2">
|
|
309
|
+
<span className="font-medium text-sm">Performance Level:</span>
|
|
310
|
+
<Badge variant={
|
|
311
|
+
performanceThrottling.performanceLevel === 'excellent' || performanceThrottling.performanceLevel === 'good'
|
|
312
|
+
? 'default' : 'secondary'
|
|
313
|
+
}>
|
|
314
|
+
{performanceThrottling.performanceLevel.toUpperCase()}
|
|
315
|
+
</Badge>
|
|
316
|
+
</div>
|
|
317
|
+
<div className="flex items-center justify-between">
|
|
318
|
+
<span className="font-medium text-sm">Throttling Status:</span>
|
|
319
|
+
<Badge variant={performanceThrottling.isThrottling ? 'secondary' : 'default'}>
|
|
320
|
+
{performanceThrottling.isThrottling ? 'Active' : 'Inactive'}
|
|
321
|
+
</Badge>
|
|
322
|
+
</div>
|
|
323
|
+
</div>
|
|
324
|
+
</CardContent>
|
|
325
|
+
</Card>
|
|
326
|
+
)}
|
|
327
|
+
|
|
328
|
+
{/* Animation Demo */}
|
|
329
|
+
{showAnimationDemo && (
|
|
330
|
+
<Card className="border border-cs-border">
|
|
331
|
+
<CardHeader>
|
|
332
|
+
<CardTitle className="text-lg">Battery-Conscious Animation Demo</CardTitle>
|
|
333
|
+
<CardDescription>
|
|
334
|
+
Test different animation types with real-time battery and performance optimization
|
|
335
|
+
</CardDescription>
|
|
336
|
+
</CardHeader>
|
|
337
|
+
<CardContent className="space-y-4">
|
|
338
|
+
{/* Animation Type Selection */}
|
|
339
|
+
<div className="flex flex-wrap gap-2">
|
|
340
|
+
<Button
|
|
341
|
+
variant={animationType === 'battery' ? 'default' : 'outline'}
|
|
342
|
+
size="sm"
|
|
343
|
+
onClick={() => setAnimationType('battery')}
|
|
344
|
+
>
|
|
345
|
+
Battery Optimized
|
|
346
|
+
</Button>
|
|
347
|
+
<Button
|
|
348
|
+
variant={animationType === 'performance' ? 'default' : 'outline'}
|
|
349
|
+
size="sm"
|
|
350
|
+
onClick={() => setAnimationType('performance')}
|
|
351
|
+
>
|
|
352
|
+
Performance Optimized
|
|
353
|
+
</Button>
|
|
354
|
+
<Button
|
|
355
|
+
variant={animationType === 'reduced-motion' ? 'default' : 'outline'}
|
|
356
|
+
size="sm"
|
|
357
|
+
onClick={() => setAnimationType('reduced-motion')}
|
|
358
|
+
>
|
|
359
|
+
Reduced Motion
|
|
360
|
+
</Button>
|
|
361
|
+
<Button
|
|
362
|
+
variant={animationType === 'user-preference' ? 'default' : 'outline'}
|
|
363
|
+
size="sm"
|
|
364
|
+
onClick={() => setAnimationType('user-preference')}
|
|
365
|
+
>
|
|
366
|
+
User Preference
|
|
367
|
+
</Button>
|
|
368
|
+
</div>
|
|
369
|
+
|
|
370
|
+
{/* Animation Complexity Selection */}
|
|
371
|
+
<div className="flex flex-wrap gap-2">
|
|
372
|
+
<Button
|
|
373
|
+
variant={animationComplexity === 'low' ? 'default' : 'outline'}
|
|
374
|
+
size="sm"
|
|
375
|
+
onClick={() => setAnimationComplexity('low')}
|
|
376
|
+
>
|
|
377
|
+
Low Complexity
|
|
378
|
+
</Button>
|
|
379
|
+
<Button
|
|
380
|
+
variant={animationComplexity === 'medium' ? 'default' : 'outline'}
|
|
381
|
+
size="sm"
|
|
382
|
+
onClick={() => setAnimationComplexity('medium')}
|
|
383
|
+
>
|
|
384
|
+
Medium Complexity
|
|
385
|
+
</Button>
|
|
386
|
+
<Button
|
|
387
|
+
variant={animationComplexity === 'high' ? 'default' : 'outline'}
|
|
388
|
+
size="sm"
|
|
389
|
+
onClick={() => setAnimationComplexity('high')}
|
|
390
|
+
>
|
|
391
|
+
High Complexity
|
|
392
|
+
</Button>
|
|
393
|
+
</div>
|
|
394
|
+
|
|
395
|
+
{/* Animation Controls */}
|
|
396
|
+
<div className="flex gap-2">
|
|
397
|
+
<Button
|
|
398
|
+
variant="default"
|
|
399
|
+
onClick={startAnimation}
|
|
400
|
+
disabled={animationState === 'running'}
|
|
401
|
+
>
|
|
402
|
+
Start Animation
|
|
403
|
+
</Button>
|
|
404
|
+
<Button
|
|
405
|
+
variant="outline"
|
|
406
|
+
onClick={pauseAnimation}
|
|
407
|
+
disabled={animationState !== 'running'}
|
|
408
|
+
>
|
|
409
|
+
Pause
|
|
410
|
+
</Button>
|
|
411
|
+
<Button
|
|
412
|
+
variant="outline"
|
|
413
|
+
onClick={resumeAnimation}
|
|
414
|
+
disabled={animationState !== 'paused'}
|
|
415
|
+
>
|
|
416
|
+
Resume
|
|
417
|
+
</Button>
|
|
418
|
+
</div>
|
|
419
|
+
|
|
420
|
+
{/* Animation Display */}
|
|
421
|
+
<div className="flex justify-center">
|
|
422
|
+
<div
|
|
423
|
+
className={`${getAnimationClasses()} ${getBackgroundColor()}`}
|
|
424
|
+
style={getAnimationStyles()}
|
|
425
|
+
/>
|
|
426
|
+
</div>
|
|
427
|
+
|
|
428
|
+
{/* Animation Info */}
|
|
429
|
+
<div className="text-center text-sm text-cs-text-secondary">
|
|
430
|
+
<p>Animation Type: <span className="font-medium">{animationType}</span></p>
|
|
431
|
+
<p>Complexity: <span className="font-medium">{animationComplexity}</span></p>
|
|
432
|
+
<p>State: <span className="font-medium">{animationState}</span></p>
|
|
433
|
+
<p>Battery Optimized: <span className="font-medium">
|
|
434
|
+
{batteryAnimations.isAnimationOptimized() ? 'Yes' : 'No'}
|
|
435
|
+
</span></p>
|
|
436
|
+
<p>Animations Disabled: <span className="font-medium">
|
|
437
|
+
{batteryAnimations.shouldDisableAnimations ? 'Yes' : 'No'}
|
|
438
|
+
</span></p>
|
|
439
|
+
</div>
|
|
440
|
+
</CardContent>
|
|
441
|
+
</Card>
|
|
442
|
+
)}
|
|
443
|
+
|
|
444
|
+
{/* Controls */}
|
|
445
|
+
{showControls && (
|
|
446
|
+
<Card className="border border-cs-border">
|
|
447
|
+
<CardHeader>
|
|
448
|
+
<CardTitle className="text-lg">Demo Controls</CardTitle>
|
|
449
|
+
<CardDescription>
|
|
450
|
+
Configure and test different battery-conscious animation features
|
|
451
|
+
</CardDescription>
|
|
452
|
+
</CardHeader>
|
|
453
|
+
<CardContent className="space-y-4">
|
|
454
|
+
<div className="flex flex-wrap gap-4">
|
|
455
|
+
<Button
|
|
456
|
+
variant={showBatteryInfo ? 'default' : 'outline'}
|
|
457
|
+
size="sm"
|
|
458
|
+
onClick={() => setShowBatteryInfo(!showBatteryInfo)}
|
|
459
|
+
>
|
|
460
|
+
{showBatteryInfo ? 'Hide' : 'Show'} Battery Info
|
|
461
|
+
</Button>
|
|
462
|
+
<Button
|
|
463
|
+
variant={showPerformanceInfo ? 'default' : 'outline'}
|
|
464
|
+
size="sm"
|
|
465
|
+
onClick={() => setShowPerformanceInfo(!showPerformanceInfo)}
|
|
466
|
+
>
|
|
467
|
+
{showPerformanceInfo ? 'Hide' : 'Show'} Performance
|
|
468
|
+
</Button>
|
|
469
|
+
<Button
|
|
470
|
+
variant={showAnimationDemo ? 'default' : 'outline'}
|
|
471
|
+
size="sm"
|
|
472
|
+
onClick={() => setShowAnimationDemo(!showAnimationDemo)}
|
|
473
|
+
>
|
|
474
|
+
{showAnimationDemo ? 'Hide' : 'Show'} Animation Demo
|
|
475
|
+
</Button>
|
|
476
|
+
</div>
|
|
477
|
+
</CardContent>
|
|
478
|
+
</Card>
|
|
479
|
+
)}
|
|
480
|
+
|
|
481
|
+
{/* Optimization Status */}
|
|
482
|
+
<Card className="border border-cs-border">
|
|
483
|
+
<CardHeader>
|
|
484
|
+
<CardTitle className="text-lg">Optimization Status</CardTitle>
|
|
485
|
+
<CardDescription>
|
|
486
|
+
Current optimization status and recommendations
|
|
487
|
+
</CardDescription>
|
|
488
|
+
</CardHeader>
|
|
489
|
+
<CardContent>
|
|
490
|
+
<div className="space-y-3">
|
|
491
|
+
<div className="flex items-center justify-between">
|
|
492
|
+
<span className="text-sm">Battery Optimization:</span>
|
|
493
|
+
<Badge variant={batteryAnimations.isAnimationOptimized() ? 'default' : 'secondary'}>
|
|
494
|
+
{batteryAnimations.isAnimationOptimized() ? 'Active' : 'Inactive'}
|
|
495
|
+
</Badge>
|
|
496
|
+
</div>
|
|
497
|
+
<div className="flex items-center justify-between">
|
|
498
|
+
<span className="text-sm">Performance Throttling:</span>
|
|
499
|
+
<Badge variant={performanceThrottling.isThrottling ? 'secondary' : 'default'}>
|
|
500
|
+
{performanceThrottling.isThrottling ? 'Active' : 'Inactive'}
|
|
501
|
+
</Badge>
|
|
502
|
+
</div>
|
|
503
|
+
<div className="flex items-center justify-between">
|
|
504
|
+
<span className="text-sm">Reduced Motion:</span>
|
|
505
|
+
<Badge variant={batteryAnimations.state.reducedMotion ? 'secondary' : 'default'}>
|
|
506
|
+
{batteryAnimations.state.reducedMotion ? 'Enabled' : 'Disabled'}
|
|
507
|
+
</Badge>
|
|
508
|
+
</div>
|
|
509
|
+
<div className="flex items-center justify-between">
|
|
510
|
+
<span className="text-sm">User Preference:</span>
|
|
511
|
+
<Badge variant="outline">{batteryAnimations.state.userPreference}</Badge>
|
|
512
|
+
</div>
|
|
513
|
+
</div>
|
|
514
|
+
|
|
515
|
+
{/* Recent Optimizations */}
|
|
516
|
+
{batteryAnimations.optimizations.length > 0 && (
|
|
517
|
+
<div className="mt-4 p-3 bg-cs-accent/10 rounded-lg">
|
|
518
|
+
<h4 className="font-medium text-sm mb-2">Recent Optimizations:</h4>
|
|
519
|
+
<ul className="text-xs text-cs-text-secondary space-y-1">
|
|
520
|
+
{batteryAnimations.optimizations.slice(-3).map((optimization, index) => (
|
|
521
|
+
<li key={index}>• {optimization}</li>
|
|
522
|
+
))}
|
|
523
|
+
</ul>
|
|
524
|
+
</div>
|
|
525
|
+
)}
|
|
526
|
+
|
|
527
|
+
{/* Performance Optimizations */}
|
|
528
|
+
{performanceThrottling.optimizations.length > 0 && (
|
|
529
|
+
<div className="mt-4 p-3 bg-cs-secondary/10 rounded-lg">
|
|
530
|
+
<h4 className="font-medium text-sm mb-2">Performance Optimizations:</h4>
|
|
531
|
+
<ul className="text-xs text-cs-text-secondary space-y-1">
|
|
532
|
+
{performanceThrottling.optimizations.slice(-3).map((optimization, index) => (
|
|
533
|
+
<li key={index}>• {optimization}</li>
|
|
534
|
+
))}
|
|
535
|
+
</ul>
|
|
536
|
+
</div>
|
|
537
|
+
)}
|
|
538
|
+
|
|
539
|
+
{/* Battery Recommendations */}
|
|
540
|
+
{batteryAnimations.recommendations.length > 0 && (
|
|
541
|
+
<div className="mt-4 p-3 bg-cs-primary/10 rounded-lg">
|
|
542
|
+
<h4 className="font-medium text-sm mb-2">Battery Recommendations:</h4>
|
|
543
|
+
<ul className="text-xs text-cs-text-secondary space-y-1">
|
|
544
|
+
{batteryAnimations.recommendations.slice(0, 3).map((recommendation, index) => (
|
|
545
|
+
<li key={index}>• {recommendation}</li>
|
|
546
|
+
))}
|
|
547
|
+
</ul>
|
|
548
|
+
</div>
|
|
549
|
+
)}
|
|
550
|
+
|
|
551
|
+
{/* Performance Recommendations */}
|
|
552
|
+
{performanceThrottling.recommendations.length > 0 && (
|
|
553
|
+
<div className="mt-4 p-3 bg-cs-accent/10 rounded-lg">
|
|
554
|
+
<h4 className="font-medium text-sm mb-2">Performance Recommendations:</h4>
|
|
555
|
+
<ul className="text-xs text-cs-text-secondary space-y-1">
|
|
556
|
+
{performanceThrottling.recommendations.slice(0, 3).map((recommendation, index) => (
|
|
557
|
+
<li key={index}>• {recommendation}</li>
|
|
558
|
+
))}
|
|
559
|
+
</ul>
|
|
560
|
+
</div>
|
|
561
|
+
)}
|
|
562
|
+
</CardContent>
|
|
563
|
+
</Card>
|
|
564
|
+
</div>
|
|
565
|
+
)
|
|
566
|
+
}
|
|
567
|
+
|
|
568
|
+
export default BatteryConsciousAnimationDemo
|