Skip to content

Commit 158f0af

Browse files
committed
refactor(theme): align AngularJS Material theme with Angular Material theme
- switch to white instead of grey background - don't import theme styles we don't need, saves 4 KB minified
1 parent 3f13c90 commit 158f0af

File tree

3 files changed

+37
-1
lines changed

3 files changed

+37
-1
lines changed

src/_theme.scss

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,25 @@ $app-accent: mat-palette($mat-green);
1111
// The warn palette is optional (defaults to red).
1212
$app-warn: mat-palette($mat-red);
1313

14+
// Override the grey background with white
15+
$mat-light-theme-background: (
16+
status-bar: map_get($mat-grey, 300),
17+
app-bar: map_get($mat-grey, 100),
18+
background: map_get($mat-grey, A100),
19+
hover: rgba(black, 0.04),
20+
card: white,
21+
dialog: white,
22+
disabled-button: rgba(black, 0.12),
23+
raised-button: white,
24+
focused-button: $dark-focused,
25+
selected-button: map_get($mat-grey, 300),
26+
selected-disabled-button: map_get($mat-grey, 400),
27+
disabled-button-toggle: map_get($mat-grey, 200),
28+
unselected-chip: map_get($mat-grey, 300),
29+
disabled-list-option: map_get($mat-grey, 200),
30+
tooltip: map_get($mat-grey, 700),
31+
);
32+
1433
// Create the theme object (a Sass map containing all of the palettes).
1534
$app-theme: mat-light-theme($app-primary, $app-accent, $app-warn);
1635

src/app/angularjs/app-angularjs.module.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,18 @@ import { bootstrapAngular } from './bootstrap-module';
1313

1414
const downgradedModule = downgradeModule(bootstrapAngular);
1515

16+
const configFunction = $mdThemingProvider => {
17+
$mdThemingProvider
18+
.theme('default')
19+
.primaryPalette('indigo')
20+
.accentPalette('green', { default: '500' })
21+
.backgroundPalette('grey', { default: 'A100' });
22+
};
23+
configFunction.$inject = ['$mdThemingProvider'];
24+
1625
export const appAngularjsModule = angular
1726
.module('AngularJSApp', ['ngMaterial', 'ngMessages', 'templates', downgradedModule])
27+
.config(configFunction)
1828
.component(appAngularJSComponent.selector, appAngularJSComponent)
1929
.component(versionStampComponent.selector, versionStampComponent)
2030
.component(tabsComponent.selector, tabsComponent)

src/styles.scss

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,14 @@
88
// Include theme styles for core and each component used in your app.
99
// Alternatively, you can import and @include the theme mixins for each component
1010
// that you are using.
11-
@include angular-material-theme($app-theme);
11+
@include mat-core-theme($app-theme);
12+
@include mat-button-theme($app-theme);
13+
@include mat-icon-theme($app-theme);
14+
@include mat-toolbar-theme($app-theme);
15+
@include mat-divider-theme($app-theme);
16+
@include mat-expansion-panel-theme($app-theme);
17+
@include mat-progress-spinner-theme($app-theme);
18+
@include mat-tabs-theme($app-theme);
1219

1320
/* You can add global styles to this file, and also import other style files */
1421

0 commit comments

Comments
 (0)