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-experimental/theming): implement M3 badge #28460

Merged
merged 1 commit into from
Jan 23, 2024

Conversation

crisbeto
Copy link
Member

Aligns the badge with the M3 spec. This required a few issues to be fixed:

  1. The badge was being sized with width and height. This is incorrect, because it prevents the badge from scaling with the text. I've resolved it while keeping the old behavior by introducing new tokens that target min-width and min-height while the old ones still target width and height.
  2. The badge was being positioned purely with top, bottom, left and right. This is problematic, because it anchors the badge to the specific point in the host, causing the content to grow inwards instead of outwards. I've fixed it by using the opposite dimensions to position the badge (e.g. bottom: 100% instead of top: -20px) and then using a negative margin to offset the badge from there. This approach also has the advantage of producing less CSS.
  3. The badge didn't have a padding which made the content look off if it's more than one character.

@crisbeto crisbeto added the target: patch This PR is targeted for the next patch release label Jan 22, 2024
@crisbeto crisbeto requested a review from andrewseguin January 22, 2024 12:45
@mmalerba mmalerba added the dev-app preview When applied, previews of the dev-app are deployed to Firebase label Jan 22, 2024
Copy link
Contributor

@mmalerba mmalerba left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Aligns the badge with the M3 spec. This required a few issues to be fixed:
1. The badge was being sized with `width` and `height`. This is incorrect, because it prevents the badge from scaling with the text. I've resolved it while keeping the old behavior by introducing new tokens that target `min-width` and `min-height` while the old ones still target `width` and `height`.
2. The badge was being positioned purely with `top`, `bottom`, `left` and `right`. This is problematic, because it anchors the badge to the specific point in the host, causing the content to grow inwards instead of outwards. I've fixed it by using the opposite dimensions to position the badge (e.g. `bottom: 100%` instead of `top: -20px`) and then using a negative margin to offset the badge from there. This approach also has the advantage of producing less CSS.
3. The badge didn't have a padding which made the content look off if it's more than one character.
Copy link

Deployed dev-app for c546d9f to: https://ng-dev-previews-comp--pr-angular-components-28460-dev-zakecw4e.web.app

Note: As new commits are pushed to this pull request, this link is updated after the preview is rebuilt.

@crisbeto crisbeto self-assigned this Jan 23, 2024
@crisbeto crisbeto added action: merge The PR is ready for merge by the caretaker target: minor This PR is targeted for the next minor release and removed target: patch This PR is targeted for the next patch release labels Jan 23, 2024
@crisbeto crisbeto merged commit 056e222 into angular:main Jan 23, 2024
26 of 28 checks passed
@angular-automatic-lock-bot
Copy link

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Feb 23, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
action: merge The PR is ready for merge by the caretaker dev-app preview When applied, previews of the dev-app are deployed to Firebase target: minor This PR is targeted for the next minor release
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants