@import 'functions';

@mixin set-css-var-value($name, $value) {
  #{joinVarName($name)}: #{$value};

  // @debug #{joinVarName($name)}, #{$value};
}

@mixin set-css-var-type($name, $type, $variables) {
  #{getCssVarName($name, $type)}: #{map-get($variables, $type)};
}

@mixin set-css-color-type($colors, $type) {
  $values: map-get($colors, $type);

  @each $attr, $value in $values {
    @if $attr == 'base' {
      @include set-css-var-value(('color', $type), $value);
    } @else {
      @include set-css-var-value(('color', $type, $attr), $value);
    }
  }

  // @each $i in (1, 2, 3, 4, 5, 6, 7, 8, 9) {
  //   @include set-css-var-value(
  //     ('color', $type, 'light', $i),
  //     map-get($colors, $type, 'light-#{$i}')
  //   );
  // }

  // @include set-css-var-value(
  //   ('color', $type, 'dark-2'),
  //   map-get($colors, $type, 'dark-2')
  // );
}

@mixin set-component-css-var($name, $variables) {
  @each $attribute, $value in $variables {
    @if $attribute == 'base' {
      #{getCssVarName($name)}: #{$value};

      // @debug #{getCssVarName($name)}, #{$value};
    } @else {
      #{getCssVarName($name, $attribute)}: #{$value};

      // @debug #{getCssVarName($name, $attribute)}, #{$value};
    }
  }
}

@mixin b($name: '', $wrap: 'page') {
  @if $name == '' {
    #{$wrap} {
      @content;
    }
  } @else {
    #{$wrap} {
      .#{$name} {
        @content;
      }
    }
  }
}

@mixin c($name: '', $wrap: 'page') {
  @if $name == '' {
    #{$wrap} {
      @content;
    }
  } @else {
    .#{$name} {
      @content;
    }
  }
}

@mixin ellipsis($row: 1) {
  display: -webkit-box;
  overflow: hidden;
  text-overflow: ellipsis;
  -webkit-line-clamp: $row;
  word-break: break-all;

  /* autoprefixer: ignore next */
  -webkit-box-orient: vertical;
}

@mixin flex($type: 'row', $justify: 'center', $align: 'center') {
  display: flex;
  flex-direction: #{$type};
  justify-content: #{$justify};
  align-items: #{$align};
}
