-
Notifications
You must be signed in to change notification settings - Fork 6.8k
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
update: add button to toggle theme in demo-app #3093
Changes from 3 commits
a3b9f8d
f981ce7
acfa1be
c285d15
6035a63
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,7 +8,6 @@ | |
section { | ||
display: flex; | ||
align-items: center; | ||
background-color: #f7f7f7; | ||
margin: 8px; | ||
} | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,41 +1,46 @@ | ||
<md-sidenav-container class="demo-root" fullscreen> | ||
<md-sidenav #start> | ||
<md-nav-list> | ||
<a *ngFor="let navItem of navItems" | ||
md-list-item | ||
(click)="start.close()" | ||
[routerLink]="[navItem.route]"> | ||
{{navItem.name}} | ||
</a> | ||
<!-- Theme class needs to be applied above sidenav-container to style content background. --> | ||
<div [class.demo-dark-theme]="isDarkTheme"> | ||
<md-sidenav-container class="demo-root" fullscreen> | ||
<md-sidenav #start> | ||
<md-nav-list> | ||
<a *ngFor="let navItem of navItems" | ||
md-list-item | ||
(click)="start.close()" | ||
[routerLink]="[navItem.route]"> | ||
{{navItem.name}} | ||
</a> | ||
|
||
<hr> | ||
<hr> | ||
|
||
<a md-list-item | ||
(click)="start.close()" | ||
[routerLink]="['baseline']"> | ||
Baseline | ||
</a> | ||
</md-nav-list> | ||
<button md-button (click)="start.close()">CLOSE</button> | ||
</md-sidenav> | ||
<div> | ||
<md-toolbar color="primary"> | ||
<button md-icon-button (click)="start.open()"> | ||
<md-icon class="md-24" >menu</md-icon> | ||
</button> | ||
<div class="demo-toolbar"> | ||
<h1>Angular Material Demos</h1> | ||
<button md-button (click)="toggleFullscreen()" title="Toggle fullscreen"> | ||
Fullscreen | ||
<a md-list-item | ||
(click)="start.close()" | ||
[routerLink]="['baseline']"> | ||
Baseline | ||
</a> | ||
</md-nav-list> | ||
<button md-button (click)="start.close()">CLOSE</button> | ||
</md-sidenav> | ||
<div> | ||
<md-toolbar color="primary"> | ||
<button md-icon-button (click)="start.open()"> | ||
<md-icon class="md-24" >menu</md-icon> | ||
</button> | ||
<button md-button (click)="root.dir = (root.dir == 'rtl' ? 'ltr' : 'rtl')" title="Toggle between RTL and LTR"> | ||
{{root.dir.toUpperCase()}} | ||
</button> | ||
</div> | ||
</md-toolbar> | ||
<div class="demo-toolbar"> | ||
<h1>Angular Material Demos</h1> | ||
<span class="demo-flex-fill"></span> | ||
<button md-button (click)="isDarkTheme = !isDarkTheme">Toggle Theme</button> | ||
<button md-button (click)="toggleFullscreen()" title="Toggle fullscreen"> | ||
Fullscreen | ||
</button> | ||
<button md-button (click)="root.dir = (root.dir == 'rtl' ? 'ltr' : 'rtl')" title="Toggle between RTL and LTR"> | ||
{{root.dir.toUpperCase()}} | ||
</button> | ||
</div> | ||
</md-toolbar> | ||
|
||
<div #root="$implicit" dir="ltr" class="demo-content"> | ||
<router-outlet></router-outlet> | ||
<div #root="$implicit" dir="ltr" class="demo-content"> | ||
<router-outlet></router-outlet> | ||
</div> | ||
</div> | ||
</div> | ||
</md-sidenav-container> | ||
</md-sidenav-container> | ||
</div> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,19 @@ | ||
// The default indigo-pink theme will load through the index file. This makes the SCSS build faster | ||
// since Sass doesn't need to build a "prebuilt" theme again. | ||
@import '../../lib/core/theming/all-theme'; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not sure how to make this work, the demo app cannot reach into the lib directory directly. Would be best to have
but the sass compiler expects this to be present during build but it is only there after build. Any other way to import this file dynamically? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. When I ran it locally it worked as expected? Sass imports the file at build-time and doesn't compile with the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We should try to keep our demo app as close as possible to how user apps would be configured. So I agree that we should avoid drilling down into the lib folder. We should be able to use the top level There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Alright. I will look into it. |
||
|
||
.demo-dark-theme { | ||
// Include core material styles. | ||
@include mat-core(); | ||
|
||
$primary: mat-palette($mat-indigo); | ||
$accent: mat-palette($mat-pink); | ||
$dark-theme: mat-dark-theme($primary, $accent); | ||
|
||
// Include component styles with the given theme. | ||
@include angular-material-theme($dark-theme); | ||
} | ||
|
||
body { | ||
font-family: Roboto, 'Helvetica Neue', sans-serif; | ||
|
||
|
@@ -31,7 +47,6 @@ body { | |
|
||
.demo-toolbar { | ||
display: flex; | ||
justify-content: space-between; | ||
width: 100%; | ||
} | ||
} | ||
|
@@ -41,6 +56,11 @@ body { | |
} | ||
} | ||
|
||
// Fills remaining flex space. | ||
.demo-flex-fill { | ||
flex: 1 1 auto; | ||
} | ||
|
||
// stretch to screen size in fullscreen mode | ||
.demo-content { | ||
width: 100%; | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,7 +4,6 @@ | |
} | ||
|
||
.demo-section { | ||
background-color: #f7f7f7; | ||
margin: 8px; | ||
padding: 16px; | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we actually pull this out into a custom theme file and lose the prebuilt altogether? I see your point with saving build time, but dropping in here makes the theme code harder to find. This is supposed to be an example, so it might confuse people to break it up this way.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fine by me. Just set the focus on performance here. Will change!