@use 'sass:map';
@use '../../config';
@use '../../functions' as *;
@use '../../schemas/' as *;
@use '../../../utils/map' as *;
@use '../../../color/functions' as *;
@use '../../../elevations/' as *;

////
/// @package theming
/// @group themes
/// @access public
/// @author <a href="https://github.com/simeonoff" target="_blank">Simeon Simeonoff</a>
/// @author <a href="https://github.com/desig9stein" target="_blank">Marin Popov</a>
////

/// Icon Theme
///
/// This theme has no automatic token derivation. All tokens are independent.
///
/// @param {Map} $schema [$light-material-schema] - The schema used as basis for styling the component.
/// @param {Color} $color [null] - The icon color.
/// @param {String} $size [null] - The icon size.
/// @param {Color} $disabled-color [null] - The disabled icon color.
/// @requires $light-material-schema
/// @example scss - Change the icon color
///   $my-icon-theme: icon-theme($color: orange);
///   // Pass the theme to the css-vars() mixin
///   @include css-vars($my-icon-theme);
@function icon-theme(
    $schema: $light-material-schema,

    $color: null,
    $size: null,
    $disabled-color: null
) {
    $selector: #{config.element-prefix() + '-' + 'icon'};
    $icon-schema: ();

    @if map.has-key($schema, 'icon') {
        $icon-schema: map.get($schema, 'icon');
    } @else {
        $icon-schema: $schema;
    }

    $theme: digest-schema($icon-schema);

    @return extend(
        $theme,
        (
            selector: $selector,
            color: $color,
            size: $size,
            disabled-color: $disabled-color,
        )
    );
}
