@import "../../../themes/ionic.globals.md";

// Material Design Segment
// --------------------------------------------------

/// @prop - Text color of the activated segment button
$segment-button-md-text-color-activated: $toolbar-md-active-color !default;

/// @prop - Border color of the activated segment button
$segment-button-md-border-color-activated: $toolbar-md-active-color !default;

/// @prop - Width of the bottom border on the segment button
$segment-button-md-border-bottom-width: 2px !default;

/// @prop - Color of the bottom border on the segment button
$segment-button-md-border-bottom-color: rgba(#000, 0.1) !default;

/// @prop - Opacity of the segment button
$segment-button-md-opacity: 0.7 !default;

/// @prop - Opacity of the activated segment button
$segment-button-md-opacity-activated: 1 !default;

/// @prop - Opacity of the disabled segment button
$segment-button-md-opacity-disabled: 0.3 !default;

/// @prop - Padding top of the segment button
$segment-button-md-padding-top: 0 !default;

/// @prop - Padding end of the segment button
$segment-button-md-padding-end: 6px !default;

/// @prop - Padding bottom of the segment button
$segment-button-md-padding-bottom: $segment-button-md-padding-top !default;

/// @prop - Padding start of the segment button
$segment-button-md-padding-start: $segment-button-md-padding-end !default;

/// @prop - Height of the segment button
$segment-button-md-height: 42px !default;

/// @prop - Line height of the segment button
$segment-button-md-line-height: 40px !default;

/// @prop - Font size of the segment button
$segment-button-md-font-size: 12px !default;

/// @prop - Size of an icon in the segment button
$segment-button-md-icon-size: 26px !default;

/// @prop - Line height of an icon in the segment button
$segment-button-md-icon-line-height: $segment-button-md-line-height !default;

.segment-md .segment-button {
  width: 0;
  height: $segment-button-md-height;
  font-size: $segment-button-md-font-size;
  font-weight: 500;
  line-height: $segment-button-md-line-height;
  color: $segment-button-md-text-color-activated;
  text-transform: uppercase;
  background-color: transparent;
  border-bottom-color: $segment-button-md-border-bottom-color;
  border-bottom-style: solid;
  border-bottom-width: $segment-button-md-border-bottom-width;
  opacity: $segment-button-md-opacity;
  transition: 100ms all linear;
  flex: 1;
  
  @include padding($segment-button-md-padding-top, $segment-button-md-padding-end, $segment-button-md-padding-bottom, $segment-button-md-padding-start);
  
  .ion-icon {
    font-size: $segment-button-md-icon-size;
    line-height: $segment-button-md-icon-line-height;
  }
  
  &:active,
  &.segment-activated {
    border-color: $segment-button-md-border-color-activated;
    opacity: $segment-button-md-opacity-activated;
  }
}

.segment-md.segment-disabled,
.segment-md .segment-button-disabled {
  pointer-events: none;
  opacity: $segment-button-md-opacity-disabled;
}

.toolbar {
  .segment-md {
    @include margin(0, auto);
  }
  
  .segment-md .segment-button:active,
  .segment-md .segment-button.segment-activated {
    opacity: 1;
  }
  
}

// Material Design Segment Button Mixin
// --------------------------------------------------

@mixin md-segment-button($color-name, $color-base, $color-contrast) {
  .segment-md-#{$color-name} .segment-button {
    color: $color-base;
    
    &:active,
    &.segment-activated {
      color: $color-base;
      border-color: $color-base;
      opacity: 1;
    }
  }
  
}

// Material Design Segment Color Generation
// --------------------------------------------------

@each $color-name, $color-base, $color-contrast in get-colors($colors-md) {
  @include md-segment-button($color-name, $color-base, $color-contrast);
}
