|
12 | 12 | // Represents a collection of typography levels.
|
13 | 13 | // Defaults come from https://material.io/guidelines/style/typography.html
|
14 | 14 | @function mat-typography-config(
|
15 |
| - $font-family: 'Roboto, "Helvetica Neue", sans-serif', |
16 |
| - $display-4: mat-typography-level(112px, 112px, 300), |
17 |
| - $display-3: mat-typography-level(56px, 56px, 400), |
18 |
| - $display-2: mat-typography-level(45px, 48px, 400), |
19 |
| - $display-1: mat-typography-level(34px, 40px, 400), |
20 |
| - $headline: mat-typography-level(24px, 32px, 400), |
21 |
| - $title: mat-typography-level(20px, 20px, 500), |
22 |
| - $subheading: mat-typography-level(16px, 28px, 400), |
23 |
| - $body-2: mat-typography-level(14px, 24px, 500), |
24 |
| - $body-1: mat-typography-level(14px, 20px, 400), |
25 |
| - $caption: mat-typography-level(12px, 12px, 400), |
26 |
| - $button: mat-typography-level(14px, 14px, 500), |
| 15 | + $font-family: 'Roboto, "Helvetica Neue", sans-serif', |
| 16 | + $display-4: mat-typography-level(112px, 112px, 300), |
| 17 | + $display-3: mat-typography-level(56px, 56px, 400), |
| 18 | + $display-2: mat-typography-level(45px, 48px, 400), |
| 19 | + $display-1: mat-typography-level(34px, 40px, 400), |
| 20 | + $headline: mat-typography-level(24px, 32px, 400), |
| 21 | + $title: mat-typography-level(20px, 32px, 500), |
| 22 | + $subheading-2: mat-typography-level(16px, 28px, 400), |
| 23 | + $subheading-1: mat-typography-level(15px, 24px, 400), |
| 24 | + $body-2: mat-typography-level(14px, 24px, 500), |
| 25 | + $body-1: mat-typography-level(14px, 20px, 400), |
| 26 | + $caption: mat-typography-level(12px, 20px, 400), |
| 27 | + $button: mat-typography-level(14px, 14px, 500), |
27 | 28 | // Line-height must be unit-less fraction of the font-size.
|
28 |
| - $input: mat-typography-level(inherit, 1.125, 400) |
| 29 | + $input: mat-typography-level(inherit, 1.125, 400) |
29 | 30 | ) {
|
30 | 31 | @return (
|
31 |
| - font-family: $font-family, |
32 |
| - display-4: $display-4, |
33 |
| - display-3: $display-3, |
34 |
| - display-2: $display-2, |
35 |
| - display-1: $display-1, |
36 |
| - headline: $headline, |
37 |
| - title: $title, |
38 |
| - subheading: $subheading, |
39 |
| - body-2: $body-2, |
40 |
| - body-1: $body-1, |
41 |
| - caption: $caption, |
42 |
| - button: $button, |
43 |
| - input: $input, |
| 32 | + font-family: $font-family, |
| 33 | + display-4: $display-4, |
| 34 | + display-3: $display-3, |
| 35 | + display-2: $display-2, |
| 36 | + display-1: $display-1, |
| 37 | + headline: $headline, |
| 38 | + title: $title, |
| 39 | + subheading-2: $subheading-2, |
| 40 | + subheading-1: $subheading-1, |
| 41 | + body-2: $body-2, |
| 42 | + body-1: $body-1, |
| 43 | + caption: $caption, |
| 44 | + button: $button, |
| 45 | + input: $input, |
44 | 46 | );
|
45 | 47 | }
|
46 | 48 |
|
47 | 49 | // Adds the base typography styles, based on a config.
|
48 |
| -// TODO(crisbeto): the headers need to handle margins as well. |
49 | 50 | @mixin mat-base-typography($config, $selector: '.mat-typography') {
|
50 |
| - .mat-h0, .mat-hero-header { |
51 |
| - @include mat-typography-level-to-styles($config, display-4); |
52 |
| - |
53 |
| - // Note: The spec doesn't mention letter spacing. The value comes from |
54 |
| - // eyeballing it until it looked exactly like the spec examples. |
55 |
| - letter-spacing: -0.05em; |
56 |
| - } |
57 |
| - |
58 |
| - .mat-h1, #{$selector} h1 { |
59 |
| - @include mat-typography-level-to-styles($config, display-3); |
60 |
| - |
61 |
| - // Note: The spec doesn't mention letter spacing. The value comes from |
62 |
| - // eyeballing it until it looked exactly like the spec examples. |
63 |
| - letter-spacing: -0.02em; |
| 51 | + .mat-h1, .mat-headline, #{$selector} h1 { |
| 52 | + @include mat-typography-level-to-styles($config, headline); |
| 53 | + margin: 0 0 16px; |
64 | 54 | }
|
65 | 55 |
|
66 |
| - .mat-h2, #{$selector} h2 { |
67 |
| - @include mat-typography-level-to-styles($config, display-2); |
68 |
| - |
69 |
| - // Note: The spec doesn't mention letter spacing. The value comes from |
70 |
| - // eyeballing it until it looked exactly like the spec examples.; |
71 |
| - letter-spacing: -0.005em; |
| 56 | + .mat-h2, .mat-title, #{$selector} h2 { |
| 57 | + @include mat-typography-level-to-styles($config, title); |
| 58 | + margin: 0 0 16px; |
72 | 59 | }
|
73 | 60 |
|
74 |
| - .mat-h3, #{$selector} h3 { |
75 |
| - @include mat-typography-level-to-styles($config, display-1); |
| 61 | + .mat-h3, .mat-subheading-2, #{$selector} h3 { |
| 62 | + @include mat-typography-level-to-styles($config, subheading-2); |
| 63 | + margin: 0 0 16px; |
76 | 64 | }
|
77 | 65 |
|
78 |
| - .mat-h4, #{$selector} h4 { |
79 |
| - @include mat-typography-level-to-styles($config, headline); |
| 66 | + .mat-h4, .mat-subheading-1, #{$selector} h4 { |
| 67 | + @include mat-typography-level-to-styles($config, subheading-1); |
| 68 | + margin: 0 0 16px; |
80 | 69 | }
|
81 | 70 |
|
| 71 | + // Note: the spec doesn't have anything that would correspond to h5 and h6, but we add these for |
| 72 | + // consistency. The font sizes come from the Chrome user agent styles which have h5 at 0.83em |
| 73 | + // and h6 at 0.67em. |
82 | 74 | .mat-h5, #{$selector} h5 {
|
83 |
| - @include mat-typography-level-to-styles($config, title); |
| 75 | + font-size: mat-font-size($config, body-1) * 0.83; |
| 76 | + font-weight: mat-font-weight($config, body-1); |
| 77 | + font-family: mat-font-family($config); |
| 78 | + line-height: mat-line-height($config, body-1); |
| 79 | + margin: 0 0 12px; |
84 | 80 | }
|
85 | 81 |
|
86 | 82 | .mat-h6, #{$selector} h6 {
|
87 |
| - @include mat-typography-level-to-styles($config, subheading); |
| 83 | + font-size: mat-font-size($config, body-1) * 0.67; |
| 84 | + font-weight: mat-font-weight($config, body-1); |
| 85 | + font-family: mat-font-family($config); |
| 86 | + line-height: mat-line-height($config, body-1); |
| 87 | + margin: 0 0 12px; |
88 | 88 | }
|
89 | 89 |
|
90 |
| - .mat-body-strong { |
| 90 | + .mat-body-strong, .mat-body-2 { |
91 | 91 | @include mat-typography-level-to-styles($config, body-2);
|
92 | 92 | }
|
93 | 93 |
|
94 |
| - .mat-body, #{$selector} { |
| 94 | + .mat-body, .mat-body-1, #{$selector} { |
95 | 95 | @include mat-typography-level-to-styles($config, body-1);
|
| 96 | + |
| 97 | + p { |
| 98 | + margin: 0 0 12px; |
| 99 | + } |
96 | 100 | }
|
97 | 101 |
|
98 |
| - .mat-small { |
| 102 | + .mat-small, .mat-caption { |
99 | 103 | @include mat-typography-level-to-styles($config, caption);
|
100 | 104 | }
|
| 105 | + |
| 106 | + // Note: The spec doesn't mention letter spacing. The value comes from |
| 107 | + // eyeballing it until it looked exactly like the spec examples. |
| 108 | + .mat-display-4, #{$selector} .mat-display-4 { |
| 109 | + @include mat-typography-level-to-styles($config, display-4); |
| 110 | + margin: 0 0 56px; |
| 111 | + letter-spacing: -0.05em; |
| 112 | + } |
| 113 | + |
| 114 | + .mat-display-3, #{$selector} .mat-display-3 { |
| 115 | + @include mat-typography-level-to-styles($config, display-3); |
| 116 | + margin: 0 0 64px; |
| 117 | + letter-spacing: -0.02em; |
| 118 | + } |
| 119 | + |
| 120 | + .mat-display-2, #{$selector} .mat-display-2 { |
| 121 | + @include mat-typography-level-to-styles($config, display-2); |
| 122 | + margin: 0 0 64px; |
| 123 | + letter-spacing: -0.005em; |
| 124 | + } |
| 125 | + |
| 126 | + .mat-display-1, #{$selector} .mat-display-1 { |
| 127 | + @include mat-typography-level-to-styles($config, display-1); |
| 128 | + margin: 0 0 64px; |
| 129 | + } |
101 | 130 | }
|
0 commit comments