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.

7.2 KB
Raw Blame
// ============================================
// FORM COMPONENTS
// ============================================

.form-group {
    margin-bottom: $space-5;

    label {
        display: block;
        font-size: $text-sm;
        font-weight: $font-weight-medium;
        color: $text-secondary;
        margin-bottom: $space-2;
    }

    input,
    select,
    textarea {
        @include input-base();
    }

    select {
        cursor: pointer;
        appearance: none;
        background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%2371717a' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
        background-repeat: no-repeat;
        background-position: right $space-4 center;
        padding-right: $space-10;
    }

    textarea {
        font-family: $font-mono;
        resize: vertical;
        min-height: 120px;
    }
}

// Two column form row
.form-row {
    // Keep system-domain fields on the shared responsive grid.
    &.system-domain-row { display: grid; gap: $space-4; }

display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: $space-4;

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

// Standard form field wrapper (used by <FormField /> component).
.form-field {
    margin-bottom: $space-4;

    &__label {
        display: inline-flex;
        align-items: center;
        gap: $space-1;
        font-size: $text-xs;
        font-weight: $font-weight-medium;
        color: $text-secondary;
        margin-bottom: $space-2;
    }

    &__required {
        color: $danger;
    }

    &__control {
        // Native controls and component controls share the same field contract.
        // Exclude checkboxes/radios and buttons: their intrinsic size matters.
        > input:not([type="checkbox"]):not([type="radio"]):not([type="hidden"]):not([type="range"]):not([type="color"]):not(.ui-input),
        > select,
        > textarea:not(.ui-textarea) {
            @include input-base();
        }

        > input:not([type="checkbox"]):not([type="radio"]):not([type="range"]):not([type="color"]),
        > select,
        > textarea,
        > .ui-select-trigger {
            width: 100%;
        }

        > select { cursor: pointer; }

        > input[type="checkbox"],
        > input[type="radio"] { accent-color: $accent-primary; }
    }

    &__hint {
        font-size: $text-xs;
        color: $text-tertiary;
        margin-top: $space-1;
        margin-bottom: 0;
    }

    &__error {
        font-size: $text-xs;
        color: $danger;
        margin-top: $space-1;
        margin-bottom: 0;
    }

    // The label carries the failure too, so a field scrolled half out of
    // view still reads as the one to fix.
    &--invalid &__label { color: $danger; }
}

// Inline form (input + button)
.install-form,
.env-form,
.command-input {
    display: flex;
    gap: $space-3;
    margin-bottom: $space-6;

    input {
        flex: 1;
        @include input-base();
    }
}

// Hint text
.hint {
    color: $text-tertiary;
    font-size: $text-sm;
    margin-bottom: $space-4;
}

// Error message
.error-message {
    display: flex;
    align-items: flex-start;
    gap: $space-2;
    line-height: 1.5;

    > svg {
        flex-shrink: 0;
        margin-top: $space-hair;
    }
}

.error-message {
    background: $danger-bg;
    border: 1px solid $danger-border;
    color: $danger;
    padding: $space-3 $space-4;
    border-radius: $radius-card;
    margin-bottom: $space-5;
    font-size: $text-sm;
}

// Filter toggle (checkbox)
.filter-toggle {
    @include flex-start();
    gap: $space-2;

    label {
        @include flex-start();
        gap: $space-2;
        color: $text-secondary;
        font-size: $text-sm;
        cursor: pointer;
    }

    input[type="checkbox"] {
        width: 16px;
        height: 16px;
        accent-color: $accent-primary;
    }
}

// Standalone form elements (used outside .form-group)
.form-input {
    @include input-base();
}

.form-select {
    @include input-base();
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%2371717a' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right $space-4 center;
    padding-right: $space-10;
}

// Code editor textarea
.code-editor {
    width: 100%;
    min-height: 400px;
    padding: $space-4;
    background: $bg-body;
    border: 1px solid $border-subtle;
    border-radius: $radius-card;
    color: $text-primary;
    font-family: $font-mono;
    font-size: $text-sm;
    line-height: $line-height-relaxed;
    resize: vertical;
    @include transition(border-color);

    &:focus {
        border-color: $accent-primary;
    }
}

.checkbox-label {
@include flex-start();
    gap: $space-2;
    cursor: pointer;

    input[type="checkbox"] {
        width: 16px;
        height: 16px;
        cursor: pointer;
        accent-color: $accent-primary;
    }

    .checkbox-text { font-weight: $font-weight-normal; }
}

.permission-checkbox {
display: flex;
    justify-content: center;
    align-items: center;
    gap: $space-2;
    font-size: $text-xs;
    color: $text-secondary;
    cursor: pointer;

    input[type="checkbox"] {
        width: 16px;
        height: 16px;
        cursor: pointer;
        accent-color: $accent-primary;
    }

    &:hover { color: $text-primary; }
}

.settings-form {
    margin-bottom: 0;
    background: $bg-card;
    border: 1px solid $border-default;
    border-radius: $radius-card;
    padding: $space-5;

    // Forms already inside a card inherit its surface and spacing.
    .settings-card & {
        background: transparent;
        border: 0;
        border-radius: 0;
        padding: 0;
    }

    .form-group {
        margin-bottom: $space-4;

        &:last-of-type {
            margin-bottom: 0;
        }

        label {
            display: block;
            font-size: $text-xs;
            font-weight: $font-weight-medium;
            color: $text-secondary;
            margin-bottom: $space-2;
        }

        input:not([type="checkbox"]):not([type="radio"]), select, textarea {
            width: 100%;
            padding: $space-3;
            background: $bg-hover;
            border: 1px solid $border-default;
            border-radius: $radius-control;
            color: $text-primary;
            font-size: $text-xs;
            transition: border-color $transition-fast;

            &:focus {
                outline: none;
                border-color: $accent-primary;
            }

            &:disabled,
            &.input-disabled {
                opacity: 0.6;
                cursor: not-allowed;
                background: $bg-body;
            }
        }

        .form-help {
            display: block;
            margin-top: $space-1;
            font-size: $text-xs;
            color: $text-tertiary;
        }
    }

    .form-actions {
        margin-top: $space-5;
        padding-top: $space-5;
        border-top: 1px solid $border-subtle;
        display: flex;
        gap: $space-2;
    }

    .form-section .btn[type="submit"] {
        margin-top: $space-4;
    }
}