Skip to content

Commit e528639

Browse files
committed
refactor: merge card tokens
1 parent bc410e0 commit e528639

File tree

11 files changed

+69
-273
lines changed

11 files changed

+69
-273
lines changed

src/material/card/BUILD.bazel

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,6 @@ sass_library(
1414
name = "m3",
1515
srcs = [
1616
"_m3-card.scss",
17-
"_m3-elevated-card.scss",
18-
"_m3-outlined-card.scss",
1917
],
2018
deps = [
2119
"//src/material/core/style:sass_utils",
@@ -27,8 +25,6 @@ sass_library(
2725
name = "m2",
2826
srcs = [
2927
"_m2-card.scss",
30-
"_m2-elevated-card.scss",
31-
"_m2-outlined-card.scss",
3228
],
3329
deps = [
3430
"//src/material/core/style:elevation",

src/material/card/_card-theme.scss

Lines changed: 0 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -6,22 +6,12 @@
66
@use '../core/typography/typography';
77
@use '../core/tokens/token-utils';
88
@use './m2-card';
9-
@use './m2-elevated-card';
10-
@use './m2-outlined-card';
119

1210
@mixin base($theme) {
1311
@if inspection.get-theme-version($theme) == 1 {
1412
@include _theme-from-tokens(inspection.get-theme-tokens($theme, base));
1513
} @else {
1614
@include sass-utils.current-selector-or-root() {
17-
@include token-utils.create-token-values-mixed(
18-
m2-elevated-card.$prefix,
19-
m2-elevated-card.get-unthemable-tokens()
20-
);
21-
@include token-utils.create-token-values-mixed(
22-
m2-outlined-card.$prefix,
23-
m2-outlined-card.get-unthemable-tokens()
24-
);
2515
@include token-utils.create-token-values-mixed(
2616
m2-card.$prefix,
2717
m2-card.get-unthemable-tokens()
@@ -35,14 +25,6 @@
3525
@include _theme-from-tokens(inspection.get-theme-tokens($theme, color));
3626
} @else {
3727
@include sass-utils.current-selector-or-root() {
38-
@include token-utils.create-token-values-mixed(
39-
m2-elevated-card.$prefix,
40-
m2-elevated-card.get-color-tokens($theme)
41-
);
42-
@include token-utils.create-token-values-mixed(
43-
m2-outlined-card.$prefix,
44-
m2-outlined-card.get-color-tokens($theme)
45-
);
4628
@include token-utils.create-token-values-mixed(
4729
m2-card.$prefix,
4830
m2-card.get-color-tokens($theme)
@@ -56,14 +38,6 @@
5638
@include _theme-from-tokens(inspection.get-theme-tokens($theme, typography));
5739
} @else {
5840
@include sass-utils.current-selector-or-root() {
59-
@include token-utils.create-token-values-mixed(
60-
m2-elevated-card.$prefix,
61-
m2-elevated-card.get-typography-tokens($theme)
62-
);
63-
@include token-utils.create-token-values-mixed(
64-
m2-outlined-card.$prefix,
65-
m2-outlined-card.get-typography-tokens($theme)
66-
);
6741
@include token-utils.create-token-values-mixed(
6842
m2-card.$prefix,
6943
m2-card.get-typography-tokens($theme)
@@ -77,14 +51,6 @@
7751
@include _theme-from-tokens(inspection.get-theme-tokens($theme, density));
7852
} @else {
7953
@include sass-utils.current-selector-or-root() {
80-
@include token-utils.create-token-values-mixed(
81-
m2-elevated-card.$prefix,
82-
m2-elevated-card.get-density-tokens($theme)
83-
);
84-
@include token-utils.create-token-values-mixed(
85-
m2-outlined-card.$prefix,
86-
m2-outlined-card.get-density-tokens($theme)
87-
);
8854
@include token-utils.create-token-values-mixed(
8955
m2-card.$prefix,
9056
m2-card.get-density-tokens($theme)
@@ -100,16 +66,6 @@
10066
namespace: m2-card.$prefix,
10167
tokens: m2-card.get-token-slots(),
10268
),
103-
(
104-
namespace: m2-elevated-card.$prefix,
105-
tokens: m2-elevated-card.get-token-slots(),
106-
prefix: 'elevated-',
107-
),
108-
(
109-
namespace: m2-outlined-card.$prefix,
110-
tokens: m2-outlined-card.get-token-slots(),
111-
prefix: 'outlined-',
112-
),
11369
);
11470
}
11571

@@ -141,14 +97,6 @@
14197
'Calls to Angular Material theme mixins with an M3 theme must be wrapped in a selector'
14298
);
14399
@if ($tokens != ()) {
144-
@include token-utils.create-token-values(
145-
m2-elevated-card.$prefix,
146-
map.get($tokens, m2-elevated-card.$prefix)
147-
);
148-
@include token-utils.create-token-values(
149-
m2-outlined-card.$prefix,
150-
map.get($tokens, m2-outlined-card.$prefix)
151-
);
152100
@include token-utils.create-token-values(
153101
m2-card.$prefix,
154102
map.get($tokens, m2-card.$prefix)

src/material/card/_m2-card.scss

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,29 @@
11
@use '../core/tokens/m2-utils';
22
@use '../core/theming/inspection';
33
@use '../core/style/sass-utils';
4+
@use '../core/style/elevation';
45

56
// The prefix used to generate the fully qualified name for tokens in this file.
67
$prefix: (mat, card);
78

89
// Tokens that can't be configured through Angular Material's current theming API,
910
// but may be in a future version of the theming API.
1011
@function get-unthemable-tokens() {
11-
@return ();
12+
@return (
13+
elevated-container-shape: 4px,
14+
outlined-container-shape: 4px,
15+
outlined-outline-width: 1px,
16+
);
1217
}
1318

1419
// Tokens that can be configured through Angular Material's color theming API.
1520
@function get-color-tokens($theme) {
1621
@return (
22+
elevated-container-color: inspection.get-theme-color($theme, background, card),
23+
elevated-container-elevation: elevation.get-box-shadow(1),
24+
outlined-container-color: inspection.get-theme-color($theme, background, card),
25+
outlined-container-elevation: elevation.get-box-shadow(0),
26+
outlined-outline-color: rgba(inspection.get-theme-color($theme, foreground, base), 0.12),
1727
subtitle-text-color: inspection.get-theme-color($theme, foreground, secondary-text),
1828
);
1929
}

src/material/card/_m2-elevated-card.scss

Lines changed: 0 additions & 51 deletions
This file was deleted.

src/material/card/_m2-outlined-card.scss

Lines changed: 0 additions & 52 deletions
This file was deleted.

src/material/card/_m3-card.scss

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
@use 'sass:map';
22
@use '../core/style/sass-utils';
33
@use '../core/tokens/m3-utils';
4+
@use '../core/style/elevation';
45

56
// The prefix used to generate the fully qualified name for tokens in this file.
67
$prefix: (mat, card);
@@ -15,10 +16,28 @@ $prefix: (mat, card);
1516
m3-utils.generate-typography-tokens($systems, title-text, title-large),
1617
m3-utils.generate-typography-tokens($systems, subtitle-text, title-medium),
1718
(
18-
subtitle-text-color: map.get($systems, md-sys-color, on-surface)
19-
)
19+
subtitle-text-color: map.get($systems, md-sys-color, on-surface),
20+
elevated-container-color: map.get($systems, md-sys-color, surface-container-low),
21+
elevated-container-elevation: map.get($systems, md-sys-elevation, level1),
22+
elevated-container-shape: map.get($systems, md-sys-shape, corner-medium),
23+
outlined-container-color: map.get($systems, md-sys-color, surface),
24+
outlined-container-elevation: map.get($systems, md-sys-elevation, level0),
25+
outlined-container-shape: map.get($systems, md-sys-shape, corner-medium),
26+
outlined-outline-color: map.get($systems, md-sys-color, outline-variant),
27+
outlined-outline-width: if($exclude-hardcoded, null, 1px),
28+
),
2029
);
2130

31+
$elevated-elevation: map.get($tokens, elevated-container-elevation);
32+
@if ($elevated-elevation != null) {
33+
$tokens: map.set($tokens, elevated-container-elevation, elevation.get-box-shadow($elevated-elevation));
34+
}
35+
36+
$outlined-elevation: map.get($tokens, outlined-container-elevation);
37+
@if ($outlined-elevation != null) {
38+
$tokens: map.set($tokens, outlined-container-elevation, elevation.get-box-shadow($outlined-elevation));
39+
}
40+
2241
@return m3-utils.namespace($prefix, $tokens, $token-slots);
2342
}
2443

src/material/card/_m3-elevated-card.scss

Lines changed: 0 additions & 27 deletions
This file was deleted.

src/material/card/_m3-outlined-card.scss

Lines changed: 0 additions & 28 deletions
This file was deleted.

0 commit comments

Comments
 (0)