@charset "UTF-8";

// @description
// * every mixin.
// * This mixin provides a convenient way to select the
// * every child of elements in the current context.

// @access public

// @version 1.0.0

// @author Lucas Bonomi
// @link: https://github.com/LukyVj/family.scss

// @license MIT

// @repository: https://github.com/Black-Axis/sass-pire

// @namespace children

// @module children/every

// @dependencies:
// * - meta.type-of (SASS function).
// * - LibFunc.cut-unit (function).
// * - Error.throw (function).

// @update
// * We updated the mixin with validations.

// @param {Number} $num
// * The number of child you want to select.

// @throw {Exception}
// * Throws exceptions if the provided each parameter is not a number.

// @example
// * .example {
// *   .child {
// *     @include every(4) {
// *        background-color: #212121;
// *        color: #ffffff;
// *     };
// *   }
// * }

// @output
// * .example .child:nth-child(4n) {
// *   background-color: #212121;
// *   color: #ffffff;
// * }

@use "sass:meta";
@use "../../functions/global/cut-unit" as LibFunc;
@use "../../development-utils/toggle-error-message" as Error;

@mixin every($num: 1) {
    @if meta.type-of($num) != number {
        content: Error.throw("The parameter of every mixin must be in a number type.");
    }

    $num-without-unit: LibFunc.cut-unit($num);

    &:nth-child(#{$num-without-unit}n) {
        @content;
    }
}
