Move the fill of keys to the root
This commit is contained in:
@@ -16,7 +16,6 @@ export class KeyboardKeyComponent implements OnInit {
|
||||
@Input() ry: string;
|
||||
@Input() height: string;
|
||||
@Input() width: string;
|
||||
@Input() fill: string;
|
||||
|
||||
constructor() { }
|
||||
|
||||
|
||||
@@ -6,5 +6,4 @@ export interface KeyboardKey {
|
||||
ry: string;
|
||||
height: string;
|
||||
width: string;
|
||||
fill: string;
|
||||
}
|
||||
|
||||
@@ -8,11 +8,10 @@ import {Module, ModuleComponent} from './module';
|
||||
template:
|
||||
`
|
||||
<svg xmlns="http://www.w3.org/2000/svg" [attr.viewBox]="viewBox" height="100%" width="100%">
|
||||
<svg:g [attr.transform]="transform">
|
||||
<svg:g [attr.transform]="transform" [attr.fill]="fill">
|
||||
<svg:g uhk-module *ngFor="#module of modules"
|
||||
[coverages]="module.coverages"
|
||||
[keyboardKeys]="module.keyboardKeys"
|
||||
[fill]="module.fill"
|
||||
[attr.transform]="module.attributes.transform"
|
||||
/>
|
||||
</svg:g>
|
||||
@@ -33,6 +32,7 @@ export class KeyboardComponent implements OnInit {
|
||||
private modules: Module[];
|
||||
private svg: any;
|
||||
private transform: string;
|
||||
private fill: string;
|
||||
|
||||
constructor(private dps: DataProviderService) {
|
||||
this.modules = [];
|
||||
@@ -42,7 +42,8 @@ export class KeyboardComponent implements OnInit {
|
||||
this.svg = this.dps.getBaseLayer();
|
||||
this.viewBox = this.svg.$.viewBox;
|
||||
this.transform = this.svg.g[0].$.transform;
|
||||
this.modules = this.svg.g[0].g.map(obj => new Module(obj, this.svg.g[0].$.fill));
|
||||
this.fill = this.svg.g[0].$.fill;
|
||||
this.modules = this.svg.g[0].g.map(obj => new Module(obj));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -9,7 +9,7 @@ import {KeyboardKeyComponent} from './keyboard-key.component';
|
||||
`
|
||||
<svg:path *ngFor="#path of coverages" [attr.d]="path.$.d"/>
|
||||
<svg:g uhk-keyboard-key *ngFor="#key of keyboardKeys"
|
||||
[id]="key.id" [fill]="key.fill"
|
||||
[id]="key.id"
|
||||
[rx]="key.rx" [ry]="key.ry"
|
||||
[width]="key.width" [height]="key.height"
|
||||
[attr.transform]="'translate(' + key.x + ' ' + key.y + ')'"
|
||||
@@ -20,7 +20,6 @@ import {KeyboardKeyComponent} from './keyboard-key.component';
|
||||
export class ModuleComponent implements OnInit {
|
||||
@Input() coverages: any[];
|
||||
@Input() keyboardKeys: KeyboardKey[];
|
||||
@Input() fill: string;
|
||||
|
||||
constructor() {
|
||||
this.keyboardKeys = [];
|
||||
|
||||
@@ -5,9 +5,8 @@ export class Module {
|
||||
private keyboardKeys: KeyboardKey[];
|
||||
private attributes: any;
|
||||
|
||||
constructor(obj: { rect: any[], path: any[], $: Object }, fill?: string) {
|
||||
constructor(obj: { rect: any[], path: any[], $: Object }) {
|
||||
this.keyboardKeys = obj.rect.map(rect => rect.$);
|
||||
this.keyboardKeys.forEach(keyboardKey => keyboardKey.fill = fill ? fill : 'black');
|
||||
this.coverages = obj.path;
|
||||
this.attributes = obj.$;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user