blob: 7f2e43df6a3932930ad4684431ce2d54a23c1e1f [file] [log] [blame]
@import '../core/theming/palette';
@import '../core/theming/theming';
@import '../core/typography/typography-utils';
@mixin mat-tabs-color($config-or-theme) {
$config: mat-get-color-config($config-or-theme);
$primary: map-get($config, primary);
$accent: map-get($config, accent);
$warn: map-get($config, warn);
$background: map-get($config, background);
$foreground: map-get($config, foreground);
$header-border: 1px solid mat-color($foreground, divider);
.mat-tab-nav-bar,
.mat-tab-header {
border-bottom: $header-border;
}
.mat-tab-group-inverted-header {
.mat-tab-nav-bar,
.mat-tab-header {
border-top: $header-border;
border-bottom: none;
}
}
.mat-tab-label, .mat-tab-link {
color: mat-color($foreground, text);
&.mat-tab-disabled {
color: mat-color($foreground, disabled-text);
}
}
.mat-tab-header-pagination-chevron {
border-color: mat-color($foreground, text);
}
.mat-tab-header-pagination-disabled .mat-tab-header-pagination-chevron {
border-color: mat-color($foreground, disabled-text);
}
// Remove header border when there is a background color
.mat-tab-group[class*='mat-background-'] .mat-tab-header,
.mat-tab-nav-bar[class*='mat-background-'] {
border-bottom: none;
border-top: none;
}
.mat-tab-group, .mat-tab-nav-bar {
$theme-colors: (
primary: $primary,
accent: $accent,
warn: $warn
);
@each $name, $color in $theme-colors {
// Set the foreground color of the tabs
&.mat-#{$name} {
@include _mat-tab-label-focus($color);
@include _mat-ink-bar($color);
// Override ink bar when background color is the same
&.mat-background-#{$name} {
> .mat-tab-header, > .mat-tab-link-container {
@include _mat-ink-bar($color, default-contrast);
}
}
}
}
@each $name, $color in $theme-colors {
// Set background color of the tabs and override focus color
&.mat-background-#{$name} {
@include _mat-tab-label-focus($color);
@include _mat-tabs-background($color);
}
}
}
}
@mixin _mat-ink-bar($color, $hue: default) {
.mat-ink-bar {
background-color: mat-color($color, $hue);
}
}
@mixin _mat-tab-label-focus($tab-focus-color) {
.mat-tab-label,
.mat-tab-link {
&.cdk-keyboard-focused,
&.cdk-program-focused {
&:not(.mat-tab-disabled) {
background-color: mat-color($tab-focus-color, lighter, 0.3);
}
}
}
}
@mixin _mat-tabs-background($background-color) {
// Note that these selectors target direct descendants so
// that the styles don't apply to any nested tab groups.
// Set background color for the tab group
> .mat-tab-header, > .mat-tab-link-container, > .mat-tab-header-pagination {
background-color: mat-color($background-color);
}
// Set labels to contrast against background
> .mat-tab-header .mat-tab-label, > .mat-tab-link-container .mat-tab-link {
color: mat-color($background-color, default-contrast);
&.mat-tab-disabled {
color: mat-color($background-color, default-contrast, 0.4);
}
}
// Set pagination chevrons to contrast background
> .mat-tab-header-pagination .mat-tab-header-pagination-chevron,
> .mat-tab-links .mat-focus-indicator::before,
> .mat-tab-header .mat-focus-indicator::before {
border-color: mat-color($background-color, default-contrast);
}
> .mat-tab-header-pagination-disabled .mat-tab-header-pagination-chevron {
border-color: mat-color($background-color, default-contrast, 0.4);
}
// Set ripples color to be the contrast color of the new background. Otherwise the ripple
// color will be based on the app background color.
> .mat-tab-header .mat-ripple-element,
> .mat-tab-link-container .mat-ripple-element {
background-color: mat-color($background-color, default-contrast, 0.12);
}
}
@mixin mat-tabs-typography($config-or-theme) {
$config: mat-get-typography-config($config-or-theme);
.mat-tab-group {
font-family: mat-font-family($config);
}
.mat-tab-label, .mat-tab-link {
font: {
family: mat-font-family($config, button);
size: mat-font-size($config, button);
weight: mat-font-weight($config, button);
}
}
}
@mixin _mat-tabs-density($config-or-theme) {}
@mixin mat-tabs-theme($theme-or-color-config) {
$theme: mat-private-legacy-get-theme($theme-or-color-config);
@include mat-private-check-duplicate-theme-styles($theme, 'mat-tabs') {
$color: mat-get-color-config($theme);
$density: mat-get-density-config($theme);
$typography: mat-get-typography-config($theme);
@if $color != null {
@include mat-tabs-color($color);
}
@if $density != null {
@include _mat-tabs-density($density);
}
@if $typography != null {
@include mat-tabs-typography($typography);
}
}
}