@charset "utf-8";
// 定义rating的基础构造
@mixin _rating {
display: inline-block;
position: relative;
width: map-get($rating, item-width) * 5;
height: map-get($rating, item-height);
overflow: hidden;
&,
> .index,
> .item {
background: url(#{map-get($setting, bgimg-domain)}#{map-get($rating, url)}) repeat-x;
background-size: auto 200%;
}
> .index,
> .item {
position: absolute;
top: 0;
left: 0;
height: 100%;
line-height: 10;
}
> .index {
background-position: 0 100%;
}
> .item {
z-index: 3;
width: 20%;
// 默认情况下不显示
background-position: 0 100px;
cursor: pointer;
&:nth-of-type(2) {
left: 20%;
&:hover {
width: 40%;
}
}
&:nth-of-type(3) {
left: 40%;
&:hover {
width: 60%;
}
}
&:nth-of-type(4) {
left: 60%;
&:hover {
width: 80%;
}
}
&:nth-of-type(5) {
left: 80%;
&:hover {
width: 100%;
}
}
&:hover {
z-index: 2;
left: 0 !important;
background-position: 0 100%;
}
}
&-readonly {
> .item {
&:hover {
background-position: 0 1rem !important;
}
}
}
}
/**
* @module widget
* @method yo-rating
* @version 1.2.0
* @description 构造yo-rating的自定义使用方法
* @demo http://doyoe.github.io/Yo/demo/widget/yo-rating.html
* @param {String} $name 定义扩展名称 <1.2.0>
* @param {Length} $item-width 单项宽度 <1.2.0>
* @param {Length} $item-height 单项高度 <1.2.0>
* @param {String} $url 星星图片url <1.3.1>
* @example 假设你需要只读状态,可以这样:
* ...
*/
@mixin yo-rating(
$name: default,
$item-width: default,
$item-height: default,
$url: default) {
// 区别是否新增实例还是修改本身
$name: if($name == default, "", "-#{$name}");
// 如果值为default,则取config的定义
@if $item-width == default {
$item-width: map-get($rating, item-width);
}
@if $item-height == default {
$item-height: map-get($rating, item-height);
}
@if $url == default {
$url: map-get($rating, url);
}
.yo-rating#{$name} {
@if $item-width != map-get($rating, item-width) {
width: $item-width * 5;
}
@if $item-height != map-get($rating, item-height) {
height: $item-height;
}
&,
> .index,
> .item {
@if $url != map-get($rating, url) {
background-image: url(#{map-get($setting, bgimg-domain)}#{$url});
}
}
// 增量扩展
@content;
}
}
// 调用本文件时载入rating基础构造
.yo-rating {
@include _rating;
}