Skip to content

Commit 80b5d88

Browse files
committed
Rework sass for smaller output
1 parent 9abc786 commit 80b5d88

File tree

1 file changed

+62
-71
lines changed

1 file changed

+62
-71
lines changed

src/lib/tabs/_tabs-theme.scss

Lines changed: 62 additions & 71 deletions
Original file line numberDiff line numberDiff line change
@@ -39,105 +39,96 @@
3939
border-color: mat-color($foreground, disabled-text);
4040
}
4141

42-
.mat-tab-group, .mat-tab-nav-bar {
43-
&.mat-primary {
44-
@include _mat-tabs-color($primary);
45-
46-
&.mat-background-primary {
47-
@include _mat-tabs-color($primary, $primary);
48-
}
42+
// Remove header border when there is a background color
43+
.mat-tab-group[class*='mat-background-'] .mat-tab-header,
44+
.mat-tab-nav-bar[class*='mat-background-'] {
45+
border-bottom: none;
46+
border-top: none;
47+
}
4948

50-
&.mat-background-accent {
51-
@include _mat-tabs-color($primary, $accent);
52-
}
49+
.mat-tab-group, .mat-tab-nav-bar {
5350

54-
&.mat-background-warn {
55-
@include _mat-tabs-color($primary, $warn);
56-
}
51+
// Set the foreground color of the tabs
52+
&.mat-primary {
53+
@include _mat-tab-label-focus($primary);
54+
@include _mat-ink-bar($primary);
5755
}
5856

5957
&.mat-accent {
60-
@include _mat-tabs-color($accent);
58+
@include _mat-tab-label-focus($accent);
59+
@include _mat-ink-bar($accent);
60+
}
6161

62-
&.mat-background-primary {
63-
@include _mat-tabs-color($accent, $primary);
64-
}
62+
&.mat-warn {
63+
@include _mat-tab-label-focus($warn);
64+
@include _mat-ink-bar($warn);
65+
}
6566

66-
&.mat-background-accent {
67-
@include _mat-tabs-color($accent, $accent);
68-
}
67+
// Set background color of the tabs and override focus color
68+
&.mat-background-primary {
69+
@include _mat-tab-label-focus($primary);
70+
@include _mat-tabs-background($primary);
71+
}
6972

70-
&.mat-background-warn {
71-
@include _mat-tabs-color($accent, $warn);
72-
}
73+
&.mat-background-accent {
74+
@include _mat-tab-label-focus($accent);
75+
@include _mat-tabs-background($accent);
7376
}
7477

75-
&.mat-warn {
76-
@include _mat-tabs-color($warn);
78+
&.mat-background-warn {
79+
@include _mat-tab-label-focus($warn);
80+
@include _mat-tabs-background($warn);
81+
}
7782

78-
&.mat-background-primary {
79-
@include _mat-tabs-color($warn, $primary);
80-
}
83+
// Override inkbar color when theme color and background are the same
84+
&.mat-primary.mat-background-primary {
85+
@include _mat-ink-bar($primary, default-contrast);
86+
}
8187

82-
&.mat-background-accent {
83-
@include _mat-tabs-color($warn, $accent);
84-
}
88+
&.mat-accent.mat-background-accent {
89+
@include _mat-ink-bar($accent, default-contrast);
90+
}
8591

86-
&.mat-background-warn {
87-
@include _mat-tabs-color($warn, $warn);
88-
}
92+
&.mat-warn.mat-background-warn {
93+
@include _mat-ink-bar($warn, default-contrast);
8994
}
9095
}
9196
}
9297

93-
@mixin _mat-tabs-color($color, $background-color: null) {
94-
95-
$tab-focus-color: if($background-color, $background-color, $color);
98+
@mixin _mat-ink-bar($color, $hue: default) {
99+
.mat-ink-bar {
100+
background-color: mat-color($color, $hue);
101+
}
102+
}
96103

97-
// Focus the tab label
104+
@mixin _mat-tab-label-focus($tab-focus-color) {
98105
.mat-tab-label:focus, .mat-tab-link:focus {
99106
background-color: mat-color($tab-focus-color, lighter, 0.3);
100107
}
108+
}
101109

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);
109-
}
110+
@mixin _mat-tabs-background($background-color) {
111+
// Set background color for the tab group
112+
.mat-tab-header, .mat-tab-links {
113+
background-color: mat-color($background-color);
110114
}
111115

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);
116-
}
117-
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-
}
125-
}
116+
// Set labels to contrast against background
117+
.mat-tab-label, .mat-tab-link {
118+
color: mat-color($background-color, default-contrast);
126119

127-
// Set pagination chevrons to contrast background
128-
.mat-tab-header-pagination-chevron {
129-
border-color: mat-color($background-color, default-contrast);
120+
&.mat-tab-disabled {
121+
color: mat-color($background-color, default-contrast, 0.4);
130122
}
123+
}
131124

132-
.mat-tab-header-pagination-disabled .mat-tab-header-pagination-chevron {
133-
border-color: mat-color($background-color, default-contrast, 0.4);
134-
}
125+
// Set pagination chevrons to contrast background
126+
.mat-tab-header-pagination-chevron {
127+
border-color: mat-color($background-color, default-contrast);
128+
}
135129

136-
// Remove header border
137-
.mat-tab-header {
138-
border-bottom: none;
139-
border-top: none;
140-
}
130+
.mat-tab-header-pagination-disabled .mat-tab-header-pagination-chevron {
131+
border-color: mat-color($background-color, default-contrast, 0.4);
141132
}
142133
}
143134

0 commit comments

Comments
 (0)