I'm struggling with something in my Angular 5.x app, and hope someone can help...
I've got a component that has a mat-raised-button, and currently I've got some styling for it within the component's SCSS file:
button-themed {
background-color: black;
color: white;
border-color: red;
border-style: solid;
border-width: 1px;}
Everything looks fine that way. However, I now want to shift that styling up to some theme SCSS files I'm working on. How can I get the styling to apply when it's in my "red-theme.scss" or "blue-theme.scss" files?
(I'm looking to be able to dynamically swap between themes and want the button to adjust according to the theme)
UPDATE
I kicked the tires some more on custom theming, and am getting nowhere. What am I missing? Below is some quick test stuff I tossed together (I'm simply trying to get the button's border to change color so I can see that the process works).
settings.component.scss:
.test-button {
border-style: solid;
border-width: 1px;
}
settings.theme.scss:
@mixin test-theme($theme) {
$primary: map-get($theme, primary);
$warn: map-get($theme, warn);
.test-button {
background-color: mat-color($primary);
color: mat-color($warn);
border-color: mat-color($warn);
}
}
settings.component.html:
<button mat-raised-button class="test-button">TEST</button>
red-theme.scss:
$test-primary: mat-palette($mat-pink, 800, 300, 900);
$test-accent: mat-palette($mat-pink);
$test-warn: mat-palette($mat-indigo, 600);
$test-theme: mat-light-theme($test-primary, $test-accent, $test-warn);
styles.scss:
@import '~@angular/material/theming';
@import 'themes/color-palettes.scss';
@include mat-core();
@import 'app/pages/settings/settings.theme.scss';
@mixin custom-components-theme($theme) {
@include test-theme($theme);
}
@import 'themes/red-theme.scss';
.red-theme {
@include angular-material-theme($test-theme);
}
It compiles and my button displays, but there's no color change to the button's border (even though other Material components have changed color on the page). Can anyone help nudge me in the right direction?