diff --git a/src/main-app.component.ts b/src/main-app.component.ts index f4acc4d2..8744d225 100644 --- a/src/main-app.component.ts +++ b/src/main-app.component.ts @@ -1,15 +1,84 @@ -import { Component, OnInit } from 'angular2/core'; +import { Component, OnInit, AfterViewInit, Renderer, ViewChildren, QueryList, ElementRef} from 'angular2/core'; import {SvgKeyboardComponent} from './components/svg-keyboard.component'; @Component({ selector: 'main-app', - template: '', + template: + `
+ + + + +
+
+ +
+ `, + styles: + [` + :host { + display: flex; + flex-direction: column; + } + + :host > div:first-child { + display: flex; + flex: 1; + align-items: center; + justify-content: center; + } + + button { + margin: 2px; + } + + :host > div:last-child { + display: flex; + flex: 5; + justify-content: center; + } + + :host > div:last-child > svg-keyboard { + width: 80%; + } + `], directives: [SvgKeyboardComponent] }) -export class MainAppComponent implements OnInit { - constructor() { } +export class MainAppComponent implements OnInit, AfterViewInit { + @ViewChildren('baseButton,modButton,fnButton,mouseButton') + buttonsQueryList: QueryList; + + private buttons: ElementRef[]; + private selectedLayerIndex: number; + + constructor(private renderer: Renderer) { + this.buttons = []; + this.selectedLayerIndex = -1; + } ngOnInit() { } + ngAfterViewInit() { + this.buttons = this.buttonsQueryList.toArray(); + this.selectedLayerIndex = 0; + } + + /* tslint:disable:no-unused-variable */ + /* selectLayer is used in the template string */ + private selectLayer(index: number): void { + /* tslint:enable:no-unused-variable */ + this.renderer.setElementClass(this.buttons[this.selectedLayerIndex].nativeElement, 'btn-primary', false); + this.renderer.setElementClass(this.buttons[index].nativeElement, 'btn-primary', true); + this.selectedLayerIndex = index; + } + }