-
Notifications
You must be signed in to change notification settings - Fork 6.8k
fix(material/card): refactor to depend on @angular/material/core/tokens #26674
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
8ba2ae9
fix(material/card): refactor to depend on @angular/material/core/tokens
mmalerba 0b715da
add card tokens with placeholder values
mmalerba 981c565
add styles for token slots and values to card
mmalerba 76d82b6
fill in real token values and fix card appearance
mmalerba 3c9a542
address feedback
mmalerba 481da02
add custom tokens for Angular Material only features
mmalerba File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
@use 'sass:map'; | ||
@use '../../token-utils'; | ||
@use '../../../theming/theming'; | ||
@use '../../../typography/typography-utils'; | ||
|
||
// The prefix used to generate the fully qualified name for tokens in this file. | ||
$prefix: (mat, card); | ||
|
||
// Tokens that can't be configured through Angular Material's current theming API, | ||
// but may be in a future version of the theming API. | ||
@function get-unthemable-tokens() { | ||
@return (); | ||
} | ||
|
||
// Tokens that can be configured through Angular Material's color theming API. | ||
@function get-color-tokens($config) { | ||
$foreground: map.get($config, foreground); | ||
|
||
@return ( | ||
// Text color of the card's subtitle. | ||
subtitle-text-color: theming.get-color-from-palette($foreground, secondary-text), | ||
); | ||
} | ||
|
||
// Tokens that can be configured through Angular Material's typography theming API. | ||
@function get-typography-tokens($config) { | ||
@return ( | ||
// Font family of the card's title. | ||
title-text-font: typography-utils.font-family($config, headline-6) | ||
or typography-utils.font-family($config), | ||
// Line height of the card's title. | ||
title-text-line-height: typography-utils.line-height($config, headline-6), | ||
// Font size of the card's title. | ||
title-text-size: typography-utils.font-size($config, headline-6), | ||
// Letter spacing of the card's title. | ||
title-text-tracking: typography-utils.letter-spacing($config, headline-6), | ||
// Font weight of the card's title. | ||
title-text-weight: typography-utils.font-weight($config, headline-6), | ||
// Font family of the card's subtitle. | ||
subtitle-text-font: typography-utils.font-family($config, subtitle-2) | ||
or typography-utils.font-family($config), | ||
// Line height of the card's subtitle. | ||
subtitle-text-line-height: typography-utils.line-height($config, subtitle-2), | ||
// Font size of the card's subtitle. | ||
subtitle-text-size: typography-utils.font-size($config, subtitle-2), | ||
// Letter spacing of the card's subtitle. | ||
subtitle-text-tracking: typography-utils.letter-spacing($config, subtitle-2), | ||
// Font weight of the card's subtitle. | ||
subtitle-text-weight: typography-utils.font-weight($config, subtitle-2), | ||
); | ||
} | ||
|
||
// Tokens that can be configured through Angular Material's density theming API. | ||
@function get-density-tokens($config) { | ||
@return (); | ||
} | ||
|
||
// Combines the tokens generated by the above functions into a single map with placeholder values. | ||
// This is used to create token slots. | ||
@function get-token-slots() { | ||
@return token-utils.merge-all( | ||
get-unthemable-tokens(), | ||
get-color-tokens(token-utils.$placeholder-color-config), | ||
get-typography-tokens(token-utils.$placeholder-typography-config), | ||
get-density-tokens(token-utils.$placeholder-density-config) | ||
); | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
@use 'sass:map'; | ||
@use '../../../theming/theming'; | ||
@use '../../token-utils'; | ||
|
||
// The prefix used to generate the fully qualified name for tokens in this file. | ||
$prefix: (mdc, elevated-card); | ||
|
||
// Tokens that can't be configured through Angular Material's current theming API, | ||
// but may be in a future version of the theming API. | ||
// | ||
// Tokens that are available in MDC, but not used in Angular Material should be mapped to `null`. | ||
// `null` indicates that we are intentionally choosing not to emit a slot or value for the token in | ||
// our CSS. | ||
@function get-unthemable-tokens() { | ||
@return ( | ||
// The border-radius of the card. | ||
container-shape: 4px, | ||
// ============================================================================================= | ||
// = TOKENS NOT USED IN ANGULAR MATERIAL = | ||
// ============================================================================================= | ||
// TODO(mmalerba): The elevation tokens don't seem to work currently. | ||
// Should work with MDC to figure out what's wrong. | ||
container-elevation: null, | ||
container-shadow-color: null, | ||
// Angular Material's card is not an interactive element, and therefore does not support states. | ||
disabled-container-color: null, | ||
disabled-container-elevation: null, | ||
disabled-container-opacity: null, | ||
dragged-container-elevation: null, | ||
dragged-state-layer-color: null, | ||
dragged-state-layer-opacity: null, | ||
focus-container-elevation: null, | ||
focus-state-layer-color:null, | ||
focus-state-layer-opacity: null, | ||
hover-container-elevation: null, | ||
hover-state-layer-color: null, | ||
hover-state-layer-opacity: null, | ||
pressed-container-elevation: null, | ||
pressed-state-layer-color: null, | ||
pressed-state-layer-opacity: null, | ||
// Angular Material does not currently support surface tint. | ||
container-surface-tint-layer-color: null, | ||
// MDC does not seem to use these tokens. | ||
icon-color: null, | ||
icon-size: null, | ||
); | ||
} | ||
|
||
// Tokens that can be configured through Angular Material's color theming API. | ||
@function get-color-tokens($config) { | ||
$background: map.get($config, background); | ||
|
||
@return ( | ||
// The background color of the card. | ||
container-color: theming.get-color-from-palette($background, card), | ||
); | ||
} | ||
|
||
// Tokens that can be configured through Angular Material's typography theming API. | ||
@function get-typography-tokens($config) { | ||
@return (); | ||
} | ||
|
||
// Tokens that can be configured through Angular Material's density theming API. | ||
@function get-density-tokens($config) { | ||
@return (); | ||
} | ||
|
||
// Combines the tokens generated by the above functions into a single map with placeholder values. | ||
// This is used to create token slots. | ||
@function get-token-slots() { | ||
@return token-utils.merge-all( | ||
get-unthemable-tokens(), | ||
get-color-tokens(token-utils.$placeholder-color-config), | ||
get-typography-tokens(token-utils.$placeholder-typography-config), | ||
get-density-tokens(token-utils.$placeholder-density-config) | ||
); | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.