Skip to content
This repository has been archived by the owner on Jan 13, 2025. It is now read-only.

Commit

Permalink
fix(button): Increase specifity of button icon's CSS class (#2242)
Browse files Browse the repository at this point in the history
Since we can't guarantee the order of CSS loading (MDC Button and Material Icons Font), we need to make icon-related classes a higher specificity than the .material-icons font CSS class.
  • Loading branch information
bwobrien authored Feb 13, 2018
1 parent 003381c commit f91d25e
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
2 changes: 1 addition & 1 deletion demos/button.html
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@
<title>Button - Material Components Catalog</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="icon" type="image/png" href="/images/logo_components_color_2x_web_48dp.png">
<link rel="stylesheet" href="/assets/button.css">
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Roboto+Mono">
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Roboto:300,400,500">
<link rel="stylesheet" href="https://fonts.googleapis.com/icon?family=Material+Icons">
<link rel="stylesheet" href="/assets/button.css">
<script src="/ready.js"></script>
<style>
.demo-wrapper {
Expand Down
12 changes: 8 additions & 4 deletions packages/mdc-button/mdc-button.scss
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,14 @@
@include mdc-button-container-fill-color(transparent);
@include mdc-button-ink-color(primary);
@include mdc-states(primary);

// The icon CSS class overrides styles defined in the .material-icons CSS
// class, which is loaded separately so the order of CSS definitions is not
// guaranteed. Therefore, increase specifity by nesting this class to ensure
// overrides apply.
.mdc-button__icon {
@include mdc-button__icon_;
}
}

.mdc-button--raised,
Expand Down Expand Up @@ -53,8 +61,4 @@
.mdc-button--dense {
@include mdc-button--dense_;
}

.mdc-button__icon {
@include mdc-button__icon_;
}
// postcss-bem-linter: end

0 comments on commit f91d25e

Please sign in to comment.