// Copyright 2020 Energinet DataHub A/S
//
// Licensed under the Apache License, Version 2.0 (the "License2");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//     http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
@use "sass:map";
@use "./watt-icon-variables" as variables;

:root {
  --watt-icon-fill: 0;

  @each $name, $settings in variables.$settings {
    $size: map.get($settings, size);
    --watt-icon-size-#{$name}: #{$size};
  }
}

watt-icon {
  display: flex;
  justify-content: center;
  align-items: center;

  &[fill] {
    --watt-icon-fill: 1;
  }

  @each $name, $settings in variables.$settings {
    $size: map.get($settings, size);
    $weight: map.get($settings, weight);
    $grade: map.get($settings, grade);
    $opticalSize: map.get($settings, optical-size);

    &.icon-size-#{$name} {
      .mat-icon,
      .watt-custom-icon {
        font-size: var(--watt-icon-size-#{$name});
        line-height: var(--watt-icon-size-#{$name});
        width: var(--watt-icon-size-#{$name});
        height: var(--watt-icon-size-#{$name});
      }

      .material-symbols-sharp {
        font-variation-settings:
          "FILL" var(--watt-icon-fill),
          "wght" $weight,
          "GRAD" $grade,
          "opsz" $opticalSize;
      }
    }
  }

  &.icon-state-success .mat-icon {
    color: var(--watt-color-state-success);
  }

  &.icon-state-danger .mat-icon {
    color: var(--watt-color-state-danger);
  }

  &.icon-state-warning .mat-icon {
    color: var(--watt-color-state-warning);
  }

  &.icon-state-info .mat-icon {
    color: var(--watt-color-state-info);
  }
}

.watt-custom-icon svg {
  width: 100%;
  height: 100%;
}
