使用主题的角形材料文本颜色

Vik*_*Vik 3 css themes sass angular-material2 angular

我正在使用具有原色和强调色的棱角材质主题。我有两个不同的主题,分别定义为橙色和绿色,最终用户可以动态更改。theme.scss如下所示

@import '~@angular/material/theming';

@include mat-core();

@mixin widget-theme($theme) {
    $primary: map-get($theme, primary);
    $accent: map-get($theme, accent);

    .fa-icon {
      color: mat-color($primary);
    }

    .fa-table-data-row-selected {
        background-color: mat-color($accent) !important;
        color: #152A23
    }

    .fa-text-link {
        color: #2A5D9F;
    }
  }



$custom-primary: mat-palette($mat-blue-grey,500);
$custom-accent:  mat-palette($mat-light-blue, A200);
$custom-warn:    mat-palette($mat-red);
$custom-theme: mat-light-theme($custom-primary, $custom-accent, $custom-warn);

@include angular-material-theme($custom-theme);
@include widget-theme($custom-theme);

//Orange theme
$ora-primary: mat-palette($mat-orange, 800);
$ora-accent:  mat-palette($mat-deep-purple, A100);
$ora-theme: mat-light-theme($ora-primary, $ora-accent);

.orange-theme {
    @include angular-material-theme($ora-theme);
    @include widget-theme($ora-theme);
}

//green theme
$green-primary: mat-palette($mat-green, 800);
$green-accent:  mat-palette($mat-lime, A700);
$green-theme: mat-light-theme($green-primary, $green-accent);

.green-theme {
    @include angular-material-theme($green-theme);
    @include widget-theme($green-theme);
}
Run Code Online (Sandbox Code Playgroud)

我的整体配色方案使用原色和强调色来完成出色的工作。但是,请注意用例,其中我有一张桌子,并且使用带有css fa-table-data-row-selected的强调色来使用选定的行颜色。所选行的文本颜色当前为硬编码。显然,这不适用于所有强调色,并且可能看起来绝对不可读。因此,还应该根据选择的主题动态地更改它。

这里有什么建议?我无法清楚地使用原色或强调色,因为这看起来可能不是最好的。它可能需要是其他一些变量,该变量的取值取决于所选择的主题。

G. *_*ter 9

使用调色板颜色的“对比”颜色:

color: mat-contrast($accent, default);
Run Code Online (Sandbox Code Playgroud)

与以下内容相同:

color: mat-color($accent, default-contrast);
Run Code Online (Sandbox Code Playgroud)

稍微了解一下主题内部结构可能会很有用。