//
// Copyright IBM Corp. 2016, 2018
//
// This source code is licensed under the Apache-2.0 license found in the
// LICENSE file in the root directory of this source tree.
//

@use "./keyframes";
@use "../../config" as *;
@use "../../spacing" as *;
@use "../../theme" as *;
@use "../../type" as *;
@use "../../utilities/convert" as *;

/// inline-loading style
/// @access private
/// @group inline-loading

/// Inline loading styles
/// @access public
/// @group inline-loading
@mixin inline-loading {
  .#{$prefix}--inline-loading {
    display: flex;
    //width: 100%;
    align-items: center;
  }

  .#{$prefix}--inline-loading__text {
    @include type-style("body-short");
  }

  .#{$prefix}--inline-loading__animation {
    position: relative;
    width: 2rem;
    height: 2rem;
    display: flex;
    justify-content: center;
    align-items: center;
  }

  .#{$prefix}--inline-loading__checkmark-container {
    width: 0.75rem;
    position: absolute;
    top: 0.75rem;

    &[hidden] {
      display: none;
    }
  }

  .#{$prefix}--inline-loading__checkmark {
    fill: none;
    stroke: $action-default-fill-primary-default;
    transform-origin: 50% 50%;
    stroke-width: 2.1;
    stroke-dasharray: 12;
    stroke-dashoffset: 12;
    animation-name: stroke;
    animation-duration: 0.25s;
    animation-fill-mode: forwards;
  }

  .#{$prefix}--loading--small .#{$prefix}--inline-loading__svg {
    stroke: $action-default-fill-primary-default;
  }
  /* If IE11 Don't show check animation */
  @media screen and (-ms-high-contrast: active),
    screen and (-ms-high-contrast: none) {
    .#{$prefix}--inline-loading__checkmark-container {
      top: 1px;
      right: 0.5rem;
    }

    .#{$prefix}--inline-loading__checkmark {
      animation: none;
      stroke-dashoffset: 0;
      stroke-dasharray: 0;
    }
  }
}

@mixin inline-loading--x {
  .#{$prefix}--inline-loading {
    display: flex;
    width: 100%;
    align-items: center;

    .#{$prefix}--loading__svg circle {
      stroke-width: 10;
    }

    .#{$prefix}--loading__stroke {
      stroke-dashoffset: 75;
    }
  }

  .#{$prefix}--inline-loading__text {
    @include type-style("body-short");
    color: $text-body-secondary;
  }

  .#{$prefix}--inline-loading__animation {
    position: relative;
    width: 2rem;
    height: 2rem;
    display: flex;
    justify-content: center;
    align-items: center;
  }

  .#{$prefix}--inline-loading__checkmark-container {
    width: 0.75rem;
    position: absolute;
    top: 0.75rem;

    &[hidden] {
      display: none;
    }
  }

  .#{$prefix}--inline-loading__checkmark {
    fill: none;
    stroke: $action-default-fill-primary-default;
    transform-origin: 50% 50%;
    stroke-width: 2.1;
    stroke-dasharray: 12;
    stroke-dashoffset: 12;
    animation-name: stroke;
    animation-duration: 0.25s;
    animation-fill-mode: forwards;
  }

  .#{$prefix}--loading--small .#{$prefix}--inline-loading__svg {
    stroke: $action-default-fill-primary-default;
  }
  /* If IE11 Don't show check animation */
  @media screen and (-ms-high-contrast: active),
    screen and (-ms-high-contrast: none) {
    .#{$prefix}--inline-loading__checkmark-container {
      top: 1px;
      right: 0.5rem;
    }

    .#{$prefix}--inline-loading__checkmark {
      animation: none;
      stroke-dashoffset: 0;
      stroke-dasharray: 0;
    }
  }
}

// @include exports('inline-loading') {
//   @if feature-flag-enabled('components-x') {
//     @include inline-loading--x;
//   } @else {
//     @include inline-loading;
//   }
// }
