@charset "UTF-8";

// @description
// * square mixin.
// * Create a square shape with equal width and height.

// @access public

// @version 1.5.1

// @author Khaled Mohamed

// @license MIT

// @repository: https://github.com/Black-Axis/sass-pire

// @namespace general

// @module general/square

// @dependencies:
// * - meta.type-of (SASS function).
// * - math.is-unitless (SASS function).
// * - math.unit (SASS function).
// * - var.$all-units (variable).
// * - LibFunc.is-in-list (function).
// * - Error.throw (function).

// @param {Number} $one-side
// * The length of one side of the square.

// @example
// * .example {
// *   @include square(50px);
// * }

// @output
// * .example {
// *   --sp-one-side: 50px;
// *   width: var(--sp-one-side);
// *   height: var(--sp-one-side);
// * }

// @note
// * There are two mixins in this file.
// * The first is the (square) mixin and second is (sq) mixin.
// * The second one is for only simplicity when using (square) mixin.
// * The core logic of (sq) mixin is to call the first one.
// * You can use one of them as you want.

@use "sass:meta";
@use "sass:list";
@use "sass:math";
@use "../../abstract/global-variables" as var;
@use "../../functions/global/is-in-list" as LibFunc;
@use "../../development-utils/toggle-error-message" as Error;

@mixin square($one-side: 1px) {
    @if meta.type-of($one-side) == number {
        @if not math.is-unitless($one-side) {
            @if LibFunc.is-in-list(var.$all-units, math.unit($one-side)) {
                --sp-one-side: #{$one-side};

                width: var(--sp-one-side);
                height: var(--sp-one-side);
            } @else {
                content: Error.throw("The parameter of square mixin must be one of: (#{var.$all-units}).");
            }
        } @else {
            content: Error.throw("The parameter of square mixin has a unit of a number type.");
        }
    } @else {
        content: Error.throw("The parameter of square mixin must be in a number type.");
    }
}

@mixin sq($one-side: 1px) {
    @include square($one-side);
}
