@charset "UTF-8";

// @description
// * generate-colors mixin.
// * This mixin generates CSS custom properties for defining colors in the
// * :root element based on the provided color map.
// * It allows you to create a consistent color scheme for your
// * application or website.

// @access public

// @version 1.1.1

// @author Khaled Mohamed

// @license MIT

// @repository: https://github.com/Black-Axis/sass-pire

// @namespace general

// @module general/generate-colors

// @dependencies:
// * - meta.type-of (SASS function).
// * - Settings.$brand-lib-name (settings variable).

// @param {String} $brand-name
// * The brand name or namespace for the color variables.
// * Defaults to the value of the "$brand-lib-name"
// * variable from the "variables" module.

// @param {Map} $color-map
// * A map containing color names and their corresponding values.
// * Each key-value pair represents a custom property for a color.
// * The key (color name) must be a string, and the value must be a color.

// @example 1
// * @include generate-colors("my-brand", (
// *   "primary": #3498db,
// *   "secondary": #2ecc71,
// *   "accent": #e74c3c
// * ));

// @output 1
// * :root {
// *   --my-brand-primary-clr: #3498db;
// *   --my-brand-secondary-clr: #2ecc71;
// *   --my-brand-accent-clr: #e74c3c;
// * }

// @example 2
// * @include generate-colors("", (
// *   "primary": #3498db,
// *   "secondary": #2ecc71,
// *   "accent": #e74c3c
// * ));

// @output 2
// * :root {
// *   --sp-primary-clr: #3498db;
// *   --sp-secondary-clr: #2ecc71;
// *   --sp-accent-clr: #e74c3c;
// * }

// @note 1
// * Make sure to include the "variables" module where the
// * "$brand-lib-name" settings variable is defined.

// @note 2
// * There are two mixins in this file.
// * The first is the (generate-colors) mixin and second is (gen-clrs) mixin.
// * The second one is for only simplicity when using (generate-colors) mixin.
// * The core logic of (gen-clrs) mixin is to call the first one.
// * You can use one of them as you want.

@use "sass:meta";
@use "sass:list";
@use "sass:string";
@use "../../abstract/settings" as Settings;

@mixin generate-colors($brand-name: Settings.$brand-lib-name, $color-map: ()) {
    @if meta.type-of($brand-name) != string {
        @error "Brand name must be in string type.";
    }

    @if meta.type-of($color-map) != map {
        @error "You must pass a map of colors to generate-colors mixin.";
    }

    @if list.length($color-map) == 0 {
        @error "Please, Pass a map with values to generate-colors mixin.";
    }

    :root {
        @each $clr, $val in $color-map {
            @if meta.type-of($clr) != string {
                @error "Please, Make the color name in the string type.";
            }

            @if meta.type-of($val) != color {
                @error "Please, Make sure the value in the map has a color type.";
            }

            @if $brand-name == "" or $brand-name == def {
                --#{Settings.$brand-lib-name}-#{string.to-lower-case($clr)}-clr: #{$val};
            } @else {
                --#{string.to-lower-case($brand-name)}-#{string.to-lower-case($clr)}-clr: #{$val};
            }
        }
    }
}

@mixin gen-clrs($brand-name: Settings.$brand-lib-name, $color-map: ()) {
    @include generate-colors($brand-name, $color-map);
}
