Skip to content

fix(material/core): unable to override tag selectors inside .mat-typography #14617

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
63 changes: 50 additions & 13 deletions src/material/core/typography/_typography.scss
Original file line number Diff line number Diff line change
Expand Up @@ -183,30 +183,51 @@
@mixin typography-hierarchy($config-or-theme, $selector: '.mat-typography') {
$config: private-typography-to-2014-config(theming.get-typography-config($config-or-theme));

.mat-h1, .mat-headline, #{$selector} h1 {
// Note that it seems redundant to prefix the class rules with the `$selector`, however it's
// necessary if we want to allow people to overwrite the tag selectors. This is due to
// selectors like `#{$selector} h1` being more specific than ones like `.mat-title`.
.mat-h1,
.mat-headline,
#{$selector} .mat-h1,
#{$selector} .mat-headline,
#{$selector} h1 {
@include typography-utils.typography-level($config, headline);
margin: 0 0 16px;
}

.mat-h2, .mat-title, #{$selector} h2 {
.mat-h2,
.mat-title,
#{$selector} .mat-h2,
#{$selector} .mat-title,
#{$selector} h2 {
@include typography-utils.typography-level($config, title);
margin: 0 0 16px;
}

.mat-h3, .mat-subheading-2, #{$selector} h3 {
.mat-h3,
.mat-subheading-2,
#{$selector} .mat-h3,
#{$selector} .mat-subheading-2,
#{$selector} h3 {
@include typography-utils.typography-level($config, subheading-2);
margin: 0 0 16px;
}

.mat-h4, .mat-subheading-1, #{$selector} h4 {
.mat-h4,
.mat-subheading-1,
#{$selector} .mat-h4,
#{$selector} .mat-subheading-1,
#{$selector} h4 {
@include typography-utils.typography-level($config, subheading-1);
margin: 0 0 16px;
}

// Note: the spec doesn't have anything that would correspond to h5 and h6, but we add these for
// consistency. The font sizes come from the Chrome user agent styles which have h5 at 0.83em
// and h6 at 0.67em.
.mat-h5, #{$selector} h5 {
.mat-h5,
#{$selector} .mat-h5,
#{$selector} h5 {
@include typography-utils.font-shorthand(
// calc is used here to support css variables
calc(#{typography-utils.font-size($config, body-1)} * 0.83),
Expand All @@ -218,7 +239,9 @@
margin: 0 0 12px;
}

.mat-h6, #{$selector} h6 {
.mat-h6,
#{$selector} .mat-h6,
#{$selector} h6 {
@include typography-utils.font-shorthand(
// calc is used here to support css variables
calc(#{typography-utils.font-size($config, body-1)} * 0.67),
Expand All @@ -230,38 +253,52 @@
margin: 0 0 12px;
}

.mat-body-strong, .mat-body-2 {
.mat-body-strong,
.mat-body-2,
#{$selector} .mat-body-strong,
#{$selector} .mat-body-2 {
@include typography-utils.typography-level($config, body-2);
}

.mat-body, .mat-body-1, #{$selector} {
.mat-body,
.mat-body-1,
#{$selector} .mat-body,
#{$selector} .mat-body-1,
#{$selector} {
@include typography-utils.typography-level($config, body-1);

p {
margin: 0 0 12px;
}
}

.mat-small, .mat-caption {
.mat-small,
.mat-caption,
#{$selector} .mat-small,
#{$selector} .mat-caption {
@include typography-utils.typography-level($config, caption);
}

.mat-display-4, #{$selector} .mat-display-4 {
.mat-display-4,
#{$selector} .mat-display-4 {
@include typography-utils.typography-level($config, display-4);
margin: 0 0 56px;
}

.mat-display-3, #{$selector} .mat-display-3 {
.mat-display-3,
#{$selector} .mat-display-3 {
@include typography-utils.typography-level($config, display-3);
margin: 0 0 64px;
}

.mat-display-2, #{$selector} .mat-display-2 {
.mat-display-2,
#{$selector} .mat-display-2 {
@include typography-utils.typography-level($config, display-2);
margin: 0 0 64px;
}

.mat-display-1, #{$selector} .mat-display-1 {
.mat-display-1,
#{$selector} .mat-display-1 {
@include typography-utils.typography-level($config, display-1);
margin: 0 0 64px;
}
Expand Down