//
// 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.
//

// Standard imports.
@import '../../global/styles/project-settings';
@import './color-map';

// UserProfileImage uses the following Carbon components:
// TooltipIcon
@import 'carbon-components/scss/components/tooltip/tooltip';

$block-class: #{$pkg-prefix}--user-profile-image;

$sizes: (
  xlg: $spacing-10,
  lg: $spacing-07,
  md: $spacing-06,
  sm: calc(#{$spacing-05} + #{$spacing-02}),
  xs: $spacing-05,
);

@mixin size($size) {
  $_size: map-get($sizes, $size);

  width: $_size;
  height: $_size;
}

$base-colors: 'cyan', 'gray', 'green', 'magenta', 'purple', 'teal';
$themes: (
  'light': (
    'light-contrast': 60,
    'dark-contrast': 80,
  ),
  'dark': (
    'light-contrast': 50,
    'dark-contrast': 30,
  ),
);

$theme-keys: map-keys($themes);

@function --get-background-color($color, $key, $contrast-key) {
  @return map-get(
    $carbon-colors,
    #{$color}#{map-get(map-get($themes, $key), #{$contrast-key}-contrast)}
  );
}

@mixin user-profile-image {
  @each $key in $theme-keys {
    .#{$block-class}--#{$key} {
      color: $ui-01;
    }
    @each $color in $base-colors {
      @each $contrast-key in $theme-keys {
        .#{$block-class}--#{$key}.#{$block-class}--#{$contrast-key}-#{$color} {
          // stylelint-disable-next-line carbon/theme-token-use
          background-color: --get-background-color($color, $key, $contrast-key);
        }
      }
    }
  }

  .#{$carbon-prefix}--tooltip__trigger.#{$block-class}__tooltip {
    &:hover,
    &:focus {
      svg {
        fill: $ui-01;
      }
    }
  }

  .#{$block-class} {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    border-radius: 100%;
    text-transform: uppercase;
  }

  .#{$prefix}--tooltip__trigger .#{$block-class} svg {
    fill: $ui-01;
  }

  .#{$block-class}__photo {
    width: 100%;
    border-radius: 100%;
  }

  .#{$block-class}__photo--xlg {
    @include size('xlg');
  }

  .#{$block-class}__photo--lg {
    @include size('lg');
  }

  .#{$block-class}__photo--md {
    @include size('md');
  }
  .#{$block-class}__photo--sm {
    @include size('sm');
  }

  .#{$block-class}__photo--xs {
    @include size('xs');
  }

  .#{$block-class}--xlg {
    @include size('xlg');
    @include carbon--type-style('productive-heading-04');
  }

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

  .#{$block-class}--md {
    @include size('md');
    @include carbon--type-style('label-01');
    @include carbon--font-weight('semibold');
  }

  .#{$block-class}--sm {
    @include size('sm');
    @include carbon--type-style('label-01');
    @include carbon--font-weight('semibold');
  }

  .#{$block-class}--xs {
    @include size('xs');
    @include carbon--type-style('label-01');
    @include carbon--font-weight('semibold');
  }
}

@include exports('user-profile-image') {
  @include user-profile-image;
}
