@use '../styles/variables';

@mixin slider-type($color) {
    .thy-slider-rail {
        background-color: variables.$gray-200;
        .thy-slider-track {
            background-color: $color;
        }
        .thy-slider-pointer {
            border-color: $color;
            background-color: variables.$bg-default;
        }
    }
}

@mixin slider-pointer-size($size) {
    @if $size == variables.$slider-height-sm {
        width: 8px;
        height: 14px;
    } @else if $size == variables.$slider-height-md {
        width: 8px;
        height: 18px;
    } @else if $size == variables.$slider-height-lg {
        width: 12px;
        height: 26px;
    }
}

@mixin slider-track-radius($size) {
    @if $size == variables.$slider-height-sm {
        border-radius: 5px;
    } @else if $size == variables.$slider-height-md {
        border-radius: 20px;
    } @else if $size == variables.$slider-height-lg {
        border-radius: 100px;
    }
}

@mixin set-slider-size($size) {
    .thy-slider-rail {
        height: $size;
        @include slider-track-radius($size);
        .thy-slider-track {
            height: $size;
            @include slider-track-radius($size);
        }
        .thy-slider-pointer {
            position: absolute;
            top: 50%;
            transform: translate(-50%, -50%);
            @include slider-pointer-size($size);
        }
    }

    &.slider-vertical {
        height: 100%;
        width: $size;
        display: inline-block;
        .thy-slider-rail {
            width: $size;
            height: 100%;
            .thy-slider-track {
                width: $size;
                height: 100%;
            }
            .thy-slider-pointer {
                transform: translate(-50%, 50%) rotate(90deg);
                left: 50%;
                bottom: 0;
                top: unset;
            }
        }
    }
}

.thy-slider {
    width: 100%;
    padding: 5px;
    box-sizing: border-box;
    height: 15px;
    display: block;
    .thy-slider-rail {
        position: relative;
        width: 100%;
        height: 6px;
        border-radius: 5px;
        background-color: variables.$gray-200;
        .thy-slider-track {
            position: absolute;
            height: 6px;
            border-radius: 5px;
        }
        .thy-slider-pointer {
            position: absolute;
            top: 50%;
            transform: translate(-50%, -50%);
            border-radius: 6px;
            width: 8px;
            height: 14px;
            border-width: 1px;
            border-style: solid;
            background-color: variables.$bg-default;
        }
    }

    &.slider-vertical {
        height: 100%;
        width: 15px;
        display: inline-block;
        .thy-slider-rail {
            width: 6px;
            height: 100%;
            .thy-slider-track {
                width: 6px;
                bottom: 0;
            }
            .thy-slider-pointer {
                transform: translate(-50%, 50%) rotate(90deg);
                left: 50%;
                bottom: 0;
                top: unset;
            }
        }
    }

    &.slider-disabled {
        cursor: variables.$disabled-cursor;
        .thy-slider-rail {
            background-color: variables.$gray-100;
            .thy-slider-track {
                background-color: variables.$gray-400;
            }
            .thy-slider-pointer {
                border-color: variables.$gray-400;
            }
        }
    }

    &.thy-slider-primary {
        @include slider-type(variables.$primary);
    }
    &,
    &.thy-slider-success {
        @include slider-type(variables.$success);
    }
    &.thy-slider-info {
        @include slider-type(variables.$info);
    }
    &.thy-slider-warning {
        @include slider-type(variables.$warning);
    }
    &.thy-slider-danger {
        @include slider-type(variables.$danger);
    }

    &.thy-slider-sm {
        @include set-slider-size(variables.$slider-height-sm);
    }

    &.thy-slider-md {
        @include set-slider-size(variables.$slider-height-md);
    }

    &.thy-slider-lg {
        @include set-slider-size(variables.$slider-height-lg);
    }
}
