Skip to content

Commit 1065201

Browse files
committed
Adding theming css
1 parent fc672b2 commit 1065201

File tree

2 files changed

+95
-21
lines changed

2 files changed

+95
-21
lines changed

src/lib/tabs/_tabs-theme.scss

Lines changed: 95 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -23,42 +23,120 @@
2323
}
2424
}
2525

26+
.mat-tab-label, .mat-tab-link {
27+
color: mat-color($foreground, text);
28+
29+
&.mat-tab-disabled {
30+
color: mat-color($foreground, disabled-text);
31+
}
32+
}
33+
34+
.mat-tab-header-pagination-chevron {
35+
border-color: mat-color($foreground, text);
36+
}
37+
38+
.mat-tab-header-pagination-disabled .mat-tab-header-pagination-chevron {
39+
border-color: mat-color($foreground, disabled-text);
40+
}
41+
2642
.mat-tab-group, .mat-tab-nav-bar {
27-
.mat-tab-label:focus, .mat-tab-link:focus {
28-
background-color: mat-color($primary, lighter, 0.3);
43+
&.mat-primary {
44+
@include _mat-tabs-color($primary);
45+
46+
&.mat-background-primary {
47+
@include _mat-tabs-color($primary, $primary);
48+
}
49+
50+
&.mat-background-accent {
51+
@include _mat-tabs-color($primary, $accent);
52+
}
53+
54+
&.mat-background-warn {
55+
@include _mat-tabs-color($primary, $warn);
56+
}
2957
}
3058

3159
&.mat-accent {
32-
.mat-tab-label:focus, .mat-tab-link:focus {
33-
background-color: mat-color($accent, lighter, 0.3);
60+
@include _mat-tabs-color($accent);
61+
62+
&.mat-background-primary {
63+
@include _mat-tabs-color($accent, $primary);
64+
}
65+
66+
&.mat-background-accent {
67+
@include _mat-tabs-color($accent, $accent);
68+
}
69+
70+
&.mat-background-warn {
71+
@include _mat-tabs-color($accent, $warn);
3472
}
3573
}
3674

3775
&.mat-warn {
38-
.mat-tab-label:focus, .mat-tab-link:focus {
39-
background-color: mat-color($warn, lighter, 0.3);
76+
@include _mat-tabs-color($warn);
77+
78+
&.mat-background-primary {
79+
@include _mat-tabs-color($warn, $primary);
80+
}
81+
82+
&.mat-background-accent {
83+
@include _mat-tabs-color($warn, $accent);
84+
}
85+
86+
&.mat-background-warn {
87+
@include _mat-tabs-color($warn, $warn);
4088
}
4189
}
90+
}
91+
}
4292

43-
.mat-ink-bar {
44-
background-color: mat-color($primary);
93+
@mixin _mat-tabs-color($color, $background-color: null) {
94+
95+
$tab-focus-color: if($background-color, $background-color, $color);
96+
97+
// Focus the tab label
98+
.mat-tab-label:focus, .mat-tab-link:focus {
99+
background-color: mat-color($tab-focus-color, lighter, 0.3);
100+
}
101+
102+
// Set the ink bar to the theme color or default-contrast if
103+
// the theme color and background color are the same
104+
.mat-ink-bar {
105+
background-color: mat-color($color);
106+
107+
@if $background-color == $color {
108+
background-color: mat-color($background-color, default-contrast);
45109
}
110+
}
46111

47-
&.mat-accent .mat-ink-bar {
48-
background-color: mat-color($accent);
112+
@if $background-color {
113+
// Set background color for the tab group
114+
.mat-tab-header, .mat-tab-links {
115+
background-color: mat-color($background-color);
49116
}
50117

51-
&.mat-warn .mat-ink-bar {
52-
background-color: mat-color($warn);
118+
// Set labels to contrast against background
119+
.mat-tab-label, .mat-tab-link {
120+
color: mat-color($background-color, default-contrast);
121+
122+
&.mat-tab-disabled {
123+
color: mat-color($background-color, default-contrast, 0.4);
124+
}
53125
}
54126

55-
}
127+
// Set pagination chevrons to contrast background
128+
.mat-tab-header-pagination-chevron {
129+
border-color: mat-color($background-color, default-contrast);
130+
}
56131

57-
.mat-tab-label, .mat-tab-link {
58-
color: mat-color($foreground, text);
132+
.mat-tab-header-pagination-disabled .mat-tab-header-pagination-chevron {
133+
border-color: mat-color($background-color, default-contrast, 0.4);
134+
}
59135

60-
&.mat-tab-disabled {
61-
color: mat-color($foreground, disabled-text);
136+
// Remove header border
137+
.mat-tab-header {
138+
border-bottom: none;
139+
border-top: none;
62140
}
63141
}
64142
}

src/lib/tabs/tab-header.scss

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -65,10 +65,6 @@
6565
.mat-tab-header-pagination-disabled {
6666
box-shadow: none;
6767
cursor: default;
68-
69-
.mat-tab-header-pagination-chevron {
70-
border-color: #ccc;
71-
}
7268
}
7369

7470
.mat-tab-label-container {

0 commit comments

Comments
 (0)