diff --git a/CHANGELOG.md b/CHANGELOG.md index 066175d2..e75eeff2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -204,6 +204,22 @@ awaiting a stable release: ### Changed +- **Skeleton loading overhaul — one primitive, overlay-on-content, no layout + shift.** Loading placeholders no longer swap in a disconnected tree that jumps + when data arrives. A new `SkeletonBoundary` keeps the real content in flow and, + while loading, hides it and paints the skeleton *over* its exact box — so the + placeholder inherits the real dimensions at every breakpoint (zero guessed + widths, zero cumulative layout shift on refresh). The two competing skeleton + primitives were consolidated to the single SCSS-based `Skeleton` (the Tailwind + `ui/skeleton` shim and its raw sizing classes are gone), and the worst + hand-guessed loaders — SSL certificates, the WordPress list and detail tabs, + and the WordPress activity feed — now render through the boundary. All skeleton + shimmer honors `prefers-reduced-motion`, and loading regions expose `aria-busy` + for assistive tech. A dev-only tool (`npm run capture:skeletons`) can measure a + logged-in page's real layout into baked bone assets for pixel-accurate + placeholders, replayed via the boundary's optional `bones` prop — no browser or + extra dependency ships in the product. + - **`update.sh` now defaults to pre-built releases (Node-free updates).** The frontend is compiled once in CI and shipped, so a normal `update.sh` no longer rebuilds the SPA on the server — it fetches the pre-built release tarball, diff --git a/frontend/src/components/SkeletonBoundary.jsx b/frontend/src/components/SkeletonBoundary.jsx new file mode 100644 index 00000000..f5ed853d --- /dev/null +++ b/frontend/src/components/SkeletonBoundary.jsx @@ -0,0 +1,89 @@ +import { Children, useEffect, useState } from 'react'; +import { cn } from '@/lib/utils'; + +/** + * SkeletonBoundary — paints a loading skeleton over the real content box. + * + * Instead of swapping the content tree for a disconnected placeholder (which + * shifts layout when data arrives), the boundary keeps the real children in + * flow and, while `loading`, hides them (`visibility: hidden`) and overlays the + * `skeleton` absolutely (`position: absolute; inset: 0`). The overlay inherits + * the real content's dimensions, so the skeleton is correct by construction at + * every breakpoint — zero guessed geometry, zero layout shift. + * + * }> + * {status && } + * + * + * When `loading` with no in-flow children yet (first load, data-gated), the + * boundary renders the skeleton in normal flow at its intrinsic size — the same + * footprint as a plain skeleton swap, so there's no regression on first paint. + * Overlay mode kicks in automatically once real children are present (e.g. a + * refresh over already-loaded data). + * + * Accessibility: the boundary is `aria-busy` while loading and the skeleton is + * `aria-hidden`. Shimmer and the optional fade honour `prefers-reduced-motion` + * via `styles/components/_skeleton.scss`. + * + * @param {boolean} loading Whether content is still loading. + * @param {React.ReactNode} skeleton Placeholder rendered while loading. + * @param {React.ReactNode} children Real content (may be data-gated/absent). + * @param {boolean} [transition] Fade the skeleton out on load (~200ms, opacity only). + * @param {string} [as] Container tag name (default 'div'). + * @param {string} [className] Extra classes on the boundary container. + */ +export function SkeletonBoundary({ + loading, + skeleton, + children, + transition = false, + as: Tag = 'div', + className = '', + ...rest +}) { + // Keep the skeleton mounted through a short fade-out when `transition` is on. + const [showSkeleton, setShowSkeleton] = useState(loading); + const leaving = !loading && showSkeleton; + + useEffect(() => { + if (loading) { + setShowSkeleton(true); + return undefined; + } + if (!transition) { + setShowSkeleton(false); + return undefined; + } + const timer = setTimeout(() => setShowSkeleton(false), 200); + return () => clearTimeout(timer); + }, [loading, transition]); + + // Overlay mode needs a real box to cover — only when in-flow children exist. + const hasContent = Children.toArray(children).length > 0; + + return ( + + {children} + {showSkeleton && ( + + )} + + ); +} + +export default SkeletonBoundary; diff --git a/frontend/src/components/ui/skeleton.jsx b/frontend/src/components/ui/skeleton.jsx deleted file mode 100644 index 3e7693d5..00000000 --- a/frontend/src/components/ui/skeleton.jsx +++ /dev/null @@ -1,7 +0,0 @@ -import { cn } from '@/lib/utils'; - -function Skeleton({ className, ...props }) { - return
; -} - -export { Skeleton }; diff --git a/frontend/src/components/wordpress/ActivityFeed.jsx b/frontend/src/components/wordpress/ActivityFeed.jsx index c368c92b..1b6ea718 100644 --- a/frontend/src/components/wordpress/ActivityFeed.jsx +++ b/frontend/src/components/wordpress/ActivityFeed.jsx @@ -4,7 +4,8 @@ import wordpressApi from '../../services/wordpress'; import { formatRelativeTime } from '@/utils/time'; import { Button } from '@/components/ui/button'; import { Badge } from '@/components/ui/badge'; -import { Skeleton } from '@/components/ui/skeleton'; +import { Skeleton } from '@/components/Skeleton'; +import SkeletonBoundary from '@/components/SkeletonBoundary'; const ACTION_ICONS = { create: Play, @@ -60,23 +61,21 @@ const ActivityFeed = ({ projectId, envId, limit = 20, compact = false }) => { } } - if (loading) { - return ( -
- {[1, 2, 3].map(i => ( -
- -
- - -
+ const feedSkeleton = ( + <> + {[1, 2, 3].map(i => ( +
+ +
+ +
- ))} -
- ); - } +
+ ))} + + ); - if (activities.length === 0) { + if (!loading && activities.length === 0) { return (

No activity recorded yet.

@@ -85,8 +84,12 @@ const ActivityFeed = ({ projectId, envId, limit = 20, compact = false }) => { } return ( -
- {activities.map(activity => { + + {activities.length > 0 && activities.map(activity => { const Icon = ACTION_ICONS[activity.action] || AlertCircle; const colorClass = ACTION_BADGE_VARIANTS[activity.action] || 'secondary'; @@ -120,7 +123,7 @@ const ActivityFeed = ({ projectId, envId, limit = 20, compact = false }) => { Load more )} -
+ ); }; diff --git a/frontend/src/components/wordpress/detail/AnalyticsTab.jsx b/frontend/src/components/wordpress/detail/AnalyticsTab.jsx index c1d32eaf..c1f930f6 100644 --- a/frontend/src/components/wordpress/detail/AnalyticsTab.jsx +++ b/frontend/src/components/wordpress/detail/AnalyticsTab.jsx @@ -6,6 +6,7 @@ import wordpressApi from '../../../services/wordpress'; import api from '../../../services/api'; import { useToast } from '../../../contexts/ToastContext'; import { MetricCard, SegControl } from '../../ds'; +import SkeletonBoundary from '../../SkeletonBoundary'; import { OverviewGridSkeleton, ANALYTICS_PERIODS } from './wpDetailShared'; // Analytics Tab — per-site traffic + error analytics (#25), parsed on-demand from @@ -48,7 +49,7 @@ const AnalyticsTab = ({ siteId }) => { useEffect(() => { load(); }, [load]); - if (loading) return ; + if (loading) return } />; const fmtHour = (iso) => { const d = new Date(iso); diff --git a/frontend/src/components/wordpress/detail/EnvironmentsTab.jsx b/frontend/src/components/wordpress/detail/EnvironmentsTab.jsx index 34e692b4..4450fe92 100644 --- a/frontend/src/components/wordpress/detail/EnvironmentsTab.jsx +++ b/frontend/src/components/wordpress/detail/EnvironmentsTab.jsx @@ -8,6 +8,7 @@ import Modal from '@/components/Modal'; import { Button } from '@/components/ui/button'; import { Input } from '@/components/ui/input'; import { Label } from '@/components/ui/label'; +import SkeletonBoundary from '../../SkeletonBoundary'; import { EnvironmentCardSkeleton } from './wpDetailShared'; // Environments Tab @@ -72,16 +73,18 @@ const EnvironmentsTab = ({ siteId, site, onUpdate }) => { if (loading) { return ( -
-
-
-
+ +
+
+
+
+
+ + +
-
- - -
-
+ )} /> ); } diff --git a/frontend/src/components/wordpress/detail/GitTab.jsx b/frontend/src/components/wordpress/detail/GitTab.jsx index 9c335988..0675fd83 100644 --- a/frontend/src/components/wordpress/detail/GitTab.jsx +++ b/frontend/src/components/wordpress/detail/GitTab.jsx @@ -5,6 +5,7 @@ import { useToast } from '../../../contexts/ToastContext'; import { GitConnectForm, CommitList } from '../index'; import { ErrorState } from '../../ErrorBoundary'; import { Button } from '@/components/ui/button'; +import SkeletonBoundary from '../../SkeletonBoundary'; // Git Tab const GitTab = ({ siteId, site, onUpdate }) => { @@ -73,14 +74,16 @@ const GitTab = ({ siteId, site, onUpdate }) => { if (loading) { return ( -
-
-
-
-
-
+ +
+
+
+
+
+
-
+ )} /> ); } diff --git a/frontend/src/components/wordpress/detail/PhpTab.jsx b/frontend/src/components/wordpress/detail/PhpTab.jsx index 2bbbce06..8cfcfee9 100644 --- a/frontend/src/components/wordpress/detail/PhpTab.jsx +++ b/frontend/src/components/wordpress/detail/PhpTab.jsx @@ -4,6 +4,7 @@ import { useToast } from '../../../contexts/ToastContext'; import { Button } from '@/components/ui/button'; import { Input } from '@/components/ui/input'; import { Label } from '@/components/ui/label'; +import SkeletonBoundary from '../../SkeletonBoundary'; import { OverviewGridSkeleton, PHP_LIMIT_LABELS } from './wpDetailShared'; // PHP Tab — live PHP version + ini limits for the Docker (apache/mod_php) site. @@ -76,7 +77,7 @@ const PhpTab = ({ siteId }) => { } } - if (loading) return ; + if (loading) return } />; const limits = php?.limits || {}; const current = php?.php_version || 'Unknown'; diff --git a/frontend/src/components/wordpress/detail/PluginsTab.jsx b/frontend/src/components/wordpress/detail/PluginsTab.jsx index 9db483e8..c529eeef 100644 --- a/frontend/src/components/wordpress/detail/PluginsTab.jsx +++ b/frontend/src/components/wordpress/detail/PluginsTab.jsx @@ -8,6 +8,7 @@ import { ServiceTile } from '../../ds'; import { Button } from '@/components/ui/button'; import { Input } from '@/components/ui/input'; import { Switch } from '@/components/ui/switch'; +import SkeletonBoundary from '../../SkeletonBoundary'; import { ListItemSkeleton } from './wpDetailShared'; // Plugins Tab @@ -131,17 +132,19 @@ const PluginsTab = ({ siteId }) => { if (loading) { return ( -
-
-
+ +
+
+
+
+
+ + + +
-
-
- - - -
-
+ )} /> ); } diff --git a/frontend/src/components/wordpress/detail/ReportsTab.jsx b/frontend/src/components/wordpress/detail/ReportsTab.jsx index df1eee7a..c7e08c49 100644 --- a/frontend/src/components/wordpress/detail/ReportsTab.jsx +++ b/frontend/src/components/wordpress/detail/ReportsTab.jsx @@ -6,6 +6,7 @@ import { useToast } from '../../../contexts/ToastContext'; import { useConfirm } from '../../../hooks/useConfirm'; import { Pill } from '../../ds'; import { Button } from '@/components/ui/button'; +import SkeletonBoundary from '../../SkeletonBoundary'; import { OverviewGridSkeleton } from './wpDetailShared'; // Reports Tab — monthly client reports (#33 agency slice). Aggregates the @@ -118,7 +119,7 @@ const ReportsTab = ({ siteId }) => { window.print(); } - if (loading) return ; + if (loading) return } />; const selected = reports.find(r => r.id === selectedId) || null; diff --git a/frontend/src/components/wordpress/detail/SecurityTab.jsx b/frontend/src/components/wordpress/detail/SecurityTab.jsx index 5ac6956a..f12a28b3 100644 --- a/frontend/src/components/wordpress/detail/SecurityTab.jsx +++ b/frontend/src/components/wordpress/detail/SecurityTab.jsx @@ -3,6 +3,7 @@ import wordpressApi from '../../../services/wordpress'; import { useToast } from '../../../contexts/ToastContext'; import { Pill, ScoreGauge } from '../../ds'; import { Button } from '@/components/ui/button'; +import SkeletonBoundary from '../../SkeletonBoundary'; import { OverviewGridSkeleton } from './wpDetailShared'; // Security Tab — per-site security depth (#30): file-integrity verification, @@ -93,7 +94,7 @@ const SecurityTab = ({ siteId }) => { finally { setBusy(false); } } - if (loading) return ; + if (loading) return } />; const intRunning = integrity?.status === 'running'; const issues = integrity?.issues || []; diff --git a/frontend/src/components/wordpress/detail/ThemesTab.jsx b/frontend/src/components/wordpress/detail/ThemesTab.jsx index ec285cec..441f0952 100644 --- a/frontend/src/components/wordpress/detail/ThemesTab.jsx +++ b/frontend/src/components/wordpress/detail/ThemesTab.jsx @@ -7,6 +7,7 @@ import EmptyState from '../../EmptyState'; import { Pill } from '../../ds'; import { Button } from '@/components/ui/button'; import { Input } from '@/components/ui/input'; +import SkeletonBoundary from '../../SkeletonBoundary'; import { ListItemSkeleton } from './wpDetailShared'; // Themes Tab @@ -92,17 +93,19 @@ const ThemesTab = ({ siteId }) => { if (loading) { return ( -
-
-
+ +
+
+
+
+
+ + + +
-
-
- - - -
-
+ )} /> ); } diff --git a/frontend/src/components/wordpress/detail/UpdatesTab.jsx b/frontend/src/components/wordpress/detail/UpdatesTab.jsx index 190e49b2..be50996f 100644 --- a/frontend/src/components/wordpress/detail/UpdatesTab.jsx +++ b/frontend/src/components/wordpress/detail/UpdatesTab.jsx @@ -5,6 +5,7 @@ import { Pill } from '../../ds'; import { Button } from '@/components/ui/button'; import { Input } from '@/components/ui/input'; import { Label } from '@/components/ui/label'; +import SkeletonBoundary from '../../SkeletonBoundary'; import { OverviewGridSkeleton, UPDATE_SCHEDULES } from './wpDetailShared'; // Updates Tab — safe update manager (#29): snapshot -> update -> health-check -> @@ -59,7 +60,7 @@ const UpdatesTab = ({ siteId }) => { finally { setBusy(false); } } - if (loading) return ; + if (loading) return } />; const runs = data?.runs || []; const running = data?.running; diff --git a/frontend/src/components/wordpress/detail/UptimeTab.jsx b/frontend/src/components/wordpress/detail/UptimeTab.jsx index f4c4b193..19342c2d 100644 --- a/frontend/src/components/wordpress/detail/UptimeTab.jsx +++ b/frontend/src/components/wordpress/detail/UptimeTab.jsx @@ -6,6 +6,7 @@ import { HealthDot } from '../HealthStatusPanel'; import { MetricCard } from '../../ds'; import { Button } from '@/components/ui/button'; import { Label } from '@/components/ui/label'; +import SkeletonBoundary from '../../SkeletonBoundary'; import { OverviewGridSkeleton } from './wpDetailShared'; // Uptime Tab — per-site health + uptime % via a bound status-page component (#26). @@ -59,7 +60,7 @@ const UptimeTab = ({ siteId }) => { } finally { setBusy(false); } } - if (loading) return ; + if (loading) return } />; const comp = data?.component; const pages = data?.pages || []; diff --git a/frontend/src/components/wordpress/detail/VulnerabilitiesTab.jsx b/frontend/src/components/wordpress/detail/VulnerabilitiesTab.jsx index 5155d749..49e9a985 100644 --- a/frontend/src/components/wordpress/detail/VulnerabilitiesTab.jsx +++ b/frontend/src/components/wordpress/detail/VulnerabilitiesTab.jsx @@ -4,6 +4,7 @@ import wordpressApi from '../../../services/wordpress'; import { useToast } from '../../../contexts/ToastContext'; import { KpiBand, MetricCard } from '../../ds'; import { Button } from '@/components/ui/button'; +import SkeletonBoundary from '../../SkeletonBoundary'; import { OverviewGridSkeleton } from './wpDetailShared'; // Vulnerabilities Tab — cross-references plugin/theme/core versions against the @@ -45,7 +46,7 @@ const VulnerabilitiesTab = ({ siteId }) => { } } - if (loading) return ; + if (loading) return } />; const running = data?.scan_status === 'running'; const summary = data?.summary || {}; diff --git a/frontend/src/pages/SSLCertificates.jsx b/frontend/src/pages/SSLCertificates.jsx index 2c0efe24..4b30f80f 100644 --- a/frontend/src/pages/SSLCertificates.jsx +++ b/frontend/src/pages/SSLCertificates.jsx @@ -15,7 +15,8 @@ import { Button } from '@/components/ui/button'; import { Input } from '@/components/ui/input'; import { Label } from '@/components/ui/label'; import { Checkbox } from '@/components/ui/checkbox'; -import { Skeleton } from '@/components/ui/skeleton'; +import { Skeleton } from '@/components/Skeleton'; +import SkeletonBoundary from '@/components/SkeletonBoundary'; const SSLCertificates = () => { const toast = useToast(); @@ -253,37 +254,43 @@ const SSLCertificates = () => { [actionLoading, certbotInstalled, certificates.length], ); - if (loading) { - return ( -
-
- {[1, 2, 3].map(i => ( -
- -
- - -
+ const sslSkeleton = ( + <> +
+ {[1, 2, 3].map(i => ( +
+ +
+ +
- ))} -
-
- {[1, 2].map(i => ( -
- -
- - -
-
- ))} -
+
+ ))}
- ); - } +
+ {[1, 2].map(i => ( +
+
+ +
+ + +
+
+
+ ))} +
+ + ); return ( -
+ <> + + {(!loading || status) && (<> {/* Status Cards */}
@@ -422,6 +429,8 @@ const SSLCertificates = () => {
)} + )} + {/* Obtain Certificate Modal */} setShowObtainModal(false)} title="Obtain SSL Certificate"> @@ -619,7 +628,7 @@ const SSLCertificates = () => {
-
+ ); }; diff --git a/frontend/src/pages/WordPress.jsx b/frontend/src/pages/WordPress.jsx index c2cd15b2..f1572ef8 100644 --- a/frontend/src/pages/WordPress.jsx +++ b/frontend/src/pages/WordPress.jsx @@ -14,6 +14,7 @@ import { Button } from '@/components/ui/button'; import { Input } from '@/components/ui/input'; import { Label } from '@/components/ui/label'; import { Checkbox } from '@/components/ui/checkbox'; +import SkeletonBoundary from '@/components/SkeletonBoundary'; // Mirror the backend slug rule (a-z, 0-9, single dashes) so the create modal can // preview the exact . host the site will be published at. @@ -194,34 +195,40 @@ function WordPress() { [] ); + const wpListSkeleton = ( +
+ {[1, 2, 3].map(i => ( +
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ ))} +
+ ); + if (loading) { return ( -
-
- {[1, 2, 3].map(i => ( -
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- ))} -
-
+ ); } diff --git a/frontend/src/pages/WordPressDetail.jsx b/frontend/src/pages/WordPressDetail.jsx index 5ee4dab9..f5141a4b 100644 --- a/frontend/src/pages/WordPressDetail.jsx +++ b/frontend/src/pages/WordPressDetail.jsx @@ -11,6 +11,7 @@ import { Pill, EnvTag, PageTopbar } from '../components/ds'; import { ErrorBoundary } from '../components/ErrorBoundary'; import EmptyState from '../components/EmptyState'; import PluginSlot from '../components/PluginSlot'; +import SkeletonBoundary from '../components/SkeletonBoundary'; import Modal from '@/components/Modal'; import { Button } from '@/components/ui/button'; import { Input } from '@/components/ui/input'; @@ -130,7 +131,7 @@ const WordPressDetail = () => { } if (loading) { - return ; + return } />; } if (!site) { diff --git a/frontend/src/styles/components/_skeleton.scss b/frontend/src/styles/components/_skeleton.scss index 5413296b..aafd37ae 100644 --- a/frontend/src/styles/components/_skeleton.scss +++ b/frontend/src/styles/components/_skeleton.scss @@ -67,6 +67,17 @@ } } +// Vertical stack for composed skeleton lines (e.g. a title over a subline) that +// sit next to an avatar/icon in a flex row. Fills the remaining row width so +// percentage widths on the child s read against the real column. +.skeleton-stack { + flex: 1; + min-width: 0; + display: flex; + flex-direction: column; + gap: $space-2; +} + // Generic panel skeleton used by EmptyState's loading branch: a header row // (avatar + two lines), a row of stat cards, and a few content lines. .skeleton-panel { @@ -118,8 +129,56 @@ margin-inline: auto; } +// ============================================ +// SKELETON BOUNDARY +// Overlays the loading skeleton on the real content box instead of swapping the +// tree — the overlay inherits the content's dimensions, so nothing jumps when +// data arrives. See components/SkeletonBoundary.jsx. +// ============================================ +.skeleton-boundary { + position: relative; + + // While loading, hide the real (in-flow) children so the overlay reads + // through — but never the skeleton overlay itself. + &[data-loading='true'] > :not(.skeleton-boundary__skeleton) { + visibility: hidden; + } + + &__skeleton { + // Flow mode (no in-flow children yet): the skeleton occupies its + // intrinsic space — same footprint as a plain skeleton swap. + + // Overlay mode: cover the hidden real content exactly. + &--overlay { + position: absolute; + inset: 0; + } + + &--fade { + transition: opacity 200ms ease-out; + } + + &--leaving { + opacity: 0; + } + } +} + @media (prefers-reduced-motion: reduce) { .skeleton::after { animation: none; } + + .skeleton-boundary__skeleton--fade { + transition: none; + } + + // The legacy `@mixin skeleton()` (pages/_wordpress) and the wp-*-skeleton + // families animate the element itself (not a ::after), so disable those too. + // The trailing [class] bumps specificity above the plain `.skeleton` / + // `.wp-*-skeleton` rules so this wins regardless of import order. + .skeleton[class], + [class*='-skeleton'][class] { + animation: none; + } } diff --git a/frontend/src/styles/components/_ui.scss b/frontend/src/styles/components/_ui.scss index f0892064..57221624 100644 --- a/frontend/src/styles/components/_ui.scss +++ b/frontend/src/styles/components/_ui.scss @@ -855,15 +855,6 @@ overflow: hidden; } -// -------------------------------------------- -// SKELETON -// -------------------------------------------- -.ui-skeleton { - border-radius: $radius-md; - background: $bg-secondary; - animation: pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite; -} - // -------------------------------------------- // MODAL (components/Modal.jsx — built on the Dialog primitive) // --------------------------------------------