Structural refactoring (#68)

* Moved html in scss to separate files
* Moved components to designated folders
* Moved logic from html to ts
This commit is contained in:
Nejc Zdovc
2016-07-15 19:23:24 +02:00
committed by József Farkas
parent 036c2d0a70
commit baaec669e0
69 changed files with 834 additions and 821 deletions

View File

@@ -0,0 +1,10 @@
<svg:path *ngFor="let path of coverages" [attr.d]="path.$.d"/>
<svg:g svg-keyboard-key *ngFor="let key of keyboardKeys; let i = index"
[id]="key.id"
[rx]="key.rx" [ry]="key.ry"
[width]="key.width" [height]="key.height"
[attr.transform]="'translate(' + key.x + ' ' + key.y + ')'"
[keyAction]="keyActions[i]"
(click)="onKeyClick(i)"
/>
<popover *ngIf="popOverEnabled"></popover>

After

Width:  |  Height:  |  Size: 424 B

View File

@@ -0,0 +1,3 @@
:host {
position: relative;
}

View File

@@ -0,0 +1,29 @@
import { Component, OnInit, Input, Output, EventEmitter } from '@angular/core';
import {SvgKeyboardKey} from '../keys/svg-keyboard-key.model';
import {SvgKeyboardKeyComponent} from '../keys/svg-keyboard-key.component';
import {KeyAction} from '../../../../config-serializer/config-items/KeyAction';
@Component({
selector: 'g[svg-module]',
template: require('./svg-module.component.html'),
styles: [require('./svg-module.component.scss')],
directives: [SvgKeyboardKeyComponent]
})
export class SvgModuleComponent implements OnInit {
@Input() coverages: any[];
@Input() keyboardKeys: SvgKeyboardKey[];
@Input() keyActions: KeyAction[];
@Output() editKeyActionRequest = new EventEmitter<number>();
constructor() {
this.keyboardKeys = [];
}
ngOnInit() { }
onKeyClick(index: number): void {
this.editKeyActionRequest.emit(index);
}
}

View File

@@ -0,0 +1,17 @@
import {SvgKeyboardKey} from '../keys/svg-keyboard-key.model';
export class SvgModule {
private coverages: any[];
private keyboardKeys: SvgKeyboardKey[];
private attributes: any;
constructor(obj: { rect: any[], path: any[], $: Object }) {
this.keyboardKeys = obj.rect.map(rect => rect.$).map(rect => {
rect.height = +rect.height;
rect.width = +rect.width;
return rect;
});
this.coverages = obj.path;
this.attributes = obj.$;
}
}