I have an application with Angular 9 using Angular Material, which has 2 themes (dark and light). They are defined like this in the style.scss file:
$rasd-dark-text-color: mat-palette($mat-grey, 300);
$rasd-light-text-color: mat-palette($mat-grey, 800);
.rasd-dark {
--text-color: #{mat-color($rasd-dark-text-color)};
}
.rasd-light {
--text-color: #{mat-color($rasd-light-text-color)};
}
And to set the theme for the application, I just set it as a class of the body element:
<body class="mat-typography rasd-dark">
<app-root></app-root>
</body>
I have a small Angular component which will need to get the value from --test-color as Hex color which depends on which (dark or light theme is applied on the body element).
export class ChartComponent implements OnInit {
textColor: string;
ngOnInit(): void {
// (!!!) How can I set the value for textColor from --test-color in SCSS?
// e.g: after setting, the value of textColor is #001100
}
}