@use "sass:string";
@use "../../variables/index" as *;
@use "../mixins/vendor-prefixes";

/**
 * Component Animations - Fade, collapse, and pulse animations
 *
 * Note: Uses color tokens for background colors.
 *
 * Intentionally hardcoded values:
 * - Animation/transition durations (0.15s, 0.35s, 1s): Animation timing
 * - Percentages in keyframes: Animation keyframe positions
 */

// We don't use the `.opacity()` mixin here since it causes a bug with text
// fields in IE7-8. Source: https://github.com/twbs/bootstrap/pull/3552.
.fade {
  opacity: 0;
  @include vendor-prefixes.transition(opacity 0.15s linear);
  &.in,
  &.show {
    opacity: 1;
  }
}

.collapse {
  display: none;
  &.in {
    display: block;
  }
  tr &.in {
    display: table-row;
  }
  tbody &.in {
    display: table-row-group;
  }
}

.collapsing {
  position: relative;
  overflow: hidden;
  width: 100%;
  height: 0;

  transition-property: height, visibility;
  transition-duration: 0.35s;
  transition-timing-function: ease;
}

@mixin component-pulse() {
  animation-name: pulseComponent;
  animation-duration: 1s;
}

.component-pulse {
  @include component-pulse();
}

@keyframes pulseComponent {
  0%,
  20%,
  50% {
    background-color: $component-realtime-added;
  }

  35%,
  100% {
    background-color: $component-background-default;
  }
}
