// @import './variables.scss';

// Toasts
@mixin toast-icon($icon) {
  display: inline-block;
  flex-grow: 0;
  flex-shrink: 0;
  width: 1.3em;
  height: 1.3em;
  margin-right: 8px;
  background-image: $icon;
  background-position: center;
  background-repeat: no-repeat;
}

.#{$namespace}toast-box {
  position: fixed;
  .#{$namespace}toast-enter-active, .#{$namespace}toast-leave {
    opacity: 1;
  }
  .#{$namespace}toast-enter, .#{$namespace}toast-leave-active {
    opacity: 0;
  }
  &.#{$namespace}toast-box-top-left {
    top: 12px;
    left: 24px;
    .#{$namespace}toast-enter-active, .#{$namespace}toast-leave {
      transform: translate(0);
    }
    .#{$namespace}toast-enter, .#{$namespace}toast-leave-active {
      transform: translate(-100%);
    }    
  }
  &.#{$namespace}toast-box-top-right  {
    top: 12px;
    right: 24px;
    .#{$namespace}toast-enter-active, .#{$namespace}toast-leave {
      transform: translate(0);
    }
    .#{$namespace}toast-enter, .#{$namespace}toast-leave-active {
      transform: translate(100%);
    }
  }
  &.#{$namespace}toast-box-bottom-left {
    bottom: 12px;
    left: 24px;

    .#{$namespace}toast-enter-active, .#{$namespace}toast-leave {
      transform: translate(0);
    }
    .#{$namespace}toast-enter, .#{$namespace}toast-leave-active {
      transform: translate(-100%);
    }
  }
  &.#{$namespace}toast-box-bottom-right {
    bottom: 12px;
    right: 24px;
    .#{$namespace}toast-enter-active, .#{$namespace}toast-leave {
      transform: translate(0);
    }
    .#{$namespace}toast-enter, .#{$namespace}toast-leave-active {
      transform: translate(100%);
    }
  }
  &.#{$namespace}toast-box-top-center {
    top: 12px;
    left: 50%;
    transform: translate(-50%);
    .#{$namespace}toast-enter-active, .#{$namespace}toast-leave {
      transform: translate(0);
    }
    .#{$namespace}toast-enter, .#{$namespace}toast-leave-active {
      transform: translate(0,-100%);
    }
  }
  &.#{$namespace}toast-box-bottom-center {
    bottom: 12px;
    left: 50%;
    transform: translate(-50%);
    .#{$namespace}toast-enter-active, .#{$namespace}toast-leave {
      transform: translate(0);
    }
    .#{$namespace}toast-enter, .#{$namespace}toast-leave-active {
      transform: translate(0,100%);
    }
  }

  .#{$namespace}toast {
    margin: 17px 0;
    padding: $toast-padding; // padding: 0 0 0 20px;
    width: 240px;
    min-height: 48px;
    display: flex;
    align-items: center;
    transition: transform .4s, opacity .3s;
    background-color: #fff;
    font-size: $toast-font-size;
    color: $toast-color;
    line-height: 20px;
    box-shadow: 0 4px 8px 0 rgba(130,125,124,0.20);
    border-radius: $toast-border-radius;
  
    .#{$namespace}toast-content {
      flex: 1;
      display: flex;
      align-items: center;
      word-wrap:break-word;//单词太长，先换行，换行后还是太长，单词内可以换行
      word-break:break-all;//放不下的时候再单词的内部换行

      .#{$namespace}toast-content-icon-success {
        @include toast-icon($toast-icon-success);
      }
      .#{$namespace}toast-content-icon-info {
        @include toast-icon($toast-icon-info);
      }
      .#{$namespace}toast-content-icon-error {
        @include toast-icon($toast-icon-danger);
      }
      .#{$namespace}toast-content-icon-warning {
        @include toast-icon($toast-icon-warning);
      }
    }
  
    .#{$namespace}toast-action {
      flex-grow: 0;
      color: $toast-action-color;
      cursor: pointer;
      svg {
        width: 1em;
        height: 1em;
        color: $toast-action-svg-color;
      }
    }
  
    &.#{$namespace}toast-primary {
      background-color: $toast-primary-background-color;
      color: $toast-primary-color;
      box-shadow: $toast-primary-box-shadow;
  
      .#{$namespace}toast-action {
        color: #fff;
  
        svg {
          color: #fff;
        }
      }
    }
  }
}
