/
card.scss
251 lines (207 loc) · 5.62 KB
/
card.scss
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
@use '../core/style/variables';
@use '../core/style/elevation';
@use '../core/style/private';
@use '../../cdk/a11y';
$padding: 16px !default;
$border-radius: 4px !default;
$header-size: 40px !default;
.mat-card {
@include elevation.elevation-transition;
@include private.private-animation-noop();
display: block;
position: relative;
padding: $padding;
border-radius: $border-radius;
.mat-divider-horizontal {
position: absolute;
left: 0;
width: 100%;
[dir='rtl'] & {
left: auto;
right: 0;
}
&.mat-divider-inset {
position: static;
margin: 0;
[dir='rtl'] & {
// Needs to be reset explicitly since the divider set `margin-right` in particular in RTL.
margin-right: 0;
}
}
}
@include a11y.high-contrast(active, off) {
outline: solid 1px;
}
}
// base styles for each card section preset (mat-card-content, etc)
%mat-card-section-base {
display: block;
margin-bottom: 16px;
}
.mat-card-title {
display: block;
margin-bottom: 8px;
}
.mat-card-subtitle, .mat-card-content {
@extend %mat-card-section-base;
}
.mat-card-actions {
@extend %mat-card-section-base;
margin-left: private.private-div(-$padding, 2);
margin-right: private.private-div(-$padding, 2);
padding: 8px 0;
}
.mat-card-actions-align-end {
display: flex;
justify-content: flex-end;
}
.mat-card-image {
width: calc(100% + #{$padding * 2});
margin: 0 (-$padding) 16px (-$padding);
}
.mat-card-footer {
// The negative margins pulls out the element, countering the padding
// to get the footer to be flush against the side of the card.
$margin: -$padding;
display: block;
margin: 0 $margin $margin $margin;
}
.mat-card-actions {
.mat-button,
.mat-raised-button,
.mat-stroked-button {
margin: 0 8px;
}
}
// HEADER STYLES
.mat-card-header {
display: flex;
flex-direction: row;
.mat-card-title {
margin-bottom: 12px;
}
}
.mat-card-header-text {
margin: 0 $padding;
}
.mat-card-avatar {
height: $header-size;
width: $header-size;
border-radius: 50%;
flex-shrink: 0;
// Makes `<img>` tags behave like `background-size: cover`. Not supported
// in IE, but we're using it as a progressive enhancement.
object-fit: cover;
}
// TITLE-GROUP STYLES
.mat-card-title-group {
display: flex;
justify-content: space-between;
}
.mat-card-sm-image {
width: 80px;
height: 80px;
}
.mat-card-md-image {
width: 112px;
height: 112px;
}
.mat-card-lg-image {
width: 152px;
height: 152px;
}
// This should normally also extend the `%mat-card-title-img`, but in order to avoid breaking
// changes, we need to keep the horizontal margin reversion for now.
// See: https://github.com/angular/components/issues/12203
.mat-card-xl-image {
width: 240px;
height: 240px;
margin: -8px;
// Special treatment inside title group in order to fix the media areas inside of a title-group.
// This can be removed once #12203 has been addressed.
.mat-card-title-group > & {
// As per Material Design specifications, the images exceed the *top* content-box and take
// up some space. The margin below is necessary because otherwise space of the actual card
// content will be overlapped.
margin: -8px 0 8px;
}
}
// MEDIA QUERIES
@media (variables.$xsmall) {
.mat-card-title-group {
margin: 0;
}
.mat-card-xl-image {
margin-left: 0;
margin-right: 0;
}
}
// FIRST/LAST CHILD ADJUSTMENTS
// top els in mat-card-content and mat-card can't have their default margin-tops (e.g. <p> tags)
// or they'll incorrectly add to card's top padding
.mat-card > :first-child, .mat-card-content > :first-child {
margin-top: 0;
}
// last els in mat-card-content and mat-card can't have their default margin-bottoms (e.g. <p> tags)
// or they'll incorrectly add to card's bottom padding
.mat-card > :last-child:not(.mat-card-footer),
.mat-card-content > :last-child:not(.mat-card-footer) {
margin-bottom: 0;
}
// if main image is on top, need to place it flush against top
// (by stripping card's default padding)
.mat-card-image:first-child {
margin-top: -$padding;
border-top-left-radius: inherit;
border-top-right-radius: inherit;
}
// actions panel on bottom should be 8px from bottom of card
// so must strip 16px from default card padding
.mat-card > .mat-card-actions:last-child {
margin-bottom: -8px;
padding-bottom: 0;
}
// actions panel should always be 8px from sides,
// so the first button in the actions panel can't add its own margins
.mat-card-actions {
&:not(.mat-card-actions-align-end) {
.mat-button,
.mat-raised-button,
.mat-stroked-button {
&:first-child {
margin-left: 0;
margin-right: 0;
}
}
}
}
.mat-card-actions-align-end {
.mat-button,
.mat-raised-button,
.mat-stroked-button {
&:last-child {
margin-left: 0;
margin-right: 0;
}
}
}
// should be 12px space between titles and subtitles generally
// default margin-bottom is 16px, so need to move lower title up 4px
.mat-card-title:not(:first-child), .mat-card-subtitle:not(:first-child) {
margin-top: -4px;
}
// should be 8px space between titles and subtitles in header
// default margin-bottom is 16px, so need to move subtitle in header up 4px
.mat-card-header .mat-card-subtitle:not(:first-child) {
margin-top: -8px;
}
// xl image should always have 16px on top.
// when it's the first el, it'll need to remove 8px from default card padding
.mat-card > .mat-card-xl-image:first-child {
margin-top: -8px;
}
// xl image should always have 16px on bottom
// when it's the last el, it'll need to remove 8px from default card padding
.mat-card > .mat-card-xl-image:last-child {
margin-bottom: -8px;
}