@use 'sass:list';
@use '../variables';

@mixin dg-box-shadow($shadow...) {
    @if variables.$dg-enable-shadows {
        $result: ();

        @if (list.length($shadow) == 1) {
            // We can pass `@include box-shadow(none);`
            $result: $shadow;
        } @else {
            // Filter to avoid invalid properties for example `box-shadow: none, 1px 1px black;`
            @for $i from 1 through list.length($shadow) {
                @if list.nth($shadow, $i) != 'none' {
                    $result: list.append($result, list.nth($shadow, $i), 'comma');
                }
            }
        }
        @if (list.length($result) > 0) {
            box-shadow: $result;
        }
    }
}
