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

////
/// @group themes
/// @package theming
/// @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>
////

/// Action Strip Theme
///
/// PRIMARY TOKENS:
/// - `$actions-background` — The actions background color.
///
/// Derived colors are auto-calculated for contrast.
///
/// @param {Map} $schema [$light-material-schema] - The schema used as basis for styling the component.
/// @param {Color} $icon-color [null] - The color used for the actions icons. Auto-derived from actions-background.
/// @param {Color} $background [null] - The color used for the action strip component content background.
/// @param {Color} $actions-background [null] - The color used for the actions background. PRIMARY - derives icon-color.
/// @param {Color} $delete-action [null] - The color used for the delete icon in action strip component.
/// @param {List} $actions-border-radius [null] - The border radius used for actions container inside action strip component.
///
/// @example scss - Change the background and icon colors in action strip
///   $my-action-strip-theme: action-strip-theme($background: black);
///   // Pass the theme to the css-vars() mixin
///   @include css-vars($my-action-strip-theme);
@function action-strip-theme(
    $schema: $light-material-schema,

    $background: null,
    $actions-background: null,
    $icon-color: null,
    $delete-action: null,
    $actions-border-radius: null
) {
    $selector: 'igx-action-strip';
    $action-strip-schema: ();

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

    $theme: digest-schema($action-strip-schema);

    @if not($icon-color) and $actions-background {
        $icon-color: adaptive-contrast(var(--actions-background));
    }

    @if not($actions-border-radius) {
        $actions-border-radius: map.get($theme, 'actions-border-radius');
    }

    @return extend(
        $theme,
        (
            selector: $selector,
            background: $background,
            actions-background: $actions-background,
            icon-color: $icon-color,
            delete-action: $delete-action,
            actions-border-radius: $actions-border-radius,
        )
    );
}
