@charset "utf-8";
@import "yo-group";

// 定义calendar的基础构造
@mixin _calendar {
    @include fullscreen;
    @include flexbox;
    @include flex-direction(column);
    background-color: #fff;
    text-align: center;
    // 星期一,二...条(bar)
    > .week-bar {
        height: map-get($calendar, week-bar-height);
        line-height: map-get($calendar, week-bar-height);
        background-color: map-get($calendar, week-bar-bgcolor);
        color: map-get($calendar, week-bar-color);
        font-size: map-get($calendar, week-bar-font-size);
    }
    > .week-bar,
    .week {
        @include flexbox;
        width: 100%;
        > li {
            @include flex;
        }
    }
    > .yo-group {
        position: relative;
        @include flex(1, column);
    }
    @include yo-list(
        $item-padding: 0,
        $item-border-space: 0
    ) {
        > .label {
            display: block;
        }
    }
    // 每周
    .week {
        height: map-get($calendar, week-height);
        color: map-get($calendar, week-color);
    }
    .day,
    .special {
        pointer-events: none;
        margin: map-get($calendar, day-margin);
        font-size: map-get($calendar, day-font-size);
        line-height: map-get($calendar, day-height);
    }
    // 每个单日
    .day {
        display: inline-block;
        @include square(map-get($calendar, day-height));
        @include border-radius(map-get($calendar, day-radius));
        vertical-align: top;
    }
    // 每个特殊的单日
    .special {
        display: block;
        color: map-get($calendar, special-color);
        // 今天是特殊日子的场景
        ~ .special {
            margin: -.05rem 0 0;
        }
    }
    .today,
    .holiday {
        > .day {
            display: none;
        }
    }
    // 周末
    .weekend {
        color: map-get($calendar, weekend-color);
    }
    // 不可选的日子
    .disabled {
        &,
        > .special {
            color: map-get($calendar, disabled-color) !important;
        }
    }
    // 起始和结束日定义
    .start,
    .end,
    .start-end {
        > .day {
            display: inline-block;
            background-color: map-get($calendar, on-bgcolor);
            color: map-get($calendar, on-color);
        }
        > .special {
            display: none;
        }
        > .tip {
            display: block;
            color: map-get($calendar, on-tip-color);
            font-size: map-get($calendar, on-tip-font-size);
        }
    }
    // 选中日期段背景
    .range {
        background-color: map-get($calendar, range-bgcolor);
    }
}

/**
 * @module fragment
 * @method yo-calendar
 * @version 3.0.0
 * @description 构造yo-calendar的自定义使用方法
 * @demo http://ued.qunar.com/hy2/yo/demo/src/html/fragment/yo-calendar.html
 * @param {String} $name 定义扩展名称 <3.0.0>
 * @param {Length} $week-bar-height 定义星期bar高度 <3.0.0>
 * @param {Color} $week-bar-bgcolor 定义星期bar背景色 <3.0.0>
 * @param {Color} $week-bar-color 定义星期bar文本色 <3.0.0>
 * @param {Length} $week-bar-font-size 定义星期bar字号 <3.0.0>
 * @param {Length} $week-height 定义每行高度 <3.0.0>
 * @param {Color} $week-color 定义每行文本色 <3.0.0>
 * @param {Length} $day-height 定义每日高度 <3.0.0>
 * @param {Length} $day-margin 定义每日间距 <3.0.0>
 * @param {Length} $day-radius 定义每日圆角 <3.0.0>
 * @param {Length} $day-font-size 定义每日字号 <3.0.0>
 * @param {Color} $special-color 定义特殊日文本色 <3.0.0>
 * @param {Color} $weekend-color 定义周末文本色 <3.0.0>
 * @param {Color} $disabled-color 定义禁用日子文本色 <3.0.0>
 * @param {Color} $on-bgcolor 定义选中日期背景色 <3.0.0>
 * @param {Color} $on-color 定义选中日期文本色 <3.0.0>
 * @param {Color} $on-tip-color 定义选中日期提示语文本色 <3.0.0>
 * @param {Length} $on-tip-font-size 定义选中日期提示语字号 <3.0.0>
 * @param {Color} $range-bgcolor 选中日期段背景 <3.0.0>
 */

