|
1 |
| -@use 'sass:map'; |
2 |
| -@use '@material/card' as mdc-card; |
3 |
| -@use '@material/card/elevated-card-theme' as mdc-elevated-card-theme; |
4 |
| -@use '@material/card/outlined-card-theme' as mdc-outlined-card-theme; |
5 |
| -@use '@material/theme/custom-properties' as mdc-custom-properties; |
6 | 1 | @use '../core/tokens/token-utils';
|
7 | 2 | @use '../core/tokens/m2/mat/card' as tokens-mat-card;
|
8 | 3 | @use '../core/tokens/m2/mdc/elevated-card' as tokens-mdc-elevated-card;
|
9 | 4 | @use '../core/tokens/m2/mdc/outlined-card' as tokens-mdc-outlined-card;
|
10 | 5 |
|
11 |
| -// TODO(jelbourn): move header and title-group styles to their own files. |
12 |
| -@include mdc-custom-properties.configure($emit-fallback-values: false, $emit-fallback-vars: false) { |
13 |
| - $mdc-elevated-card-token-slots: tokens-mdc-elevated-card.get-token-slots(); |
14 |
| - $mdc-outlined-card-token-slots: tokens-mdc-outlined-card.get-token-slots(); |
| 6 | +// Size of the `mat-card-header` region custom to Angular Material. |
| 7 | +$mat-card-header-size: 40px !default; |
| 8 | + |
| 9 | +// Default padding for text content within a card. |
| 10 | +$mat-card-default-padding: 16px !default; |
15 | 11 |
|
16 |
| - // Add the MDC card static styles. |
17 |
| - @include mdc-card.static-styles(); |
| 12 | +.mat-mdc-card { |
| 13 | + display: flex; |
| 14 | + flex-direction: column; |
| 15 | + box-sizing: border-box; |
| 16 | + position: relative; |
| 17 | + border-style: solid; |
| 18 | + border-width: 0; |
| 19 | + |
| 20 | + @include token-utils.use-tokens( |
| 21 | + tokens-mdc-elevated-card.$prefix, |
| 22 | + tokens-mdc-elevated-card.get-token-slots() |
| 23 | + ) { |
| 24 | + @include token-utils.create-token-slot(background-color, container-color); |
| 25 | + @include token-utils.create-token-slot(border-color, container-color); |
| 26 | + @include token-utils.create-token-slot(border-radius, container-shape); |
| 27 | + @include token-utils.create-token-slot(box-shadow, container-elevation); |
| 28 | + } |
18 | 29 |
|
19 |
| - .mat-mdc-card { |
20 |
| - // Add the official slots for the MDC elevated-card. |
21 |
| - @include mdc-elevated-card-theme.theme-styles(map.merge($mdc-elevated-card-token-slots, ( |
22 |
| - // MDC emits the box-shadow on .mdc-card, so the full selector would be |
23 |
| - // `.mat-mdc-card .mdc-card` which is incorrect. We emit the elevation slot ourselves instead. |
24 |
| - container-elevation: null, |
25 |
| - container-shadow-color: null, |
26 |
| - ))); |
| 30 | + // Transparent card border for high-contrast mode. |
| 31 | + &::after { |
| 32 | + position: absolute; |
| 33 | + top: 0; |
| 34 | + left: 0; |
| 35 | + width: 100%; |
| 36 | + height: 100%; |
| 37 | + border: solid 1px transparent; |
| 38 | + content: ''; |
| 39 | + display: block; |
| 40 | + pointer-events: none; |
| 41 | + box-sizing: border-box; |
27 | 42 |
|
28 |
| - // Emit the elevation slot directly on .mat-mdc-card. |
29 | 43 | @include token-utils.use-tokens(
|
30 |
| - tokens-mdc-elevated-card.$prefix, $mdc-elevated-card-token-slots) { |
31 |
| - @include token-utils.create-token-slot(box-shadow, container-elevation); |
| 44 | + tokens-mdc-elevated-card.$prefix, |
| 45 | + tokens-mdc-elevated-card.get-token-slots() |
| 46 | + ) { |
| 47 | + @include token-utils.create-token-slot(border-radius, container-shape); |
32 | 48 | }
|
33 | 49 | }
|
| 50 | +} |
34 | 51 |
|
35 |
| - .mat-mdc-card-outlined { |
36 |
| - // Add the official slots for the MDC outlined-card. |
37 |
| - @include mdc-outlined-card-theme.theme-styles(map.merge($mdc-outlined-card-token-slots, ( |
38 |
| - // MDC emits the box-shadow on .mdc-card, so the full selector would be |
39 |
| - // `.mat-mdc-card-outlined .mdc-card` which is incorrect. We emit the elevation slot ourselves |
40 |
| - // instead. |
41 |
| - container-elevation: null, |
42 |
| - container-shadow-color: null, |
43 |
| - ))); |
44 |
| - |
45 |
| - // Emit the elevation slot directly on .mat-mdc-card-outlined. |
46 |
| - @include token-utils.use-tokens( |
47 |
| - tokens-mdc-outlined-card.$prefix, $mdc-outlined-card-token-slots) { |
48 |
| - @include token-utils.create-token-slot(box-shadow, container-elevation); |
49 |
| - } |
| 52 | +.mat-mdc-card-outlined { |
| 53 | + @include token-utils.use-tokens( |
| 54 | + tokens-mdc-outlined-card.$prefix, |
| 55 | + tokens-mdc-outlined-card.get-token-slots() |
| 56 | + ) { |
| 57 | + @include token-utils.create-token-slot(background-color, container-color); |
| 58 | + @include token-utils.create-token-slot(border-radius, container-shape); |
| 59 | + @include token-utils.create-token-slot(border-width, outline-width); |
| 60 | + @include token-utils.create-token-slot(border-color, outline-color); |
| 61 | + @include token-utils.create-token-slot(box-shadow, container-elevation); |
50 | 62 | }
|
51 | 63 |
|
52 |
| - // Add slots for custom Angular Material card tokens. |
53 |
| - @include token-utils.use-tokens(tokens-mat-card.$prefix, tokens-mat-card.get-token-slots()) { |
54 |
| - .mat-mdc-card-title { |
55 |
| - @include token-utils.create-token-slot(font-family, title-text-font); |
56 |
| - @include token-utils.create-token-slot(line-height, title-text-line-height); |
57 |
| - @include token-utils.create-token-slot(font-size, title-text-size); |
58 |
| - @include token-utils.create-token-slot(letter-spacing, title-text-tracking); |
59 |
| - @include token-utils.create-token-slot(font-weight, title-text-weight); |
60 |
| - } |
| 64 | + // Outlined card already displays border in high-contrast mode. |
| 65 | + // Overwriting styles set above to remove a duplicate border. |
| 66 | + &::after { |
| 67 | + border: none; |
| 68 | + } |
| 69 | +} |
61 | 70 |
|
62 |
| - .mat-mdc-card-subtitle { |
63 |
| - @include token-utils.create-token-slot(color, subtitle-text-color); |
64 |
| - @include token-utils.create-token-slot(font-family, subtitle-text-font); |
65 |
| - @include token-utils.create-token-slot(line-height, subtitle-text-line-height); |
66 |
| - @include token-utils.create-token-slot(font-size, subtitle-text-size); |
67 |
| - @include token-utils.create-token-slot(letter-spacing, subtitle-text-tracking); |
68 |
| - @include token-utils.create-token-slot(font-weight, subtitle-text-weight); |
69 |
| - } |
| 71 | +.mdc-card__media { |
| 72 | + position: relative; |
| 73 | + box-sizing: border-box; |
| 74 | + background-repeat: no-repeat; |
| 75 | + background-position: center; |
| 76 | + background-size: cover; |
| 77 | + |
| 78 | + &::before { |
| 79 | + display: block; |
| 80 | + content: ''; |
| 81 | + } |
| 82 | + |
| 83 | + &:first-child { |
| 84 | + border-top-left-radius: inherit; |
| 85 | + border-top-right-radius: inherit; |
| 86 | + } |
| 87 | + |
| 88 | + &:last-child { |
| 89 | + border-bottom-left-radius: inherit; |
| 90 | + border-bottom-right-radius: inherit; |
70 | 91 | }
|
71 | 92 | }
|
72 | 93 |
|
73 |
| -// Size of the `mat-card-header` region custom to Angular Material. |
74 |
| -$mat-card-header-size: 40px !default; |
| 94 | +.mat-mdc-card-actions { |
| 95 | + display: flex; |
| 96 | + flex-direction: row; |
| 97 | + align-items: center; |
| 98 | + box-sizing: border-box; |
| 99 | + min-height: 52px; |
| 100 | + padding: 8px; |
| 101 | +} |
75 | 102 |
|
76 |
| -// Default padding for text content within a card. |
77 |
| -$mat-card-default-padding: 16px !default; |
| 103 | +// Add slots for custom Angular Material card tokens. |
| 104 | +@include token-utils.use-tokens(tokens-mat-card.$prefix, tokens-mat-card.get-token-slots()) { |
| 105 | + .mat-mdc-card-title { |
| 106 | + @include token-utils.create-token-slot(font-family, title-text-font); |
| 107 | + @include token-utils.create-token-slot(line-height, title-text-line-height); |
| 108 | + @include token-utils.create-token-slot(font-size, title-text-size); |
| 109 | + @include token-utils.create-token-slot(letter-spacing, title-text-tracking); |
| 110 | + @include token-utils.create-token-slot(font-weight, title-text-weight); |
| 111 | + } |
78 | 112 |
|
79 |
| -.mat-mdc-card { |
80 |
| - position: relative; |
| 113 | + .mat-mdc-card-subtitle { |
| 114 | + @include token-utils.create-token-slot(color, subtitle-text-color); |
| 115 | + @include token-utils.create-token-slot(font-family, subtitle-text-font); |
| 116 | + @include token-utils.create-token-slot(line-height, subtitle-text-line-height); |
| 117 | + @include token-utils.create-token-slot(font-size, subtitle-text-size); |
| 118 | + @include token-utils.create-token-slot(letter-spacing, subtitle-text-tracking); |
| 119 | + @include token-utils.create-token-slot(font-weight, subtitle-text-weight); |
| 120 | + } |
81 | 121 | }
|
82 | 122 |
|
83 | 123 | // Title text and subtitles text within a card. MDC doesn't have pre-made title sections for cards.
|
|
0 commit comments