//
// Copyright 2018 Google Inc.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
//

@import "@limetech/mdc-animation/variables";
@import "@limetech/mdc-density/functions";
@import "@limetech/mdc-feature-targeting/functions";
@import "@limetech/mdc-feature-targeting/mixins";
@import "@limetech/mdc-tab-scroller/mixins";
@import "@limetech/mdc-tab/mixins";
@import "./variables";

@mixin mdc-tab-bar-core-styles($query: mdc-feature-all()) {
  // postcss-bem-linter: define tab-bar
  .mdc-tab-bar {
    @include mdc-tab-bar-width(100%, $query);
  }

  @include mdc-tab-bar-density($mdc-tab-bar-density-scale, $query: $query);
  @include mdc-tab-bar-stacked-density($mdc-tab-bar-stacked-density-scale, $query: $query);
  // postcss-bem-linter: end
}

@mixin mdc-tab-bar-width($width, $query: mdc-feature-all()) {
  $feat-structure: mdc-feature-create-target($query, structure);

  @include mdc-feature-targets($feat-structure) {
    width: $width;
  }
}

///
/// Sets density scale to default tab bar variant. Use `mdc-tab-bar-stacked-density()` mixin for stacked tab bar
/// variant.
///
/// @param {Number} $density-scale Density scale value. Supported density scales `-4`, `-3`, `-2`, `-1` and `0`.
///
@mixin mdc-tab-bar-density($density-scale, $query: mdc-feature-all()) {
  $height: mdc-density-prop-value(
    $density-config: $mdc-tab-bar-density-config,
    $density-scale: $density-scale,
    $property-name: height,
  );

  .mdc-tab {
    @include mdc-tab-height($height, $query: $query);
  }
}

///
/// Sets density scale to stacked tab bar variant.
///
/// @param {Number} $density-scale Density scale value. Supported density scales `-4`, `-3`, `-2`, `-1` and `0`.
///
@mixin mdc-tab-bar-stacked-density($density-scale, $query: mdc-feature-all()) {
  $height: mdc-density-prop-value(
    $density-config: $mdc-tab-bar-stacked-density-config,
    $density-scale: $density-scale,
    $property-name: height,
  );

  .mdc-tab--stacked {
    @include mdc-tab-height($height, $query: $query);
  }
}

///
/// Sets the CSS transition for the tab scrolling animation. This mixin is a proxy to `mdc-tab-scroller-transition`
/// mixin.
///
/// @param {Number | String} $duration-ms - Duration (in ms) of the animation.
/// @param {String} $timing-function - Optionally overrides the default animation timing function.
///
@mixin mdc-tab-bar-tab-scroller-transition(
  $duration-ms,
  $timing-function: $mdc-animation-standard-curve-timing-function,
  $query: mdc-feature-all()
) {
  .mdc-tab-scroller {
    @include mdc-tab-scroller-transition($duration-ms, $timing-function: $timing-function, $query: $query);
  }
}