@mixin yo-calendar(
    $name: default,
    $week-bar-height: default,
    $week-bar-bgcolor: default,
    $week-bar-color: default,
    $week-bar-font-size: default,
    $week-height: default,
    $week-color: default,
    $day-height: default,
    $day-margin: default,
    $day-radius: default,
    $day-font-size: default,
    $special-color: default,
    $weekend-color: default,
    $disabled-color: default,
    $on-bgcolor: default,
    $on-color: default,
    $on-tip-color: default,
    $on-tip-font-size: default,
    $range-bgcolor: default) {
    // 区别是否新增实例还是修改本身
    $name: if($name == default, "", "-#{$name}");
    // 如果值为default,则取config的定义
    @if $week-bar-height == default {
        $week-bar-height: map-get($calendar, week-bar-height);
    }
    @if $week-bar-bgcolor == default {
        $week-bar-bgcolor: map-get($calendar, week-bar-bgcolor);
    }
    @if $week-bar-color == default {
        $week-bar-color: map-get($calendar, week-bar-color);
    }
    @if $week-bar-font-size == default {
        $week-bar-font-size: map-get($calendar, week-bar-font-size);
    }
    @if $week-height == default {
        $week-height: map-get($calendar, week-height);
    }
    @if $week-color == default {
        $week-color: map-get($calendar, week-color);
    }
    @if $day-height == default {
        $day-height: map-get($calendar, day-height);
    }
    @if $day-margin == default {
        $day-margin: map-get($calendar, day-margin);
    }
    @if $day-radius == default {
        $day-radius: map-get($calendar, day-radius);
    }
    @if $day-font-size == default {
        $day-font-size: map-get($calendar, day-font-size);
    }
    @if $special-color == default {
        $special-color: map-get($calendar, special-color);
    }
    @if $weekend-color == default {
        $weekend-color: map-get($calendar, weekend-color);
    }
    @if $disabled-color == default {
        $disabled-color: map-get($calendar, disabled-color);
    }
    @if $on-bgcolor == default {
        $on-bgcolor: map-get($calendar, on-bgcolor);
    }
    @if $on-color == default {
        $on-color: map-get($calendar, on-color);
    }
    @if $on-tip-color == default {
        $on-tip-color: map-get($calendar, on-tip-color);
    }
    @if $on-tip-font-size == default {
        $on-tip-font-size: map-get($calendar, on-tip-font-size);
    }
    @if $range-bgcolor == default {
        $range-bgcolor: map-get($calendar, range-bgcolor);
    }
    .yo-calendar#{$name} {
        // 星期一,二...条(bar)
        > .week-bar {
            @if $week-bar-height != map-get($calendar, week-bar-height) {
                height: $week-bar-height;
                line-height: $week-bar-height;
            }
            @if $week-bar-bgcolor != map-get($calendar, week-bar-bgcolor) {
                background-color: $week-bar-bgcolor;
            }
            @if $week-bar-color != map-get($calendar, week-bar-color) {
                color: $week-bar-color;
            }
            @if $week-bar-font-size != map-get($calendar, week-bar-font-size) {
                font-size: $week-bar-font-size;
            }
        }
        // 每周
        .week {
            @if $week-height != map-get($calendar, week-height) {
                height: $week-height;
            }
            @if $week-color != map-get($calendar, week-color) {
                color: $week-color;
            }
        }
        .day,
        .special {
            @if $day-margin != map-get($calendar, day-margin) {
                margin: $day-margin;
            }
            @if $day-font-size != map-get($calendar, day-font-size) {
                font-size: $day-font-size;
            }
            @if $day-height != map-get($calendar, day-height) {
                line-height: $day-height;
            }
        }
        // 每个单日
        .day {
            @if $day-height != map-get($calendar, day-height) {
                @include square($day-height);
            }
            @if $day-radius != map-get($calendar, day-radius) {
                border-radius: $day-radius;
            }
        }
        // 每个特殊的单日
        .special {
            @if $special-color != map-get($calendar, special-color) {
                color: $special-color;
            }
        }
        // 周末
        .weekend {
            @if $weekend-color != map-get($calendar, weekend-color) {
                color: $weekend-color;
            }
        }
        // 不可选的日子
        .disabled {
            &,
            > .special {
                @if $disabled-color != map-get($calendar, disabled-color) {
                    color: $disabled-color !important;
                }
            }
        }
        // 起始和结束日定义
        .start,
        .end,
        .start-end {
            > .day {
                @if $on-bgcolor != map-get($calendar, on-bgcolor) {
                    background-color: $on-bgcolor;
                }
                @if $on-color != map-get($calendar, on-color) {
                    color: $on-color;
                }
            }
            > .tip {
                @if $on-tip-color != map-get($calendar, on-tip-color) {
                    color: $on-tip-color;
                }
                @if $on-tip-font-size != map-get($calendar, on-tip-font-size) {
                    font-size: $on-tip-font-size;
                }
            }
        }
        .range {
            @if $range-bgcolor != map-get($calendar, range-bgcolor) {
                background-color: $range-bgcolor;
            }
        }

        // 增量扩展
        @content;
    }
}

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