@mixin animate-end($name) {
  animation-timing-function: $ease-out;
  animation-fill-mode: both;
  animation-name: $name;
}

@mixin snackbar-color($base-color) {
  border-color: $base-color;
  background-color: tint($base-color, 90%);
  .#{$snackbar-prefix}-item-icon {
    color: $base-color;
  }
}

$snackbar-prefix: #{$prefix}-snackbar;
@mixin ne-snackbar {
  .#{$snackbar-prefix} {
    position: fixed;
    top: auto;
    right: auto;
    bottom: auto;
    left: auto;
    pointer-events: none;

    > div {
      display: flex;
    }

    &-position-top,
    &-position-topLeft,
    &-position-topRight {
      top: $snackbar-distance;
      > div {
        flex-direction: column;
      }
    }

    &-position-bottom,
    &-position-bottomLeft,
    &-position-bottomRight {
      bottom: $snackbar-distance;
      > div {
        flex-direction: column-reverse;
      }
    }

    &-position-top,
    &-position-bottom {
      right: $snackbar-distance;
      left: $snackbar-distance;
      > div {
        align-items: center;
      }
    }

    &-position-topLeft,
    &-position-bottomLeft {
      left: $snackbar-distance;
      > div {
        align-items: flex-start;
      }
    }

    &-position-topRight,
    &-position-bottomRight {
      right: $snackbar-distance;
      > div {
        align-items: flex-end;
      }
    }
    [class*='-enter-active'] ~ [class*='-exit-'] {
      animation-delay: $animation-duration-slower;
    }
  }

  .#{$snackbar-prefix}-item {
    display: inline-block;
    position: relative;
    overflow: hidden;
    min-width: $snackbar-min-width;
    max-width: $snackbar-max-width;
    max-height: $snackbar-max-height;
    margin-bottom: $snackbar-gutter;
    padding: $snackbar-padding;
    border: $global-border-width solid transparent;
    border-radius: $global-radius;
    box-shadow: $global-shadow;
    color: $component-default-color;
    text-align: left;
    pointer-events: all;

    &-color-primary {
      border-color: $snackbar-primary-bg;
      background-color: $snackbar-primary-bg;
      color: $white;
      .#{$snackbar-prefix}-item-title {
        color: $white;
      }
    }

    &-color-error {
      @include snackbar-color($error-color);
    }

    &-color-info {
      @include snackbar-color($info-color);
    }
    &-color-warning {
      @include snackbar-color($warning-color);
    }
    &-color-success {
      @include snackbar-color($success-color);
    }

    &-body {
      display: flex;
      flex-wrap: wrap;
      align-items: center;
      margin-right: 12px;
      animation: $animation-duration-slow body-fade-in;
      animation-fill-mode: both;
    }
    &-icon {
      margin-right: $icon-gutter;
      font-size: $snackbar-title-size;
      vertical-align: middle;
    }
    &-content-container {
      display: flex;
      position: relative;
      flex: 1 1 auto;
      &-full-width {
        width: 100%;
      }
    }
    &-wrapper {
    }
    &-title {
      margin-top: 0;
      margin-bottom: 6px;
      color: $global-font-color;
      font-size: $snackbar-title-size;
    }
    &-actions {
      margin-left: auto;
    }
    &-close.#{$prefix}-button.#{$prefix}-icon-button {
      position: absolute;
      top: get-side($snackbar-padding, top);
      right: get-side($snackbar-padding, top);
      overflow: hidden;
      padding: 0;
    }
  }

  // 新增元素动画
  @each $name, $value,
    $listFrom
      in (
        down: translate(0, -100%),
        left: translate(100%, 0),
        right: translate(-100%, 0),
        up: translate(0, 100%)
      )
  {
    @if ($name == 'down' or $name == 'up') {
      .#{$snackbar-prefix}-slide-#{$name}-enter {
        animation-duration: $animation-duration-slow;
        &.#{$snackbar-prefix}-slide-#{$name}-enter-active {
          @include animate-end(slide-in-#{$name});
        }
      }
      .#{$snackbar-prefix}-slide-#{$name}-exit {
        animation-duration: $animation-duration-slow;
        &.#{$snackbar-prefix}-slide-#{$name}-exit-active {
          @include animate-end(slide-out-vertical);
        }
      }
    } @else {
      .#{$snackbar-prefix}-slide-#{$name}-enter {
        animation-duration: $animation-duration-slow;
        &.#{$snackbar-prefix}-slide-#{$name}-enter-active {
          @include animate-end(slide-out-#{$name});
          animation-direction: reverse;
        }
      }
      .#{$snackbar-prefix}-slide-#{$name}-exit {
        animation-duration: $animation-duration-slower;
        &.#{$snackbar-prefix}-slide-#{$name}-exit-active {
          @include animate-end(slide-out-#{$name});
        }
      }
    }
    @keyframes slide-in-#{$name} {
      0% {
        max-height: 0;
        margin: 0;
        padding: 0 get-side($snackbar-padding, left);
        border-width: 0;
        opacity: 0;
        transform: $value;
      }
      100% {
        max-height: $snackbar-max-height;
        margin-bottom: $snackbar-gutter;
        padding: $snackbar-padding;
        border-width: $global-border-width;
        opacity: 1;
        transform: translate(0, 0);
      }
    }
    @keyframes slide-out-#{$name} {
      0% {
        // max-height: $snackbar-max-height;
        max-height: $snackbar-max-height;
        margin-bottom: $snackbar-gutter;
        padding: $snackbar-padding;
        border-width: $global-border-width;
        opacity: 1;
        transform: translate(0, 0);
      }
      50% {
        max-height: $snackbar-max-height;
        margin-bottom: $snackbar-gutter;
        padding: $snackbar-padding;
        border-width: $global-border-width;
        opacity: 0;
        transform: $value;
      }
      100% {
        max-height: 0;
        margin: 0;
        padding: 0;
        border-width: 0;
        opacity: 0;
        transform: $value;
      }
    }
  }

  @keyframes slide-out-vertical {
    0% {
      opacity: 1;
    }
    100% {
      max-height: 0;
      margin: 0;
      padding-top: 0;
      padding-bottom: 0;
      opacity: 0;
    }
  }

  @keyframes body-fade-in {
    0% {
      opacity: 0;
    }
    100% {
      opacity: 1;
    }
  }
}
