@charset "UTF-8";

// @description
// * grid-col mixin.
// * This mixin provides a convenient way to set the grid-col to a value
// * using the specified vendor prefixes for better
// * cross-browser compatibility.

// @access public

// @version 1.1.0

// @author Khaled Mohamed

// @license MIT

// @repository: https://github.com/Black-Axis/sass-pire

// @reference: https://developer.mozilla.org/en-US/docs/Web/CSS/grid-column

// @namespace grid

// @module grid/grid-col

// @dependencies:
// * - meta.type-of (SASS function).
// * - list.length (SASS function).
// * - list.nth (SASS function).
// * - string.unquote (SASS function).
// * - string.split (SASS function).
// * - Error.throw (function).

// @param {Number|String} $value
// * The value of column-gap property.
// * If a string, it can be: (normal, initial, inherit).

// @example
// * .example {
// *   @include grid-col("2 / span 3");
// * }

// @output:
// * .example {
// *   -ms-grid-column: 2;
// *   -ms-grid-column-span: span 3;
// *   grid-column: 2 / span 3;
// * }

@use "sass:meta";
@use "sass:string";
@use "sass:list";
@use "../../functions/global/trim-string" as LibFunc;
@use "../../development-utils/toggle-error-message" as Error;

// stylelint-disable property-no-vendor-prefix

@mixin grid-col($value) {
    @if meta.type-of($value) != string {
        content: Error.throw("The parameter of grid-col mixin must be in a string type.");
    }

    $actual-value: string.split($value, "/");

    @if list.length($actual-value) > 2 {
        content: Error.throw("The parameter of grid-col mixin must has two values separated with / character.");
    } @else {
        $first-value: LibFunc.trim(list.nth($actual-value, 1));
        $second-value: LibFunc.trim(list.nth($actual-value, 2));

        @if $first-value == "" or $second-value == "" {
            content: Error.throw("The parameter of grid-col mixin must has two values separated with / character.");
        } @else {
            $first-value: string.unquote($first-value);
            $second-value: string.unquote($second-value);

            -ms-grid-column: $first-value;
            -ms-grid-column-span: $second-value;
            grid-column: $first-value + #{" / "} + $second-value;
        }
    }
}
