@use 'sass:map';
@use '~@angular/material' as mat;

@mixin color($theme) {
  $config: mat.get-color-config($theme);
  $primary: map.get($config, primary);
  $foreground: map.get($config, foreground);
  $background: map.get($config, background);

  rds-c-nav-tree {
    .mat-tree-node {
      border-color: transparent;
      &:hover {
        background-color: mat.get-color-from-palette($background, hover);
      }
      &.node-active {
        background-color: mat.get-color-from-palette($primary, default, 0.12);
        border-color: mat.get-color-from-palette($primary);
      }
    }

    .rds-nav-tree-node-link,
    .mat-icon[matTreeNodeToggle],
    .node-icon,
    .tree-toggle-button {
      color: mat.get-color-from-palette($foreground, text);
    }
  }
}

@mixin typography($theme) {
  $typography-config: mat.get-typography-config($theme);
  rds-c-nav-tree {
    .rds-nav-tree-node-link {
      @include mat.typography-level($typography-config, 'body-2');
    }
  }
}

@mixin theme($theme) {
  $config: mat.get-color-config($theme);
  @if $config != null {
    @include color($theme);
  }

  $typography-config: mat.get-typography-config($theme);
  @if $typography-config != null {
    @include typography($theme);
  }
}
