/* 辅助函数
--------------------------------------------------------------------- */
//遍历主题map
@mixin map-themes {
  @each $theme-name, $theme-map in $themes {
    //!global 把局部变量强升为全局变量
    $theme-map: $theme-map !global;
    //#{}是sass的插值表达式
    //& sass嵌套里的父容器标识  @content是混合器插槽
    .#{$theme-name} & {
      @content;
    }
  }
}

// $_seed: 1 !default;
@function theme-content($key) {
  // $_seed: $_seed + 1 !global;
  // @debug "map length: #{$_seed}";
  @return map-get($theme-map, $key);
}
/* end
--------------------------------------------------------------------- */

/* 抽离出样式的委托函数
--------------------------------------------------------------------- */
//背景颜色
@mixin theme-background-color($category, $isImportant: $--not-important) {
  @include map-themes {
    @if $isImportant == $--important {
      background-color: theme-content($category) !important;
    } @else {
      background-color: theme-content($category)
    }
  }
}

// 背景（全）
@mixin theme-background($category, $isImportant: $--not-important) {
  @include map-themes {
    @if $isImportant == $--important {
      background: theme-content($category) !important;
    } @else {
      background: theme-content($category)
    }
  }
}

//字体颜色、icon颜色
@mixin theme-color($category, $isImportant: $--not-important) {
  @include map-themes {
    @if $isImportant == $--important {
      color: theme-content($category) !important;
    } @else {
      color: theme-content($category);
    }
  }
}

//字体颜色
@mixin theme-font-color($category, $isImportant: $--not-important) {
  @include map-themes {
    @if $isImportant == $--important {
      color: theme-content($category) !important;
    } @else {
      color: theme-content($category);
    }
  }
}

//边框（全）
@mixin theme-border($category, $isImportant: $--not-important) {
  @include map-themes {
    @if $isImportant == $--important {
      border: theme-content($category) !important;
    } @else {
      border: theme-content($category);
    }
  }
}

//左边框（全）
@mixin theme-border-left($category, $isImportant: $--not-important) {
  @include map-themes {
    @if $isImportant == $--important {
      border-left: theme-content($category) !important;
    } @else {
      border-left: theme-content($category);
    }
  }
}

//右边框（全）
@mixin theme-border-right($category, $isImportant: $--not-important) {
  @include map-themes {
    @if $isImportant == $--important {
      border-right: theme-content($category) !important;
    } @else {
      border-right: theme-content($category);
    }
  }
}

//上边框（全）
@mixin theme-border-top($category, $isImportant: $--not-important) {
  @include map-themes {
    @if $isImportant == $--important {
      border-top: theme-content($category) !important;
    } @else {
      border-top: theme-content($category);
    }
  }
}

//下边框（全）
@mixin theme-border-bottom($category, $isImportant: $--not-important) {
  @include map-themes {
    @if $isImportant == $--important {
      border-bottom: theme-content($category) !important;
    } @else {
      border-bottom: theme-content($category);
    }
  }
}

//边框颜色（全）
@mixin theme-border-color($category, $isImportant: $--not-important) {
  @include map-themes {
    @if $isImportant == $--important {
      border-color: theme-content($category) !important;
    } @else {
      border-color: theme-content($category);
    }
  }
}

//左边框颜色
@mixin theme-border-left-color($category, $isImportant: $--not-important) {
  @include map-themes {
    @if $isImportant == $--important {
      border-left-color: theme-content($category) !important;
    } @else {
      border-left-color: theme-content($category);
    }
  }
}

//右边框颜色
@mixin theme-border-right-color($category, $isImportant: $--not-important) {
  @include map-themes {
    @if $isImportant == $--important {
      border-right-color: theme-content($category) !important;
    } @else {
      border-right-color: theme-content($category);
    }
  }
}

//上边框颜色
@mixin theme-border-top-color($category, $isImportant: $--not-important) {
  @include map-themes {
    @if $isImportant == $--important {
      border-top-color: theme-content($category) !important;
    } @else {
      border-top-color: theme-content($category);
    }
  }
}

//下边框颜色
@mixin theme-border-bottom-color($category, $isImportant: $--not-important) {
  @include map-themes {
    @if $isImportant == $--important {
      border-bottom-color: theme-content($category) !important;
    } @else {
      border-bottom-color: theme-content($category);
    }
  }
}

//box-shadow
@mixin theme-box-shadow($category, $isImportant: $--not-important) {
  @include map-themes {
    @if $isImportant == $--important {
      box-shadow: theme-content($category) !important;
    } @else {
      box-shadow: theme-content($category);
    }
  }
}

//透明度
//opacity
@mixin theme-opacity($category, $isImportant: $--not-important) {
  @include map-themes {
    @if $isImportant == $--important {
      opacity: theme-content($category) !important;
    } @else {
      opacity: theme-content($category);
    }
  }
}

//圆角
//border-radius
@mixin theme-border-radius($category, $isImportant: $--not-important) {
  @include map-themes {
    @if $isImportant == $--important {
      border-radius: theme-content($category) !important;
    } @else {
      border-radius: theme-content($category);
    }
  }
}

//宽度 width
@mixin theme-max-width($category, $isImportant: $--not-important) {
  @include map-themes {
    @if $isImportant == $--important {
      max-width: theme-content($category) !important;
    } @else {
      max-width: theme-content($category);
    }
  }
}

//高度 height
@mixin theme-max-height($category, $isImportant: $--not-important) {
  @include map-themes {
    @if $isImportant == $--important {
      max-height: theme-content($category) !important;
    } @else {
      max-height: theme-content($category);
    }
  }
}

//IE浏览器 滚动条样式

//滚动条滑块
//scrollbar-face-color 
@mixin theme-scrollbar-face-color($category, $isImportant: $--not-important) {
  @include map-themes {
    @if $isImportant == $--important {
      scrollbar-face-color: theme-content($category) !important;
    } @else {
      scrollbar-face-color: theme-content($category);
    }
  }
}

//滚动条轨迹部分颜色
//scrollbar-track-color 
@mixin theme-scrollbar-track-color($category, $isImportant: $--not-important) {
  @include map-themes {
    @if $isImportant == $--important {
      scrollbar-track-color: theme-content($category) !important;
    } @else {
      scrollbar-track-color: theme-content($category);
    }
  }
}

//滚动条箭头颜色
//scrollbar-arrow-color 
@mixin theme-scrollbar-arrow-color($category, $isImportant: $--not-important) {
  @include map-themes {
    @if $isImportant == $--important {
      scrollbar-arrow-color: theme-content($category) !important;
    } @else {
      scrollbar-arrow-color: theme-content($category);
    }
  }
}

//滚动条滑块阴影颜色
//scrollbar-shadow-color 
@mixin theme-scrollbar-shadow-color($category, $isImportant: $--not-important) {
  @include map-themes {
    @if $isImportant == $--important {
      scrollbar-shadow-color: theme-content($category) !important;
    } @else {
      scrollbar-shadow-color: theme-content($category);
    }
  }
}
