Skip to content

Commit af0d0f8

Browse files
committed
docs(material/card): add each appearance example
update the example to contain `elevated`, `outlined` & `filled` variants
1 parent 86651fe commit af0d0f8

File tree

6 files changed

+27
-9
lines changed

6 files changed

+27
-9
lines changed
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,11 @@
1+
<mat-card>
2+
<mat-card-content>Elevated</mat-card-content>
3+
</mat-card>
4+
15
<mat-card appearance="outlined">
2-
<mat-card-content>Simple card</mat-card-content>
6+
<mat-card-content>Outlined</mat-card-content>
37
</mat-card>
8+
9+
<mat-card appearance="filled">
10+
<mat-card-content>Filled</mat-card-content>
11+
</mat-card>

src/dev-app/card/BUILD.bazel

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ ng_project(
1515
"//:node_modules/@angular/forms",
1616
"//src/material/button",
1717
"//src/material/card",
18-
"//src/material/checkbox",
18+
"//src/material/radio",
1919
],
2020
)
2121

src/dev-app/card/card-demo.html

+5-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
<div class="demo-card-container">
2-
<mat-checkbox (change)="toggleAppearance()">Use outlined cards</mat-checkbox>
2+
<mat-radio-group (change)="appearance = $event.value">
3+
<mat-radio-button value="raised">Raised</mat-radio-button>
4+
<mat-radio-button value="outlined">Outlined</mat-radio-button>
5+
<mat-radio-button value="filled">Filled</mat-radio-button>
6+
</mat-radio-group>
37

48
<!-- TODO(jelbourn): re-add dividers and footers with progress bars once the MDC versions exist -->
59
<mat-card [appearance]="appearance">

src/dev-app/card/card-demo.scss

+4
Original file line numberDiff line numberDiff line change
@@ -16,3 +16,7 @@
1616
text-transform: uppercase;
1717
}
1818
}
19+
20+
mat-radio-group {
21+
margin-bottom: 10px;
22+
}

src/dev-app/card/card-demo.ts

+3-5
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,15 @@ import {ChangeDetectionStrategy, Component, ViewEncapsulation} from '@angular/co
1010
import {FormsModule} from '@angular/forms';
1111
import {MatButtonModule} from '@angular/material/button';
1212
import {MatCardAppearance, MatCardModule} from '@angular/material/card';
13-
import {MatCheckboxModule} from '@angular/material/checkbox';
13+
import {MatRadioModule} from '@angular/material/radio';
1414

1515
@Component({
1616
selector: 'card-demo',
1717
templateUrl: 'card-demo.html',
1818
styleUrl: 'card-demo.css',
1919
encapsulation: ViewEncapsulation.None,
20-
imports: [MatCardModule, MatButtonModule, MatCheckboxModule, FormsModule],
20+
standalone: true,
21+
imports: [MatCardModule, MatButtonModule, MatRadioModule, FormsModule],
2122
changeDetection: ChangeDetectionStrategy.OnPush,
2223
})
2324
export class CardDemo {
@@ -28,7 +29,4 @@ export class CardDemo {
2829
As of some one gently rapping, rapping at my chamber door.
2930
“’Tis some visitor,” I muttered, “tapping at my chamber door—
3031
Only this and nothing more.”`;
31-
toggleAppearance() {
32-
this.appearance = this.appearance == 'raised' ? 'outlined' : 'raised';
33-
}
3432
}

src/material/card/_card-theme.scss

+5-1
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,10 @@
9898
tokens-mat-outlined-card.$prefix,
9999
tokens-mat-outlined-card.get-density-tokens($theme)
100100
);
101+
@include token-utils.create-token-values-mixed(
102+
tokens-mat-filled-card.$prefix,
103+
tokens-mat-filled-card.get-density-tokens($theme)
104+
);
101105
@include token-utils.create-token-values-mixed(
102106
tokens-mat-card.$prefix,
103107
tokens-mat-card.get-density-tokens($theme)
@@ -126,7 +130,7 @@
126130
(
127131
namespace: tokens-mat-filled-card.$prefix,
128132
tokens: tokens-mat-filled-card.get-token-slots(),
129-
prefix: 'outlined-',
133+
prefix: 'filled-',
130134
)
131135
);
132136
}

0 commit comments

Comments
 (0)