Created
August 10, 2017 17:31
-
-
Save beeman/2740d52002b330381a5ec8badbb75af4 to your computer and use it in GitHub Desktop.
scratchpad: ngx-bootswatch
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import { Component, ChangeDetectionStrategy, Input } from '@angular/core' | |
| @Component({ | |
| selector: 'theme', | |
| template: ` | |
| <div class="btn-group" | |
| [class.show]="themeDropOpen"> | |
| <button type="button" | |
| class="btn btn-outline-primary dropdown-toggle" | |
| data-toggle="dropdown" | |
| aria-haspopup="true" | |
| aria-expanded="false" | |
| (click)="toggleThemeDrop()">Theme | |
| </button> | |
| <div class="dropdown-menu"> | |
| <a *ngFor="let theme of themes" | |
| class="dropdown-item" | |
| href="#" | |
| [class.active]="selectedTheme === theme.name" | |
| (click)="selectTheme(theme)">{{ theme.name }} | |
| </a> | |
| </div> | |
| </div> | |
| `, | |
| styles: [` | |
| .btn-group { | |
| position: absolute; | |
| right: 50px; | |
| top: -20px; | |
| } | |
| .dropdown-menu { | |
| margin-top: 20px; | |
| } | |
| `], | |
| changeDetection: ChangeDetectionStrategy.OnPush | |
| }) | |
| export class ThemeComponent { | |
| public selectedTheme = 'Cosmo' | |
| public themeDropOpen = false | |
| public themes = [ | |
| { name: 'Cerulean' }, | |
| { name: 'Cosmo' }, | |
| { name: 'Cyborg' }, | |
| { name: 'Darkly' }, | |
| { name: 'Flatly' }, | |
| { name: 'Journal' }, | |
| { name: 'Litera' }, | |
| { name: 'Lumen' }, | |
| { name: 'Lux' }, | |
| { name: 'Materia' }, | |
| { name: 'Minty' }, | |
| { name: 'Pulse' }, | |
| { name: 'Sandstone' }, | |
| { name: 'Simplex' }, | |
| { name: 'Spacelab' }, | |
| { name: 'Superhero' }, | |
| { name: 'United' }, | |
| { name: 'Yeti' }, | |
| ] | |
| toggleThemeDrop() { | |
| this.themeDropOpen = !this.themeDropOpen | |
| } | |
| selectTheme(theme) { | |
| this.selectedTheme = theme.name | |
| this.toggleThemeDrop() | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment