@charset "utf-8";

// 定义swipemenu的基础构造
@mixin _swipemenu {
    &,
    > .item {
        position: relative;
        // 当yo-swipemenu被应用到yo-list里时，需要重置yo-list item的flex定义
        display: block !important;
        // 清除.item的内补白，交由yo-swipemenu的子项来处理
        padding: 0 !important;
    }
    .front {
        position: relative;
        z-index: 2;
        width: map-get($swipemenu, padding);
        background-color: #fff;
    }
    .transition {
        @include transition(transform .3s);
    }
    .action {
        @include flexbox;
        position: absolute;
        top: 0;
        right: 0;
        bottom: 0;
        overflow: hidden;
        width: map-get($swipemenu, action-width);
        background-color: map-get($swipemenu, action-bgcolor);
        color: map-get($swipemenu, action-color);
        &-start {
            right: auto;
            left: 0;
        }
        > .item {
            @include flex;
            @include align;
            &:first-child {
                background-color: map-get($swipemenu, action-first-bgcolor);
            }
        }
    }
}

/**
 * @module fragment
 * @method yo-swipemenu
 * @version 3.0.0
 * @description 构造yo-swipemenu的自定义使用方法
 * @demo http://ued.qunar.com/hy2/yo/demo/src/html/fragment/yo-swipemenu.html
 * @param {String} $name 定义扩展名称 <3.0.0>
 * @param {Length} $padding front区域内补白 <3.0.0>
 * @param {Length} $action-width action操作区宽度 <3.0.0>
 * @param {Color} $action-bgcolor action操作区背景色 <3.0.0>
 * @param {Color} $action-color action操作区文本色 <3.0.0>
 * @param {Color} $action-first-bgcolor action操作区第一个子项的背景色 <3.0.0>
 */

@mixin yo-swipemenu(
    $name: default,
    $padding: default,
    $action-width: default,
    $action-bgcolor: default,
    $action-color: default,
    $action-first-bgcolor: default) {
    // 区别是否新增实例还是修改本身
    $name: if($name == default, "", "-#{$name}");
    // 如果值为default，则取config的定义
    @if $padding == default {
        $padding: map-get($swipemenu, padding);
    }
    @if $action-width == default {
        $action-width: map-get($swipemenu, action-width);
    }
    @if $action-bgcolor == default {
        $action-bgcolor: map-get($swipemenu, action-bgcolor);
    }
    @if $action-color == default {
        $action-color: map-get($swipemenu, action-color);
    }
    @if $action-first-bgcolor == default {
        $action-first-bgcolor: map-get($swipemenu, action-first-bgcolor);
    }
    .yo-swipemenu#{$name} {
        .front {
            @if $padding != map-get($swipemenu, padding) {
                padding: $padding;
            }
        }
        > .action {
            @if $action-width != map-get($swipemenu, action-width) {
                width: $action-width;
            }
            @if $action-bgcolor != map-get($swipemenu, action-bgcolor) {
                background-color: $action-bgcolor;
            }
            @if $action-color != map-get($swipemenu, action-color) {
                color: $action-color;
            }
            > .item {
                &:first-child {
                    @if $action-first-bgcolor != map-get($swipemenu, action-first-bgcolor) {
                        background-color: $action-first-bgcolor;
                    }
                }
            }
        }
        // 增量扩展
        @content;
    }
}

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