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:
committed by
József Farkas
parent
036c2d0a70
commit
baaec669e0
10
src/components/svg/module/svg-module.component.html
Normal file
10
src/components/svg/module/svg-module.component.html
Normal 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 |
3
src/components/svg/module/svg-module.component.scss
Normal file
3
src/components/svg/module/svg-module.component.scss
Normal file
@@ -0,0 +1,3 @@
|
||||
:host {
|
||||
position: relative;
|
||||
}
|
||||
29
src/components/svg/module/svg-module.component.ts
Normal file
29
src/components/svg/module/svg-module.component.ts
Normal 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);
|
||||
}
|
||||
|
||||
}
|
||||
17
src/components/svg/module/svg-module.model.ts
Normal file
17
src/components/svg/module/svg-module.model.ts
Normal 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.$;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user