forked from angular/components
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(material/card): support
filled
variant
this commit add `filled` variant for material card which provides subtle seperation from background and has less emphasis than elevated or outlined cards fixes angular#29840
- Loading branch information
Showing
8 changed files
with
155 additions
and
4 deletions.
There are no files selected for viewing
This file contains 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 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 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 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 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,81 @@ | ||
@use '../../../style/elevation'; | ||
@use '../../../theming/inspection'; | ||
@use '../../../style/sass-utils'; | ||
@use '../../token-definition'; | ||
|
||
// The prefix used to generate the fully qualified name for tokens in this file. | ||
$prefix: (mdc, filled-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 = | ||
// ============================================================================================= | ||
// Angular Material's card is not an interactive element, and therefore does not support states. | ||
disabled-container-elevation: null, | ||
disabled-outline-color: null, | ||
disabled-outline-opacity: null, | ||
dragged-container-elevation: null, | ||
dragged-outline-color: null, | ||
dragged-state-layer-color: null, | ||
dragged-state-layer-opacity: null, | ||
focus-container-elevation: null, | ||
focus-outline-color: null, | ||
focus-state-layer-color: null, | ||
focus-state-layer-opacity: null, | ||
hover-container-elevation: null, | ||
hover-outline-color: null, | ||
hover-state-layer-color: null, | ||
hover-state-layer-opacity: null, | ||
pressed-container-elevation: null, | ||
pressed-outline-color: null, | ||
pressed-state-layer-color: null, | ||
pressed-state-layer-opacity: null, | ||
container-shadow-color: 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($theme) { | ||
$elevation: inspection.get-theme-color($theme, foreground, elevation); | ||
|
||
@return ( | ||
// The background color of the card. | ||
container-color: inspection.get-theme-color($theme, background, card), | ||
container-elevation: elevation.get-box-shadow(0), | ||
); | ||
} | ||
|
||
// Tokens that can be configured through Angular Material's typography theming API. | ||
@function get-typography-tokens($theme) { | ||
@return (); | ||
} | ||
|
||
// Tokens that can be configured through Angular Material's density theming API. | ||
@function get-density-tokens($theme) { | ||
@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 sass-utils.deep-merge-all( | ||
get-unthemable-tokens(), | ||
get-color-tokens(token-definition.$placeholder-color-config), | ||
get-typography-tokens(token-definition.$placeholder-typography-config), | ||
get-density-tokens(token-definition.$placeholder-density-config) | ||
); | ||
} |
This file contains 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 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,22 @@ | ||
@use 'sass:map'; | ||
@use '../../../style/elevation'; | ||
@use '../../token-definition'; | ||
|
||
// The prefix used to generate the fully qualified name for tokens in this file. | ||
$prefix: (mdc, filled-card); | ||
|
||
/// Generates the tokens for MDC filled-card | ||
/// @param {Map} $systems The MDC system tokens | ||
/// @param {Boolean} $exclude-hardcoded Whether to exclude hardcoded token values | ||
/// @param {Map} $token-slots Possible token slots | ||
/// @return {Map} A set of tokens for the MDC filled-card | ||
@function get-tokens($systems, $exclude-hardcoded, $token-slots) { | ||
$tokens: token-definition.get-mdc-tokens('filled-card', $systems, $exclude-hardcoded); | ||
$elevation: map.get($tokens, container-elevation); | ||
|
||
@if ($elevation != null) { | ||
$tokens: map.set($tokens, container-elevation, elevation.get-box-shadow($elevation)); | ||
} | ||
|
||
@return token-definition.namespace-tokens($prefix, $tokens, $token-slots); | ||
} |
This file contains 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