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