@charset "UTF-8";

// @description
// * translate-x mixin.
// * This mixin provides a convenient way to apply horizontal translation
// * using the `transform` property with proper vendor prefixes.
// * It supports both numerical values for translation distances and
// * predefined keywords such as:
// * `inherit`, `initial`, `revert`, `unset`, and `none`.

// @access public

// @version 1.4.0

// @author Khaled Mohamed

// @license MIT

// @repository: https://github.com/Black-Axis/sass-pire

// @reference: https://developer.mozilla.org/en-US/docs/Web/CSS/transform

// @namespace transform

// @module transform/translate-x

// @dependencies:
// * - meta.type-of (SASS function).
// * - math.unit (SASS function).
// * - var.$main-units (variable).
// * - LibMixin.prefixing-all (mixin).
// * - Error.throw (function).

// @param {Number|String} $x
// * The horizontal translation distance.
// * Default: 1px.
// * If a number, it must have a valid unit from the main-units list.
// * If a string, it can be: (inherit, initial, revert, unset, none).

// @example
// * .example {
// *   @include translate-x(10px);
// * }

// @output
// * .example {
// *   -webkit-transform: translateX(10px);
// *   -moz-transform: translateX(10px);
// *   -ms-transform: translateX(10px);
// *   -o-transform: translateX(10px);
// *   transform: translateX(10px);
// * }

@use "sass:meta";
@use "sass:list";
@use "sass:math";
@use "../../abstract/global-variables" as var;
@use "../../mixins/vendor-prefixes/prefix" as LibMixin;
@use "../../development-utils/toggle-error-message" as Error;

@mixin translate-x($x: 1px) {
    $transform-props-values: (inherit, initial, revert, unset, none) !default;

    @if meta.type-of($x) == number {
        @if not list.index(var.$main-units, math.unit($x)) {
            content: Error.throw(
                "The parameter of translate-x mixin must has one of these units: (#{var.$main-units})."
            );
        } @else {
            @include LibMixin.prefixing-all(transform, translateX($x));
        }
    } @else if meta.type-of($x) == string {
        @if not list.index($transform-props-values, $x) {
            content: Error.throw(
                "The parameter of translate-x mixin must has one of these values: (#{$transform-props-values})."
            );
        } @else {
            @include LibMixin.prefixing-all(transform, translateX($x));
        }
    } @else {
        content: Error.throw("The value of translate-x mixin must be in a number or a string type.");
    }
}
