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.

12.3 KB
Raw Blame
// ============================================
// SKELETON LOADERS
// Shimmer placeholders shown while content loads — replaces the spinner in
// EmptyState's loading branch. Compose <Skeleton /> primitives for tailored
// per-page skeletons.
// ============================================

.skeleton {
    display: block;
    position: relative;
    overflow: hidden;
    background: var(--surface-2);
    border-radius: $radius-badge;

    // Shimmer sweep — a soft highlight travelling left → right.
    &::after {
        content: '';
        position: absolute;
        inset: 0;
        transform: translateX(-100%);
        background: linear-gradient(
            90deg,
            transparent 0%,
            var(--surface-3) 50%,
            transparent 100%
        );
        animation: skeleton-shimmer 1.4s ease-in-out infinite;
    }

    &--line {
        width: 100%;
        height: 12px;
    }

    &--title {
        width: 40%;
        height: 20px; // geometry: skeleton title bar (content placeholder)
        border-radius: $radius-control;
    }

    &--avatar {
        flex: none;
        width: 48px;
        height: 48px; // geometry: skeleton avatar
        border-radius: $radius-card;
    }

    &--card {
        width: 100%;
        height: 84px;
        border-radius: $radius-card;
    }

    &--block {
        width: 100%;
        height: 100%;
    }

    &--circle {
        border-radius: 50%;
    }
}

@keyframes skeleton-shimmer {
    100% {
        transform: translateX(100%);
    }
}

// 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 {
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: $space-5;

    &__head {
        display: flex;
        align-items: center;
        gap: $space-4;
    }

    &__head-text {
        flex: 1;
        display: flex;
        flex-direction: column;
        gap: $space-2;
    }

    &__cards {
        display: grid;
        grid-template-columns: repeat(3, 1fr);
        gap: $space-4;
    }

    &__rows {
        display: flex;
        flex-direction: column;
        gap: $space-3;
    }

    @media (max-width: $breakpoint-md) {
        &__cards {
            grid-template-columns: 1fr;
        }
    }
}

// Loading variant: stretch the panel full-width and left-align it instead of the
// centered spinner layout the base .empty-state uses.
.empty-state--loading {
    align-items: stretch;
    justify-content: flex-start;
    text-align: left;
    width: 100%;
    max-width: 880px;
    margin-inline: auto;

    // Shaped variants predict a full page layout, so they are not squeezed into
    // the 880px column the generic panel uses.
    &:has(.sk-page-wrap) {
        max-width: none;
        // Several pages early-return their loading state, bypassing the padded
        // container the loaded page renders into. Without this the skeleton
        // spans edge to edge and then everything jumps inward on arrival —
        // exactly the flash a skeleton exists to prevent. Page padding is
        // reasserted here and dropped again below when a real container is
        // already supplying it, so neither case doubles up.
        padding: $space-6;
        min-height: 0;
    }
}

// ============================================
// PAGE SKELETON ARCHETYPES  (components/PageSkeleton.jsx)
// One shape per page layout, so the placeholder predicts what is about to
// arrive instead of promising a layout that never comes.
// ============================================
.sk-page-wrap {
    width: 100%;
}

