Skip to content

ServerKit is a lightweight, modern server control panel for managing web applications, databases, and services on your VPS or dedicated server. Built with Python/Flask backend and React frontend.

feat(ui): respect prefers-reduced-motion across the app

Juan Denis61b576952f93
diff --git a/frontend/src/components/Sidebar.jsx b/frontend/src/components/Sidebar.jsx
index 391900c7..d13fa989 100644
--- a/frontend/src/components/Sidebar.jsx
+++ b/frontend/src/components/Sidebar.jsx
@@ -7,6 +7,7 @@ import { api } from '../services/api';
import ServerKitLogo from './ServerKitLogo';
import { SIDEBAR_CATEGORIES, CATEGORY_LABELS, SIDEBAR_PRESETS, getHiddenItemIds, getVisibleItems } from './sidebarItems';
import { useContributions } from '../plugins/contributions';
+import useMediaQuery from '../hooks/useMediaQuery';
const Sidebar = ({ mobileOpen = false, isMobile = false, onMobileClose = () => {} }) => {
const { user, logout, updateUser } = useAuth();
@@ -17,6 +18,7 @@ const Sidebar = ({ mobileOpen = false, isMobile = false, onMobileClose = () => {
const [wpInstalled, setWpInstalled] = useState(false);
const menuRef = useRef(null);
const sidebarRef = useRef(null);
+ const prefersReducedMotion = useMediaQuery('(prefers-reduced-motion: reduce)');
// When collapsed to a drawer and closed, take the whole subtree out of the
// tab order and the accessibility tree. `inert` is set imperatively so it
@@ -90,7 +92,9 @@ const Sidebar = ({ mobileOpen = false, isMobile = false, onMobileClose = () => {
}, []);
useEffect(() => {
- if (whiteLabel.enabled) return;
+ // The star's celebratory burst is pure decoration: never auto-play it
+ // for users who asked the OS to reduce motion.
+ if (whiteLabel.enabled || prefersReducedMotion) return;
let playCount = 0;
let timeoutId;
@@ -122,7 +126,7 @@ const Sidebar = ({ mobileOpen = false, isMobile = false, onMobileClose = () => {
clearTimeout(initialDelay);
clearTimeout(timeoutId);
};
- }, [whiteLabel.enabled]);
+ }, [whiteLabel.enabled, prefersReducedMotion]);
const conditions = { wpInstalled };
const currentPreset = user?.sidebar_config?.preset || 'full';
diff --git a/frontend/src/styles/_variables.scss b/frontend/src/styles/_variables.scss
index 221bebc6..e3220e08 100644
--- a/frontend/src/styles/_variables.scss
+++ b/frontend/src/styles/_variables.scss
@@ -181,6 +181,11 @@ $transition-fast: 0.15s ease;
$transition-base: 0.2s ease;
$transition-slow: 0.3s ease;
+// Easing curves — natural deceleration. No bounce/elastic.
+$ease-out-quart: cubic-bezier(0.25, 1, 0.5, 1);
+$ease-out-quint: cubic-bezier(0.22, 1, 0.36, 1);
+$ease-out-expo: cubic-bezier(0.16, 1, 0.3, 1);
+
// --------------------------------------------
// LAYOUT
// --------------------------------------------
diff --git a/frontend/src/styles/base/_reset.scss b/frontend/src/styles/base/_reset.scss
index 120de3bf..56859b10 100644
--- a/frontend/src/styles/base/_reset.scss
+++ b/frontend/src/styles/base/_reset.scss
@@ -66,3 +66,29 @@ ul, ol {
background: $text-tertiary;
}
}
+
+// ============================================
+// REDUCED MOTION
+// ============================================
+// Honor the OS "reduce motion" setting across the whole app: collapse
+// transitions and decorative keyframe animations to effectively instant.
+// Loading spinners are re-enabled below because the rotation IS the
+// "working…" status cue, not decoration, so freezing it would hide state.
+@media (prefers-reduced-motion: reduce) {
+ *,
+ *::before,
+ *::after {
+ animation-duration: 0.01ms !important;
+ animation-iteration-count: 1 !important;
+ transition-duration: 0.01ms !important;
+ transition-delay: 0ms !important;
+ scroll-behavior: auto !important;
+ }
+
+ // Keep loading indicators turning (higher specificity wins over `*`).
+ .spinner-ring,
+ [class*="spinner"] {
+ animation-duration: 0.8s !important;
+ animation-iteration-count: infinite !important;
+ }
+}
diff --git a/frontend/src/styles/layout/_sidebar.scss b/frontend/src/styles/layout/_sidebar.scss
index 0800e1f0..3d2ef93c 100644
--- a/frontend/src/styles/layout/_sidebar.scss
+++ b/frontend/src/styles/layout/_sidebar.scss
@@ -24,7 +24,7 @@
padding-top: env(safe-area-inset-top);
z-index: $z-modal;
transform: translateX(-100%);
- transition: transform 0.28s cubic-bezier(0.22, 1, 0.36, 1);
+ transition: transform 0.28s $ease-out-quint;
will-change: transform;
&.sidebar--mobile-open {