Skip to content
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

fix(material/badge): content incorrectly truncated in M3 #29854

Merged
merged 1 commit into from
Oct 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions src/material/badge/badge.scss
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,11 @@ $large-size: $default-size + 6;
// * `container-size` token - In M2 the token is emitted as `unset` to preserve the legacy
// behavior while in M3 it targets `min-width` and `min-height` which allows the badge to
// grow with the content.
width: token-utils.get-token-variable($legacy-size-var-name, $fallback: unset);
height: token-utils.get-token-variable($legacy-size-var-name, $fallback: unset);
min-width: token-utils.get-token-variable($size-var-name, $fallback: unset);
min-height: token-utils.get-token-variable($size-var-name, $fallback: unset);
line-height: token-utils.get-token-variable($legacy-size-var-name);
@include token-utils.create-token-slot(width, $legacy-size-var-name);
@include token-utils.create-token-slot(height, $legacy-size-var-name);
@include token-utils.create-token-slot(min-width, $size-var-name);
@include token-utils.create-token-slot(min-height, $size-var-name);
@include token-utils.create-token-slot(line-height, '#{$prefix}line-height');
@include token-utils.create-token-slot(padding, '#{$prefix}container-padding');
@include token-utils.create-token-slot(font-size, '#{$prefix}text-size');
@include token-utils.create-token-slot(margin, '#{$prefix}container-offset');
Expand Down
15 changes: 12 additions & 3 deletions src/material/core/tokens/m2/mat/_badge.scss
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,19 @@
@use '../../../theming/inspection';
@use '../../../style/sass-utils';

$_default-size: 22px;
$_small-size: $_default-size - 6px;
$_large-size: $_default-size + 6px;

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

// 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() {
$default-size: 22px;
$small-size: $default-size - 6;
$large-size: $default-size + 6;
$default-size: $_default-size;
$small-size: $_small-size;
$large-size: $_large-size;

@return (
container-shape: 50%,
Expand Down Expand Up @@ -77,10 +81,15 @@ $prefix: (mat, badge);

@return (
text-font: inspection.get-theme-typography($theme, body-2, font-family),
line-height: $_default-size,
text-size: $base-size,
text-weight: 600,

small-size-text-size: $base-size * 0.75,
small-size-line-height: $_small-size,

large-size-text-size: $base-size * 2,
large-size-line-height: $_large-size,
);
}

Expand Down
9 changes: 6 additions & 3 deletions src/material/core/tokens/m3/mat/_badge.scss
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,11 @@ $prefix: (mat, badge);
small-size-text-size: token-definition.hardcode(0, $exclude-hardcoded),
container-shape: map.get($systems, md-sys-shape, corner-full),
container-size: token-definition.hardcode(16px, $exclude-hardcoded),
legacy-container-size: token-definition.hardcode(16px, $exclude-hardcoded),
legacy-small-size-container-size: token-definition.hardcode(16px, $exclude-hardcoded),
line-height: token-definition.hardcode(16px, $exclude-hardcoded),
legacy-container-size: token-definition.hardcode(unset, $exclude-hardcoded),
legacy-small-size-container-size: token-definition.hardcode(unset, $exclude-hardcoded),
small-size-container-size: token-definition.hardcode(6px, $exclude-hardcoded),
small-size-line-height: token-definition.hardcode(6px, $exclude-hardcoded),
container-padding: token-definition.hardcode(0 4px, $exclude-hardcoded),
small-size-container-padding: token-definition.hardcode(0, $exclude-hardcoded),
container-offset: token-definition.hardcode(-12px 0, $exclude-hardcoded),
Expand All @@ -37,11 +39,12 @@ $prefix: (mat, badge);

// This size isn't in the M3 spec so we emit the same values as for `medium`.
large-size-container-size: token-definition.hardcode(16px, $exclude-hardcoded),
large-size-line-height: token-definition.hardcode(16px, $exclude-hardcoded),
large-size-container-offset: token-definition.hardcode(-12px 0, $exclude-hardcoded),
large-size-container-overlap-offset: token-definition.hardcode(-12px, $exclude-hardcoded),
large-size-text-size: map.get($systems, md-sys-typescale, label-small-size),
large-size-container-padding: token-definition.hardcode(0 4px, $exclude-hardcoded),
legacy-large-size-container-size: token-definition.hardcode(16px, $exclude-hardcoded),
legacy-large-size-container-size: token-definition.hardcode(unset, $exclude-hardcoded),
), (
primary: (
background-color: map.get($systems, md-sys-color, primary),
Expand Down
Loading