Add svg prefix to avoid future name collision

This commit is contained in:
József Farkas
2016-04-24 11:43:58 +02:00
parent b9b2fcbf84
commit 6c1df933be
7 changed files with 24 additions and 26 deletions

View File

@@ -1,3 +0,0 @@
import {Module} from './module.model';
import {ModuleComponent} from './module.component';
export {Module, ModuleComponent};

View File

@@ -1,7 +1,7 @@
import { Component, OnInit, Input } from 'angular2/core'; import { Component, OnInit, Input } from 'angular2/core';
@Component({ @Component({
selector: 'g[uhk-keyboard-key]', selector: 'g[svg-keyboard-key]',
template: template:
` `
<svg:rect [id]="id" [attr.rx]="rx" [attr.ry]="ry" <svg:rect [id]="id" [attr.rx]="rx" [attr.ry]="ry"
@@ -10,7 +10,7 @@ import { Component, OnInit, Input } from 'angular2/core';
/> />
` `
}) })
export class KeyboardKeyComponent implements OnInit { export class SvgKeyboardKeyComponent implements OnInit {
@Input() id: string; @Input() id: string;
@Input() rx: string; @Input() rx: string;
@Input() ry: string; @Input() ry: string;

View File

@@ -1,4 +1,4 @@
export interface KeyboardKey { export interface SvgKeyboardKey {
id: string; id: string;
x: string; x: string;
y: string; y: string;

View File

@@ -1,15 +1,16 @@
import { Component, OnInit} from 'angular2/core'; import { Component, OnInit} from 'angular2/core';
import {DataProviderService} from '../services/data-provider.service'; import {DataProviderService} from '../services/data-provider.service';
import {Module, ModuleComponent} from './module'; import {SvgModule} from './svg-module.model';
import {SvgModuleComponent} from './svg-module.component';
@Component({ @Component({
selector: 'keyboard', selector: 'svg-keyboard',
template: template:
` `
<svg xmlns="http://www.w3.org/2000/svg" [attr.viewBox]="viewBox" height="100%" width="100%"> <svg xmlns="http://www.w3.org/2000/svg" [attr.viewBox]="viewBox" height="100%" width="100%">
<svg:g [attr.transform]="transform" [attr.fill]="fill"> <svg:g [attr.transform]="transform" [attr.fill]="fill">
<svg:g uhk-module *ngFor="#module of modules" <svg:g svg-module *ngFor="#module of modules"
[coverages]="module.coverages" [coverages]="module.coverages"
[keyboardKeys]="module.keyboardKeys" [keyboardKeys]="module.keyboardKeys"
[attr.transform]="module.attributes.transform" [attr.transform]="module.attributes.transform"
@@ -25,11 +26,11 @@ import {Module, ModuleComponent} from './module';
height: 100%; height: 100%;
} }
`], `],
directives: [ModuleComponent] directives: [SvgModuleComponent]
}) })
export class KeyboardComponent implements OnInit { export class SvgKeyboardComponent implements OnInit {
private viewBox: string; private viewBox: string;
private modules: Module[]; private modules: SvgModule[];
private svg: any; private svg: any;
private transform: string; private transform: string;
private fill: string; private fill: string;
@@ -43,7 +44,7 @@ export class KeyboardComponent implements OnInit {
this.viewBox = this.svg.$.viewBox; this.viewBox = this.svg.$.viewBox;
this.transform = this.svg.g[0].$.transform; this.transform = this.svg.g[0].$.transform;
this.fill = this.svg.g[0].$.fill; this.fill = this.svg.g[0].$.fill;
this.modules = this.svg.g[0].g.map(obj => new Module(obj)); this.modules = this.svg.g[0].g.map(obj => new SvgModule(obj));
} }
} }

View File

@@ -1,25 +1,25 @@
import { Component, OnInit, Input} from 'angular2/core'; import { Component, OnInit, Input} from 'angular2/core';
import {KeyboardKey} from './keyboard-key.model'; import {SvgKeyboardKey} from './svg-keyboard-key.model';
import {KeyboardKeyComponent} from './keyboard-key.component'; import {SvgKeyboardKeyComponent} from './svg-keyboard-key.component';
@Component({ @Component({
selector: 'g[uhk-module]', selector: 'g[svg-module]',
template: template:
` `
<svg:path *ngFor="#path of coverages" [attr.d]="path.$.d"/> <svg:path *ngFor="#path of coverages" [attr.d]="path.$.d"/>
<svg:g uhk-keyboard-key *ngFor="#key of keyboardKeys" <svg:g svg-keyboard-key *ngFor="#key of keyboardKeys"
[id]="key.id" [id]="key.id"
[rx]="key.rx" [ry]="key.ry" [rx]="key.rx" [ry]="key.ry"
[width]="key.width" [height]="key.height" [width]="key.width" [height]="key.height"
[attr.transform]="'translate(' + key.x + ' ' + key.y + ')'" [attr.transform]="'translate(' + key.x + ' ' + key.y + ')'"
/> />
`, `,
directives: [KeyboardKeyComponent] directives: [SvgKeyboardKeyComponent]
}) })
export class ModuleComponent implements OnInit { export class SvgModuleComponent implements OnInit {
@Input() coverages: any[]; @Input() coverages: any[];
@Input() keyboardKeys: KeyboardKey[]; @Input() keyboardKeys: SvgKeyboardKey[];
constructor() { constructor() {
this.keyboardKeys = []; this.keyboardKeys = [];

View File

@@ -1,8 +1,8 @@
import {KeyboardKey} from './keyboard-key.model'; import {SvgKeyboardKey} from './svg-keyboard-key.model';
export class Module { export class SvgModule {
private coverages: any[]; private coverages: any[];
private keyboardKeys: KeyboardKey[]; private keyboardKeys: SvgKeyboardKey[];
private attributes: any; private attributes: any;
constructor(obj: { rect: any[], path: any[], $: Object }) { constructor(obj: { rect: any[], path: any[], $: Object }) {

View File

@@ -1,11 +1,11 @@
import { Component, OnInit } from 'angular2/core'; import { Component, OnInit } from 'angular2/core';
import {KeyboardComponent} from './components/keyboard.component'; import {SvgKeyboardComponent} from './components/svg-keyboard.component';
@Component({ @Component({
selector: 'main-app', selector: 'main-app',
template: '<keyboard></keyboard>', template: '<svg-keyboard></svg-keyboard>',
directives: [KeyboardComponent] directives: [SvgKeyboardComponent]
}) })
export class MainAppComponent implements OnInit { export class MainAppComponent implements OnInit {
constructor() { } constructor() { }