@use 'sass:map';
@use '../../config';
@use '../../functions' as *;
@use '../../schemas/' as *;
@use '../../../utils/map' 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>
////

/// Column Actions Theme
///
/// PRIMARY TOKENS:
/// - `$background-color` — The background color of the panel.
///
/// Derived colors are auto-calculated for contrast.
///
/// @param {Map} $schema [$light-material-schema] - The schema used as basis for styling the component.
/// @param {Color} $title-color [null]- The text color used for the title of the list. Auto-derived from background-color.
/// @param {Color} $background-color [null] - The background color of the panel. PRIMARY - derives title-color.
///
/// @requires $light-material-schema
///
/// @example scss - Change the title color
///   $column-actions-theme: igx-column-actions-theme($title-color: black);
///   // Pass the theme to the css-vars mixin
///   @include css-vars($column-actions-theme);
////
@function column-actions-theme(
    $schema: $light-material-schema,

    $title-color: null,
    $background-color: null
) {
    $selector: #{config.element-prefix() + '-' + 'column-actions'};
    $column-actions-schema: ();

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

    $theme: digest-schema($column-actions-schema);

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

    @return extend(
        $theme,
        (
            selector: $selector,
            title-color: $title-color,
            background-color: $background-color,
        )
    );
}
