mirror of
https://github.com/jhd3197/ServerKit.git
synced 2026-12-03 13:45:09 +09:00
feat(frontend): consolidate skeletons + overlay SkeletonBoundary (plan 50 phase 1)
Deprecate the Tailwind `ui/skeleton` shim (deleted; its two call sites moved to the SCSS `Skeleton` primitive with no raw Tailwind sizing classes) and add `SkeletonBoundary`, which keeps real content in flow and paints the skeleton over its exact box while loading — inheriting the real dimensions so there is no cumulative layout shift when data arrives. Falls back to intrinsic size when the data-gated children are still absent (first load), overlays once content is present (refresh). Migrated the worst hand-guessed loaders through the boundary: SSL certificates, WordPress list + detail page, the WordPress activity feed, and all 11 WordPress detail tabs. Skeleton shimmer now honors prefers-reduced-motion across the legacy wp-* skeleton families too (specificity-proof override), and loading regions set aria-busy. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
1 parent
d1589024e3
commit
c687ea4dc4
20 files changed
+321
-134
No files matched your search
@@ -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.
|
||||
*
|
||||
* <SkeletonBoundary loading={isLoading} skeleton={<CertListSkeleton />}>
|
||||
* {status && <CertList data={status} />}
|
||||
* </SkeletonBoundary>
|
||||
*
|
||||
* 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 (
|
||||
<Tag
|
||||
className={cn('skeleton-boundary', className)}
|
||||
data-loading={loading ? 'true' : undefined}
|
||||
aria-busy={loading ? 'true' : undefined}
|
||||
{...rest}
|
||||
>
|
||||
{children}
|
||||
{showSkeleton && (
|
||||
<div
|
||||
className={cn(
|
||||
'skeleton-boundary__skeleton',
|
||||
hasContent && 'skeleton-boundary__skeleton--overlay',
|
||||
transition && 'skeleton-boundary__skeleton--fade',
|
||||
leaving && 'skeleton-boundary__skeleton--leaving',
|
||||
)}
|
||||
aria-hidden="true"
|
||||
>
|
||||
{skeleton}
|
||||
</div>
|
||||
)}
|
||||
</Tag>
|
||||
);
|
||||
}
|
||||
|
||||
export default SkeletonBoundary;
|
||||
@@ -1,7 +0,0 @@
|
||||
import { cn } from '@/lib/utils';
|
||||
|
||||
function Skeleton({ className, ...props }) {
|
||||
return <div className={cn('ui-skeleton', className)} {...props} />;
|
||||
}
|
||||
|
||||
export { Skeleton };
|
||||
@@ -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 (
|
||||
<div className="activity-feed">
|
||||
{[1, 2, 3].map(i => (
|
||||
<div key={i} className="activity-item-skeleton">
|
||||
<Skeleton className="h-8 w-8 rounded-full" />
|
||||
<div style={{ flex: 1 }}>
|
||||
<Skeleton className="h-3.5 w-3/5 mb-1.5" />
|
||||
<Skeleton className="h-3 w-2/5" />
|
||||
</div>
|
||||
const feedSkeleton = (
|
||||
<>
|
||||
{[1, 2, 3].map(i => (
|
||||
<div key={i} className="activity-item-skeleton">
|
||||
<Skeleton variant="circle" width={32} height={32} />
|
||||
<div className="skeleton-stack">
|
||||
<Skeleton variant="line" width="60%" />
|
||||
<Skeleton variant="line" width="40%" />
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
</div>
|
||||
))}
|
||||
</>
|
||||
);
|
||||
|
||||
if (activities.length === 0) {
|
||||
if (!loading && activities.length === 0) {
|
||||
return (
|
||||
<div className="activity-feed-empty">
|
||||
<p>No activity recorded yet.</p>
|
||||
@@ -85,8 +84,12 @@ const ActivityFeed = ({ projectId, envId, limit = 20, compact = false }) => {
|
||||
}
|
||||
|
||||
return (
|
||||
<div className={`activity-feed ${compact ? 'compact' : ''}`}>
|
||||
{activities.map(activity => {
|
||||
<SkeletonBoundary
|
||||
className={`activity-feed ${compact ? 'compact' : ''}`.trim()}
|
||||
loading={loading}
|
||||
skeleton={feedSkeleton}
|
||||
>
|
||||
{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
|
||||
</Button>
|
||||
)}
|
||||
</div>
|
||||
</SkeletonBoundary>
|
||||
);
|
||||
};
|
||||
|
||||
|
||||
@@ -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 <OverviewGridSkeleton panels={3} />;
|
||||
if (loading) return <SkeletonBoundary loading skeleton={<OverviewGridSkeleton panels={3} />} />;
|
||||
|
||||
const fmtHour = (iso) => {
|
||||
const d = new Date(iso);
|
||||
|
||||
@@ -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 (
|
||||
<div className="environments-tab">
|
||||
<div className="section-header">
|
||||
<div className="skeleton" style={{ width: 120, height: 24 }} />
|
||||
<div className="skeleton" style={{ width: 160, height: 36, borderRadius: 6 }} />
|
||||
<SkeletonBoundary loading skeleton={(
|
||||
<div className="environments-tab">
|
||||
<div className="section-header">
|
||||
<div className="skeleton" style={{ width: 120, height: 24 }} />
|
||||
<div className="skeleton" style={{ width: 160, height: 36, borderRadius: 6 }} />
|
||||
</div>
|
||||
<div className="environments-grid">
|
||||
<EnvironmentCardSkeleton />
|
||||
<EnvironmentCardSkeleton />
|
||||
</div>
|
||||
</div>
|
||||
<div className="environments-grid">
|
||||
<EnvironmentCardSkeleton />
|
||||
<EnvironmentCardSkeleton />
|
||||
</div>
|
||||
</div>
|
||||
)} />
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -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 (
|
||||
<div className="git-tab">
|
||||
<div className="git-connect git-connect--card">
|
||||
<div className="skeleton" style={{ width: 200, height: 24, marginBottom: 16 }} />
|
||||
<div className="skeleton" style={{ height: 44, borderRadius: 6, marginBottom: 12 }} />
|
||||
<div className="skeleton" style={{ height: 44, borderRadius: 6, marginBottom: 12 }} />
|
||||
<div className="skeleton" style={{ width: 140, height: 36, borderRadius: 6 }} />
|
||||
<SkeletonBoundary loading skeleton={(
|
||||
<div className="git-tab">
|
||||
<div className="git-connect git-connect--card">
|
||||
<div className="skeleton" style={{ width: 200, height: 24, marginBottom: 16 }} />
|
||||
<div className="skeleton" style={{ height: 44, borderRadius: 6, marginBottom: 12 }} />
|
||||
<div className="skeleton" style={{ height: 44, borderRadius: 6, marginBottom: 12 }} />
|
||||
<div className="skeleton" style={{ width: 140, height: 36, borderRadius: 6 }} />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
)} />
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -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 <OverviewGridSkeleton panels={2} />;
|
||||
if (loading) return <SkeletonBoundary loading skeleton={<OverviewGridSkeleton panels={2} />} />;
|
||||
|
||||
const limits = php?.limits || {};
|
||||
const current = php?.php_version || 'Unknown';
|
||||
|
||||
@@ -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 (
|
||||
<div className="plugins-tab">
|
||||
<div className="section-header">
|
||||
<div className="skeleton" style={{ width: 80, height: 24 }} />
|
||||
<SkeletonBoundary loading skeleton={(
|
||||
<div className="plugins-tab">
|
||||
<div className="section-header">
|
||||
<div className="skeleton" style={{ width: 80, height: 24 }} />
|
||||
</div>
|
||||
<div className="skeleton" style={{ height: 44, borderRadius: 6, marginBottom: 16 }} />
|
||||
<div className="plugins-list">
|
||||
<ListItemSkeleton />
|
||||
<ListItemSkeleton />
|
||||
<ListItemSkeleton />
|
||||
</div>
|
||||
</div>
|
||||
<div className="skeleton" style={{ height: 44, borderRadius: 6, marginBottom: 16 }} />
|
||||
<div className="plugins-list">
|
||||
<ListItemSkeleton />
|
||||
<ListItemSkeleton />
|
||||
<ListItemSkeleton />
|
||||
</div>
|
||||
</div>
|
||||
)} />
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -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 <OverviewGridSkeleton panels={2} />;
|
||||
if (loading) return <SkeletonBoundary loading skeleton={<OverviewGridSkeleton panels={2} />} />;
|
||||
|
||||
const selected = reports.find(r => r.id === selectedId) || null;
|
||||
|
||||
|
||||
@@ -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 <OverviewGridSkeleton panels={2} />;
|
||||
if (loading) return <SkeletonBoundary loading skeleton={<OverviewGridSkeleton panels={2} />} />;
|
||||
|
||||
const intRunning = integrity?.status === 'running';
|
||||
const issues = integrity?.issues || [];
|
||||
|
||||
@@ -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 (
|
||||
<div className="themes-tab">
|
||||
<div className="section-header">
|
||||
<div className="skeleton" style={{ width: 80, height: 24 }} />
|
||||
<SkeletonBoundary loading skeleton={(
|
||||
<div className="themes-tab">
|
||||
<div className="section-header">
|
||||
<div className="skeleton" style={{ width: 80, height: 24 }} />
|
||||
</div>
|
||||
<div className="skeleton" style={{ height: 44, borderRadius: 6, marginBottom: 16 }} />
|
||||
<div className="themes-list">
|
||||
<ListItemSkeleton />
|
||||
<ListItemSkeleton />
|
||||
<ListItemSkeleton />
|
||||
</div>
|
||||
</div>
|
||||
<div className="skeleton" style={{ height: 44, borderRadius: 6, marginBottom: 16 }} />
|
||||
<div className="themes-list">
|
||||
<ListItemSkeleton />
|
||||
<ListItemSkeleton />
|
||||
<ListItemSkeleton />
|
||||
</div>
|
||||
</div>
|
||||
)} />
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -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 <OverviewGridSkeleton panels={2} />;
|
||||
if (loading) return <SkeletonBoundary loading skeleton={<OverviewGridSkeleton panels={2} />} />;
|
||||
|
||||
const runs = data?.runs || [];
|
||||
const running = data?.running;
|
||||
|
||||
@@ -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 <OverviewGridSkeleton panels={2} />;
|
||||
if (loading) return <SkeletonBoundary loading skeleton={<OverviewGridSkeleton panels={2} />} />;
|
||||
|
||||
const comp = data?.component;
|
||||
const pages = data?.pages || [];
|
||||
|
||||
@@ -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 <OverviewGridSkeleton panels={2} />;
|
||||
if (loading) return <SkeletonBoundary loading skeleton={<OverviewGridSkeleton panels={2} />} />;
|
||||
|
||||
const running = data?.scan_status === 'running';
|
||||
const summary = data?.summary || {};
|
||||
|
||||
@@ -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 (
|
||||
<div className="sk-tabgroup__inner ssl-page">
|
||||
<div className="ssl-status-bar">
|
||||
{[1, 2, 3].map(i => (
|
||||
<div key={i} className="ssl-status-item">
|
||||
<Skeleton className="w-12 h-12 rounded-xl" />
|
||||
<div>
|
||||
<Skeleton className="w-20 h-3.5 mb-1.5" />
|
||||
<Skeleton className="w-12 h-3" />
|
||||
</div>
|
||||
const sslSkeleton = (
|
||||
<>
|
||||
<div className="ssl-status-bar">
|
||||
{[1, 2, 3].map(i => (
|
||||
<div key={i} className="ssl-status-item">
|
||||
<Skeleton variant="avatar" />
|
||||
<div className="skeleton-stack">
|
||||
<Skeleton variant="title" width="55%" />
|
||||
<Skeleton variant="line" width="35%" />
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
<div className="ssl-cert-list">
|
||||
{[1, 2].map(i => (
|
||||
<div key={i} className="ssl-cert-item">
|
||||
<Skeleton className="w-10 h-10 rounded-xl" />
|
||||
<div className="flex-1">
|
||||
<Skeleton className="w-48 h-3.5 mb-2" />
|
||||
<Skeleton className="w-72 h-3" />
|
||||
</div>
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
<div className="ssl-cert-list">
|
||||
{[1, 2].map(i => (
|
||||
<div key={i} className="ssl-cert-item">
|
||||
<div className="ssl-cert-item-info">
|
||||
<Skeleton variant="avatar" />
|
||||
<div className="skeleton-stack">
|
||||
<Skeleton variant="title" width={200} />
|
||||
<Skeleton variant="line" width={280} />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
</>
|
||||
);
|
||||
|
||||
return (
|
||||
<div className="sk-tabgroup__inner ssl-page">
|
||||
<>
|
||||
<SkeletonBoundary
|
||||
className="sk-tabgroup__inner ssl-page"
|
||||
loading={loading}
|
||||
skeleton={sslSkeleton}
|
||||
>
|
||||
{(!loading || status) && (<>
|
||||
{/* Status Cards */}
|
||||
<div className="ssl-status-bar">
|
||||
<div className="ssl-status-item">
|
||||
@@ -422,6 +429,8 @@ const SSLCertificates = () => {
|
||||
</Button>
|
||||
</div>
|
||||
)}
|
||||
</>)}
|
||||
</SkeletonBoundary>
|
||||
|
||||
{/* Obtain Certificate Modal */}
|
||||
<Modal open={showObtainModal} onClose={() => setShowObtainModal(false)} title="Obtain SSL Certificate">
|
||||
@@ -619,7 +628,7 @@ const SSLCertificates = () => {
|
||||
</div>
|
||||
</form>
|
||||
</Modal>
|
||||
</div>
|
||||
</>
|
||||
);
|
||||
};
|
||||
|
||||
|
||||
@@ -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 <slug>.<base> host the site will be published at.
|
||||
@@ -194,34 +195,40 @@ function WordPress() {
|
||||
[]
|
||||
);
|
||||
|
||||
const wpListSkeleton = (
|
||||
<div className="wp-sites-grid">
|
||||
{[1, 2, 3].map(i => (
|
||||
<div key={i} className="wp-site-card-skeleton">
|
||||
<div className="wp-site-card-skeleton-header">
|
||||
<div className="wp-site-card-skeleton-icon" />
|
||||
<div className="wp-site-card-skeleton-info">
|
||||
<div className="wp-site-card-skeleton-name" />
|
||||
<div className="wp-site-card-skeleton-url" />
|
||||
</div>
|
||||
<div className="wp-site-card-skeleton-status" />
|
||||
</div>
|
||||
<div className="wp-site-card-skeleton-body">
|
||||
<div className="wp-site-card-skeleton-meta">
|
||||
<div className="wp-site-card-skeleton-label" />
|
||||
<div className="wp-site-card-skeleton-value" />
|
||||
</div>
|
||||
<div className="wp-site-card-skeleton-meta">
|
||||
<div className="wp-site-card-skeleton-label" />
|
||||
<div className="wp-site-card-skeleton-value" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
);
|
||||
|
||||
if (loading) {
|
||||
return (
|
||||
<div className="sk-tabgroup__inner wordpress-page">
|
||||
<div className="wp-sites-grid">
|
||||
{[1, 2, 3].map(i => (
|
||||
<div key={i} className="wp-site-card-skeleton">
|
||||
<div className="wp-site-card-skeleton-header">
|
||||
<div className="wp-site-card-skeleton-icon" />
|
||||
<div className="wp-site-card-skeleton-info">
|
||||
<div className="wp-site-card-skeleton-name" />
|
||||
<div className="wp-site-card-skeleton-url" />
|
||||
</div>
|
||||
<div className="wp-site-card-skeleton-status" />
|
||||
</div>
|
||||
<div className="wp-site-card-skeleton-body">
|
||||
<div className="wp-site-card-skeleton-meta">
|
||||
<div className="wp-site-card-skeleton-label" />
|
||||
<div className="wp-site-card-skeleton-value" />
|
||||
</div>
|
||||
<div className="wp-site-card-skeleton-meta">
|
||||
<div className="wp-site-card-skeleton-label" />
|
||||
<div className="wp-site-card-skeleton-value" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
<SkeletonBoundary
|
||||
className="sk-tabgroup__inner wordpress-page"
|
||||
loading
|
||||
skeleton={wpListSkeleton}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -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 <DetailPageSkeleton />;
|
||||
return <SkeletonBoundary loading skeleton={<DetailPageSkeleton />} />;
|
||||
}
|
||||
|
||||
if (!site) {
|
||||
|
||||
@@ -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 <Skeleton>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;
|
||||
}
|
||||
}
|
||||
@@ -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)
|
||||
// --------------------------------------------
|
||||
|
||||
Reference in new issue
Block a user