@import "./variable";

// 遍历主题
@mixin themeify {
    @each $theme-name, $theme-map in $themes {
        // !global 把局部变量强升为全局变量
        $theme-map: $theme-map !global;
        [data-theme="#{$theme-name}"] & {
            @content;
        }
    }
}

@function themed($key) {
    @return map-get($theme-map, $key);
}

// 获取系统背景色
@mixin bg_color($color: null) {
    @if $color!=null {
        background-color: $color;
    } @else {
        @include themeify {
            background-color: themed("bg_color");
        }
    }
}

// 获取系统背景色 - 主题色
@mixin bg_color_theme($color: null) {
    @if $color!=null {
        background-color: $color;
    } @else {
        @include themeify {
            background-color: themed("bg_color_theme");
        }
    }
}

// 获取系统背景色 - 带模糊程度
@mixin bg_color_opacity($color: null) {
    @if $color!=null {
        background-color: $color;
    } @else {
        @include themeify {
            background-color: themed("bg_color_opacity");
        }
    }
}
@mixin bg_color_opacity_7($color: null) {
    @if $color!=null {
        background-color: $color;
    } @else {
        @include themeify {
            background-color: themed("bg_color_opacity_7");
        }
    }
}

// 获取边框颜色
@mixin bg_border_color($color: null) {
    @if $color!=null {
        border-color: $color;
    } @else {
        @include themeify {
            border-color: themed("bg_border_color");
        }
    }
}

// 获取灰色的边框颜色
@mixin bg_border_color_gray($color: null) {
    @if $color!=null {
        border-color: $color;
    } @else {
        @include themeify {
            border-color: themed("bg_border_color_gray");
        }
    }
}

// 获取字体颜色
@mixin font_color($color: null) {
    @if $color!=null {
        color: $color;
    } @else {
        @include themeify {
            color: themed("font_color");
        }
    }
}

@mixin font_color_theme($color: null) {
    @if $color!=null {
        color: $color;
    } @else {
        @include themeify {
            color: themed("font_color_theme");
        }
    }
}

// 灰色字色
@mixin font_color_gray($color: null) {
    @if $color!=null {
        color: $color;
    } @else {
        @include themeify {
            color: themed("font_color_gray");
        }
    }
}

// 背景盒子三角
@mixin bg_corner($color: null) {
    @if $color!=null {
        border-color: $color;
    } @else {
        @include themeify {
            border-color: themed("bg_corner");
        }
    }
}