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

@import '../../global/styles/project-settings';

@import 'carbon-components/scss/components/button/button';
@import 'carbon-components/scss/components/inline-loading/inline-loading';

// Define all component styles in a mixin which is then exported using
// the Carbon import-once mechanism.
@mixin action-set {
  // The block part of our conventional BEM class names (blockClass__E--M).
  $block-class: #{$pkg-prefix}--action-set;

  .#{$block-class} {
    align-items: stretch;
    justify-content: flex-end;
    background-color: $ui-01;
  }

  .#{$block-class} .#{$block-class}__action-button {
    @include carbon--type-style('body-short-01');

    align-items: center;
    margin: 0;

    &.#{$block-class}__action-button--expressive {
      height: $spacing-10;
      padding-top: $spacing-05;
      padding-bottom: $spacing-07;
    }
  }

  .#{$block-class}.#{$carbon-prefix}--btn-set
    .#{$block-class}__action-button.#{$carbon-prefix}--btn.#{$carbon-prefix}--btn--expressive,
  .#{$block-class}.#{$carbon-prefix}--btn-set
    .#{$block-class}__action-button.#{$carbon-prefix}--btn {
    max-width: none;
  }

  .#{$block-class}:not(.#{$block-class}--stacking)
    .#{$block-class}__action-button--ghost {
    padding-left: $spacing-07;
  }

  // For row-single in medium,
  // or for ghosts in row-single,
  // buttons are 100% width
  .#{$block-class}.#{$block-class}--row-single.#{$block-class}--md
    .#{$block-class}__action-button,
  .#{$block-class}.#{$block-class}--row-single
    .#{$block-class}__action-button--ghost {
    flex: 0 0 100%;
  }

  // For ghosts in row-double,
  // buttons are 75% width and expand to use any remaining space
  .#{$block-class}.#{$block-class}--row-double
    .#{$block-class}__action-button--ghost {
    flex: 1 1 75%;
  }

  // For row-single in large (non-ghost),
  // or row-double in medium or large,
  // buttons are 50% width
  .#{$block-class}.#{$block-class}--row-single.#{$block-class}--lg
    .#{$block-class}__action-button:not(.#{$block-class}__action-button--ghost),
  .#{$block-class}.#{$block-class}--row-double.#{$block-class}--md
    .#{$block-class}__action-button,
  .#{$block-class}.#{$block-class}--row-double.#{$block-class}--lg
    .#{$block-class}__action-button,
  .#{$block-class}.#{$block-class}--row-triple
    .#{$block-class}__action-button--ghost {
    flex: 0 1 50%;
  }

  // For ghosts in row-triple,
  // buttons are 50% width and expand to use any remaining space
  .#{$block-class}.#{$block-class}--row-triple
    .#{$block-class}__action-button--ghost {
    flex: 1 1 50%;
  }

  // For row-triple in large (non-ghost),
  // or any non-ghosts in extra large or max,
  // or row-quadruple (non-ghost),
  // buttons are 25% width with a max of 232px
  .#{$block-class}.#{$carbon-prefix}--btn-set.#{$block-class}--row-triple.#{$block-class}--lg
    .#{$block-class}__action-button:not(.#{$block-class}__action-button--ghost),
  .#{$block-class}.#{$carbon-prefix}--btn-set.#{$block-class}--xlg
    .#{$block-class}__action-button:not(.#{$block-class}__action-button--ghost),
  .#{$block-class}.#{$carbon-prefix}--btn-set.#{$block-class}--max
    .#{$block-class}__action-button:not(.#{$block-class}__action-button--ghost),
  .#{$block-class}.#{$carbon-prefix}--btn-set.#{$block-class}--row-quadruple
    .#{$block-class}__action-button:not(
      .#{$block-class}__action-button--ghost
    ) {
    max-width: rem(232px);
    flex: 0 1 25%;
  }

  .#{$block-class}.#{$carbon-prefix}--btn-set.#{$block-class}--row-quadruple
    .#{$block-class}__action-button--ghost {
    flex: 1 1 25%;
  }

  .#{$block-class}
    .#{$block-class}__action-button
    .#{$carbon-prefix}--inline-loading {
    position: absolute;
    top: 0;
    right: 0;
    width: $spacing-07;
  }
}

@include exports('action-set') {
  @include action-set;
}
