@charset "utf-8";
@import "../core/variables";
@import "../core/classes";

// 定义score的基础构造
@mixin _score {
    position: relative;
    width: map-get($score, item-width) * 5;
    height: map-get($score, item-height);
    overflow: hidden;
    &,
    > .index {
        display: inline-block;
        background: url(#{map-get($setting, bgimg-domain)}#{map-get($score, url)}) repeat-x;
        @if map-get($score, item-height) != null {
            background-size: auto map-get($score, item-height) * 2;
        }
    }
    > .index {
        height: 100%;
        background-position: 0 -#{map-get($score, item-height)};
        line-height: 10;
        vertical-align: top;
    }
}

/**
 * @module element
 * @method yo-score
 * @description 构造评分展示的自定义使用方法
 * @demo http://doyoe.github.io/Yo/demo/element/yo-score.html
 * @param {String} $name 为新的扩展定义一个名称
 * @param {Length} $item-width 单项宽度
 * @param {Length} $item-height 单项高度
 * @param {String} $url 背景图片url
 */

@mixin yo-score(
    $name: default,
    $item-width: default,
    $item-height: default,
    $url: default) {
    // 区别是否新增实例还是修改本身
    @if $name == default {
        $name: "";
    } @else {
        $name: "-#{$name}";
    }
    // 如果值为default,则取config的定义
    @if $item-width == default {
        $item-width: map-get($score, item-width);
    }
    @if $item-height == default {
        $item-height: map-get($score, item-height);
    }
    @if $url == default {
        $url: map-get($score, url);
    }
    .yo-score#{$name} {
        @if $item-width != map-get($score, item-width) {
            width: $item-width * 5;
        }
        @if $item-height != map-get($score, item-height) {
            height: $item-height;
        }
        &,
        > .index {
            @if $url != map-get($score, url) {
                background-image: url(#{map-get($setting, bgimg-domain)}#{$url});
            }
            @if $item-height != map-get($score, item-height) {
                background-size: auto $item-height * 2;
            }
        }
        > .index {
            @if $item-height != map-get($score, item-height) {
                background-position: 0 -#{$item-height};
            }
        }
        // 增量扩展
        @content;
    }
}

// 调用本文件时载入score基础构造
.yo-score {
    @include _score;
}