|
71 | 71 |
|
72 | 72 | // Adds the base typography styles, based on a config. |
73 | 73 | @mixin mat-base-typography($config, $selector: '.mat-typography') { |
74 | | - .mat-h1, .mat-headline, #{$selector} h1 { |
| 74 | + // Note that it seems redundant to prefix the class rules with the `$selector`, however it's |
| 75 | + // necessary if we want to allow people to overwrite the tag selectors. This is due to |
| 76 | + // selectors like `#{$selector} h1` being more specific than ones like `.mat-title`. |
| 77 | + .mat-h1, |
| 78 | + .mat-headline, |
| 79 | + #{$selector} .mat-h1, |
| 80 | + #{$selector} .mat-headline, |
| 81 | + #{$selector} h1 { |
75 | 82 | @include mat-typography-level-to-styles($config, headline); |
76 | 83 | margin: 0 0 16px; |
77 | 84 | } |
78 | 85 |
|
79 | | - .mat-h2, .mat-title, #{$selector} h2 { |
| 86 | + .mat-h2, |
| 87 | + .mat-title, |
| 88 | + #{$selector} .mat-h2, |
| 89 | + #{$selector} .mat-title, |
| 90 | + #{$selector} h2 { |
80 | 91 | @include mat-typography-level-to-styles($config, title); |
81 | 92 | margin: 0 0 16px; |
82 | 93 | } |
83 | 94 |
|
84 | | - .mat-h3, .mat-subheading-2, #{$selector} h3 { |
| 95 | + .mat-h3, |
| 96 | + .mat-subheading-2, |
| 97 | + #{$selector} .mat-h3, |
| 98 | + #{$selector} .mat-subheading-2, |
| 99 | + #{$selector} h3 { |
85 | 100 | @include mat-typography-level-to-styles($config, subheading-2); |
86 | 101 | margin: 0 0 16px; |
87 | 102 | } |
88 | 103 |
|
89 | | - .mat-h4, .mat-subheading-1, #{$selector} h4 { |
| 104 | + .mat-h4, |
| 105 | + .mat-subheading-1, |
| 106 | + #{$selector} .mat-h4, |
| 107 | + #{$selector} .mat-subheading-1, |
| 108 | + #{$selector} h4 { |
90 | 109 | @include mat-typography-level-to-styles($config, subheading-1); |
91 | 110 | margin: 0 0 16px; |
92 | 111 | } |
93 | 112 |
|
94 | 113 | // Note: the spec doesn't have anything that would correspond to h5 and h6, but we add these for |
95 | 114 | // consistency. The font sizes come from the Chrome user agent styles which have h5 at 0.83em |
96 | 115 | // and h6 at 0.67em. |
97 | | - .mat-h5, #{$selector} h5 { |
| 116 | + .mat-h5, |
| 117 | + #{$selector} .mat-h5, |
| 118 | + #{$selector} h5 { |
98 | 119 | @include mat-typography-font-shorthand( |
99 | 120 | // calc is used here to support css variables |
100 | 121 | calc(#{mat-font-size($config, body-1)} * 0.83), |
|
106 | 127 | margin: 0 0 12px; |
107 | 128 | } |
108 | 129 |
|
109 | | - .mat-h6, #{$selector} h6 { |
| 130 | + .mat-h6, |
| 131 | + #{$selector} .mat-h6, |
| 132 | + #{$selector} h6 { |
110 | 133 | @include mat-typography-font-shorthand( |
111 | 134 | // calc is used here to support css variables |
112 | 135 | calc(#{mat-font-size($config, body-1)} * 0.67), |
|
118 | 141 | margin: 0 0 12px; |
119 | 142 | } |
120 | 143 |
|
121 | | - .mat-body-strong, .mat-body-2 { |
| 144 | + .mat-body-strong, |
| 145 | + .mat-body-2, |
| 146 | + #{$selector} .mat-body-strong, |
| 147 | + #{$selector} .mat-body-2 { |
122 | 148 | @include mat-typography-level-to-styles($config, body-2); |
123 | 149 | } |
124 | 150 |
|
125 | | - .mat-body, .mat-body-1, #{$selector} { |
| 151 | + .mat-body, |
| 152 | + .mat-body-1, |
| 153 | + #{$selector} .mat-body, |
| 154 | + #{$selector} .mat-body-1, |
| 155 | + #{$selector} { |
126 | 156 | @include mat-typography-level-to-styles($config, body-1); |
127 | 157 |
|
128 | 158 | p { |
129 | 159 | margin: 0 0 12px; |
130 | 160 | } |
131 | 161 | } |
132 | 162 |
|
133 | | - .mat-small, .mat-caption { |
| 163 | + .mat-small, |
| 164 | + .mat-caption, |
| 165 | + #{$selector} .mat-small, |
| 166 | + #{$selector} .mat-caption { |
134 | 167 | @include mat-typography-level-to-styles($config, caption); |
135 | 168 | } |
136 | 169 |
|
137 | | - .mat-display-4, #{$selector} .mat-display-4 { |
| 170 | + .mat-display-4, |
| 171 | + #{$selector} .mat-display-4 { |
138 | 172 | @include mat-typography-level-to-styles($config, display-4); |
139 | 173 | margin: 0 0 56px; |
140 | 174 | } |
141 | 175 |
|
142 | | - .mat-display-3, #{$selector} .mat-display-3 { |
| 176 | + .mat-display-3, |
| 177 | + #{$selector} .mat-display-3 { |
143 | 178 | @include mat-typography-level-to-styles($config, display-3); |
144 | 179 | margin: 0 0 64px; |
145 | 180 | } |
146 | 181 |
|
147 | | - .mat-display-2, #{$selector} .mat-display-2 { |
| 182 | + .mat-display-2, |
| 183 | + #{$selector} .mat-display-2 { |
148 | 184 | @include mat-typography-level-to-styles($config, display-2); |
149 | 185 | margin: 0 0 64px; |
150 | 186 | } |
151 | 187 |
|
152 | | - .mat-display-1, #{$selector} .mat-display-1 { |
| 188 | + .mat-display-1, |
| 189 | + #{$selector} .mat-display-1 { |
153 | 190 | @include mat-typography-level-to-styles($config, display-1); |
154 | 191 | margin: 0 0 64px; |
155 | 192 | } |
|
0 commit comments