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(labs): remove unnecessary CSS duplication variables of components in labs #5701

Merged
merged 1 commit into from
Aug 27, 2024

Conversation

bre97-web
Copy link
Contributor

@bre97-web bre97-web commented Aug 25, 2024

I found that some components in the labs folder had duplicate CSS variables (includes badge, navigationbar, navigationtab, segmentedbutton) , like this:

image

After I compile the component style separately through sass:

npx sass ./labs/navigationbar/internal/navigation-bar-styles.scss ./o.css

image

This is because of unnecessary prefixes in these styles:

    @each $token, $value in $tokens {
      // We need to delete "var(--md-navigation-bar-#{$token}, "
      //--_#{$token}: var(--md-navigation-bar-#{$token}, #{$value});
      --_#{$token}: #{$value};
    }

After repair:

image

@asyncLiz
Copy link
Collaborator

This is working as intended. The custom properties with underscores are private internal details and not meant to be used directly. The prefixed component properties such as --md-badge-* are the public API surface.

@asyncLiz asyncLiz closed this Aug 26, 2024
@bre97-web
Copy link
Contributor Author

This is working as intended. The custom properties with underscores are private internal details and not meant to be used directly. The prefixed component properties such as --md-badge-* are the public API surface.

Sorry to bother you. I still don’t understand why --md-badge-* appears twice.

e.g.

--_size: var(--md-badge-size, var(--md-badge-size, 6px));

@asyncLiz
Copy link
Collaborator

I'm sorry, I didn't pay enough attention. You're right, there should only be one --md-* var.

@asyncLiz asyncLiz reopened this Aug 27, 2024
Copy link
Collaborator

@asyncLiz asyncLiz left a comment

Choose a reason for hiding this comment

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

Thanks for catching this, I missed it when adding the ability for tokens to return custom properties directly.

@asyncLiz asyncLiz changed the title fix: remove unnecessary CSS duplication variables of components in labs fix(labs): remove unnecessary CSS duplication variables of components in labs Aug 27, 2024
@copybara-service copybara-service bot merged commit 22e19c2 into material-components:main Aug 27, 2024
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants