Skip to content

Commit 18a4794

Browse files
mmalerbakara
authored andcommitted
demo: add dark theme to demo app (#4479)
1 parent 2c0506c commit 18a4794

File tree

4 files changed

+36
-0
lines changed

4 files changed

+36
-0
lines changed

src/demo-app/demo-app/demo-app.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
</button>
2626
<div class="demo-toolbar">
2727
<h1>Angular Material Demos</h1>
28+
<button md-button (click)="dark = !dark">{{dark ? 'Light' : 'Dark'}} theme</button>
2829
<button md-button (click)="toggleFullscreen()" title="Toggle fullscreen">
2930
Fullscreen
3031
</button>

src/demo-app/demo-app/demo-app.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,14 @@ export class Home {}
1515
selector: 'demo-app',
1616
templateUrl: 'demo-app.html',
1717
styleUrls: ['demo-app.css'],
18+
host: {
19+
'[class.unicorn-dark-theme]': 'dark',
20+
},
1821
encapsulation: ViewEncapsulation.None,
1922
})
2023
export class DemoApp {
24+
dark = false;
25+
2126
navItems = [
2227
{name: 'Autocomplete', route: 'autocomplete'},
2328
{name: 'Button', route: 'button'},

src/demo-app/index.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
<link rel="icon" type="image/x-icon" href="favicon.ico">
1010
<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
1111
<link href="dist/packages/material/core/theming/prebuilt/indigo-pink.css" rel="stylesheet">
12+
<link href="theme.css" rel="stylesheet">
1213

1314
<!-- FontAwesome for md-icon demo. -->
1415
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.5.0/css/font-awesome.min.css">

src/demo-app/theme.scss

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
@import '../../dist/packages/material/core/theming/all-theme';
2+
// Plus imports for other components in your app.
3+
4+
// Include the common styles for Angular Material. We include this here so that you only
5+
// have to load a single css file for Angular Material in your app.
6+
// **Be sure that you only ever include this mixin once!**
7+
@include mat-core();
8+
9+
// Define the default theme (same as the example above).
10+
$candy-app-primary: mat-palette($mat-indigo);
11+
$candy-app-accent: mat-palette($mat-pink, A200, A100, A400);
12+
$candy-app-theme: mat-light-theme($candy-app-primary, $candy-app-accent);
13+
14+
// Include the default theme styles.
15+
@include angular-material-theme($candy-app-theme);
16+
17+
18+
// Define an alternate dark theme.
19+
$dark-primary: mat-palette($mat-blue-grey);
20+
$dark-accent: mat-palette($mat-amber, A200, A100, A400);
21+
$dark-warn: mat-palette($mat-deep-orange);
22+
$dark-theme: mat-dark-theme($dark-primary, $dark-accent, $dark-warn);
23+
24+
// Include the alternative theme styles inside of a block with a CSS class. You can make this
25+
// CSS class whatever you want. In this example, any component inside of an element with
26+
// `.unicorn-dark-theme` will be affected by this alternate dark theme instead of the default theme.
27+
.unicorn-dark-theme {
28+
@include angular-material-theme($dark-theme);
29+
}

0 commit comments

Comments
 (0)