.sk-page {
    display: flex;
    flex-direction: column;
    gap: $space-4;
    width: 100%;

    // Pushes a trailing control to the right edge of a toolbar row.
    &__push { margin-left: auto; }

    &__toolbar,
    &__conbar {
        display: flex;
        align-items: center;
        gap: $space-3;
        flex-wrap: wrap;
    }

    // ---- table ----
    &__table {
        border: 1px solid $border-subtle;
        border-radius: $radius-card;
        overflow: hidden;
    }

    &__thead,
    &__trow {
        display: grid;
        grid-template-columns: minmax(0, 2.2fr) repeat(4, minmax(0, 1fr));
        align-items: center;
        gap: $space-4;
        padding: $space-3 $space-4;
    }

    &__thead {
        background: $bg-elevated;
        border-bottom: 1px solid $border-subtle;
    }

    &__trow + &__trow { border-top: 1px solid $border-subtle; }

    &__cell--lead {
        display: flex;
        align-items: center;
        gap: $space-3;
        min-width: 0;
    }

    // ---- feed ----
    &__group {
        display: flex;
        flex-direction: column;
        gap: $space-2;
    }

    &__feedrow {
        display: grid;
        grid-template-columns: 16px minmax(0, 1fr) auto 70px 54px;
        align-items: center;
        gap: $space-5;
        padding: $space-3 $space-4;
        background: $bg-card;
        border: 1px solid $border-subtle;
        border-radius: $radius-card;
    }

    &__ticks { display: flex; gap: 3px; }

    // ---- cards ----
    &--cards {
        display: grid;
        grid-template-columns: repeat(auto-fill, minmax(264px, 1fr));
        gap: $space-4;
    }

    &__card {
        display: flex;
        flex-direction: column;
        gap: $space-2;
        padding: $space-4;
        background: $bg-card;
        border: 1px solid $border-subtle;
        border-radius: $radius-card;
    }

    &__card-top {
        display: flex;
        align-items: center;
        gap: $space-3;
        margin-bottom: $space-2;
    }

    &__card-tags {
        display: flex;
        gap: $space-tight;
        margin-top: $space-2;
    }

    // ---- detail ----
    &__hero {
        display: flex;
        align-items: center;
        gap: $space-4;
        padding: $space-5;
        background: $bg-card;
        border: 1px solid $border-subtle;
        border-radius: $radius-card;
    }

    &__stats {
        display: grid;
        grid-template-columns: repeat(4, 1fr);
        gap: $space-4;
    }

    &__stat {
        display: flex;
        flex-direction: column;
        gap: $space-2;
        padding: $space-4;
        background: $bg-card;
        border: 1px solid $border-subtle;
        border-radius: $radius-card;
    }

    &__panels {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: $space-4;
    }

    &__panel {
        display: flex;
        flex-direction: column;
        gap: $space-3;
        padding: $space-4;
        background: $bg-card;
        border: 1px solid $border-subtle;
        border-radius: $radius-card;
    }

    &__kv {
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: $space-4;
    }

    // ---- console ----
    &--console {
        // The log surface is intentionally the same dark slab in every theme,
        // matching the real console.
        .sk-page__lines {
            padding: $space-3 $space-4;
            background: #0d1117;
            border: 1px solid $border-subtle;
            border-radius: $radius-card;
        }
    }

    &__lines {
        display: flex;
        flex-direction: column;
        gap: $space-2;
    }

    &__logline {
        display: flex;
        align-items: center;
        gap: $space-4;
    }

    // ---- form ----
    &--form { max-width: 640px; }

    &__field {
        display: flex;
        flex-direction: column;
        gap: $space-2;
    }

    &__formfoot {
        display: flex;
        justify-content: flex-end;
        gap: $space-2;
        margin-top: $space-2;
    }

    // ---- chart ----
    &__plot {
        display: flex;
        flex-direction: column;
        gap: $space-3;
        padding: $space-4;
        background: $bg-card;
        border: 1px solid $border-subtle;
        border-radius: $radius-card;
    }

    &__plot-bars {
        display: flex;
        align-items: flex-end;
        gap: $space-2;
        height: 190px;

        > * { flex: 1; }
    }

    &__plot-axis {
        display: flex;
        justify-content: space-between;
    }

    // ---- tree / split ----
    &--tree,
    &--split {
        display: grid;
        gap: $space-4;
    }

    &--tree { grid-template-columns: 260px minmax(0, 1fr); }
    &--split { grid-template-columns: minmax(0, 1fr) 320px; }

    &__rail,
    &__pane,
    &__main,
    &__aside {
        display: flex;
        flex-direction: column;
        gap: $space-3;
        min-width: 0;
    }

    &__rail {
        padding: $space-3;
        background: $bg-card;
        border: 1px solid $border-subtle;
        border-radius: $radius-card;
    }

    &__twig {
        display: flex;
        align-items: center;
        gap: $space-2;

        // Decorative depth stagger. Twigs start as the rail's second child
        // (after the leading block), which offsets the 3-cycle by two —
        // hence 3n / 3n+1 rather than 3n+2 / 3n.
        &:nth-child(3n) { padding-left: 14px; }
        &:nth-child(3n + 1) { padding-left: 28px; }
    }

    @media (max-width: $breakpoint-md) {
        &__thead,
        &__trow { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); }
        &__thead > *:nth-child(n + 3),
        &__trow > *:nth-child(n + 3) { display: none; }

        &__feedrow { grid-template-columns: 16px minmax(0, 1fr) auto; }
        &__feedrow > *:nth-child(n + 4) { display: none; }

        &__stats { grid-template-columns: repeat(2, 1fr); }
        &__panels { grid-template-columns: 1fr; }
        &--tree,
        &--split { grid-template-columns: 1fr; }
        &__rail { display: none; }
    }
}

// ============================================
// 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;
        }
    }
}

// Captured-bone replay (renderBones): a positioned canvas of leaf placeholders
// measured from the real layout. Each .skeleton-bone carries its own dynamic
// left/top/width/height inline; the look comes from the shared .skeleton class.
.skeleton-bones {
    position: relative;
    width: 100%;
}

.skeleton-bone {
    position: absolute;
}

@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;
    }
}

// Style-guide gallery: each archetype labelled, so they can be compared and a
// regression in any one of them is visible in a single screenshot.
.sk-gallery {
    padding: $space-4;
    background: $bg-card;
    border: 1px solid $border-subtle;
    border-radius: $radius-card;

    + .sk-gallery { margin-top: $space-4; }

    &__name {
        margin-bottom: $space-3;
        color: $text-tertiary;
        font-family: var(--mono);
        font-size: $text-xs;
    }
}