@avatar-generator/angular 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/Avatar.component.js +67 -0
- package/dist/Avatar.module.js +17 -0
- package/dist/index.js +2 -0
- package/dist/types/Avatar.component.d.ts +12 -0
- package/dist/types/Avatar.module.d.ts +2 -0
- package/dist/types/index.d.ts +2 -0
- package/package.json +15 -0
- package/src/Avatar.component.ts +42 -0
- package/src/Avatar.module.ts +8 -0
- package/src/index.ts +2 -0
- package/tsconfig.json +15 -0
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
2
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
|
+
};
|
|
7
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
8
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
9
|
+
};
|
|
10
|
+
import { Component, ElementRef, Input, } from "@angular/core";
|
|
11
|
+
import { createAvatar } from "@avatar-generator/core";
|
|
12
|
+
let AvatarComponent = class AvatarComponent {
|
|
13
|
+
el;
|
|
14
|
+
name;
|
|
15
|
+
backgroundColor = "#ccc";
|
|
16
|
+
textColor = "#fff";
|
|
17
|
+
fontSize = "40px";
|
|
18
|
+
shape = "circle";
|
|
19
|
+
constructor(el) {
|
|
20
|
+
this.el = el;
|
|
21
|
+
}
|
|
22
|
+
ngOnChanges(changes) {
|
|
23
|
+
this.renderAvatar();
|
|
24
|
+
}
|
|
25
|
+
renderAvatar() {
|
|
26
|
+
const container = this.el.nativeElement.querySelector("#avatarContainer");
|
|
27
|
+
const avatarOptions = {
|
|
28
|
+
name: this.name,
|
|
29
|
+
backgroundColor: this.backgroundColor,
|
|
30
|
+
textColor: this.textColor,
|
|
31
|
+
fontSize: this.fontSize,
|
|
32
|
+
shape: this.shape,
|
|
33
|
+
};
|
|
34
|
+
if (container) {
|
|
35
|
+
container.innerHTML = "";
|
|
36
|
+
container.appendChild(createAvatar(avatarOptions));
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
};
|
|
40
|
+
__decorate([
|
|
41
|
+
Input(),
|
|
42
|
+
__metadata("design:type", String)
|
|
43
|
+
], AvatarComponent.prototype, "name", void 0);
|
|
44
|
+
__decorate([
|
|
45
|
+
Input(),
|
|
46
|
+
__metadata("design:type", Object)
|
|
47
|
+
], AvatarComponent.prototype, "backgroundColor", void 0);
|
|
48
|
+
__decorate([
|
|
49
|
+
Input(),
|
|
50
|
+
__metadata("design:type", Object)
|
|
51
|
+
], AvatarComponent.prototype, "textColor", void 0);
|
|
52
|
+
__decorate([
|
|
53
|
+
Input(),
|
|
54
|
+
__metadata("design:type", Object)
|
|
55
|
+
], AvatarComponent.prototype, "fontSize", void 0);
|
|
56
|
+
__decorate([
|
|
57
|
+
Input(),
|
|
58
|
+
__metadata("design:type", String)
|
|
59
|
+
], AvatarComponent.prototype, "shape", void 0);
|
|
60
|
+
AvatarComponent = __decorate([
|
|
61
|
+
Component({
|
|
62
|
+
selector: "avatar-generator",
|
|
63
|
+
template: `<div #avatarContainer></div>`,
|
|
64
|
+
}),
|
|
65
|
+
__metadata("design:paramtypes", [ElementRef])
|
|
66
|
+
], AvatarComponent);
|
|
67
|
+
export { AvatarComponent };
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
2
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
|
+
};
|
|
7
|
+
import { NgModule } from "@angular/core";
|
|
8
|
+
import { AvatarComponent } from "./Avatar.component";
|
|
9
|
+
let AvatarModule = class AvatarModule {
|
|
10
|
+
};
|
|
11
|
+
AvatarModule = __decorate([
|
|
12
|
+
NgModule({
|
|
13
|
+
declarations: [AvatarComponent],
|
|
14
|
+
exports: [AvatarComponent],
|
|
15
|
+
})
|
|
16
|
+
], AvatarModule);
|
|
17
|
+
export { AvatarModule };
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { ElementRef, OnChanges, SimpleChanges } from "@angular/core";
|
|
2
|
+
export declare class AvatarComponent implements OnChanges {
|
|
3
|
+
private el;
|
|
4
|
+
name: string;
|
|
5
|
+
backgroundColor: string;
|
|
6
|
+
textColor: string;
|
|
7
|
+
fontSize: string;
|
|
8
|
+
shape: "circle" | "square";
|
|
9
|
+
constructor(el: ElementRef);
|
|
10
|
+
ngOnChanges(changes: SimpleChanges): void;
|
|
11
|
+
private renderAvatar;
|
|
12
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@avatar-generator/angular",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"types": "dist/types/index.d.ts",
|
|
7
|
+
"scripts": {
|
|
8
|
+
"build": "tsc",
|
|
9
|
+
"prepublishOnly": "npm run build"
|
|
10
|
+
},
|
|
11
|
+
"dependencies": {
|
|
12
|
+
"@avatar-generator/core": "^1.0.0",
|
|
13
|
+
"@angular/core": "^13.0.0"
|
|
14
|
+
}
|
|
15
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import {
|
|
2
|
+
Component,
|
|
3
|
+
ElementRef,
|
|
4
|
+
Input,
|
|
5
|
+
OnChanges,
|
|
6
|
+
SimpleChanges,
|
|
7
|
+
} from "@angular/core";
|
|
8
|
+
import { createAvatar, AvatarOptions } from "@avatar-generator/core";
|
|
9
|
+
|
|
10
|
+
@Component({
|
|
11
|
+
selector: "avatar-generator",
|
|
12
|
+
template: `<div #avatarContainer></div>`,
|
|
13
|
+
})
|
|
14
|
+
export class AvatarComponent implements OnChanges {
|
|
15
|
+
@Input() name!: string;
|
|
16
|
+
@Input() backgroundColor = "#ccc";
|
|
17
|
+
@Input() textColor = "#fff";
|
|
18
|
+
@Input() fontSize = "40px";
|
|
19
|
+
@Input() shape: "circle" | "square" = "circle";
|
|
20
|
+
|
|
21
|
+
constructor(private el: ElementRef) {}
|
|
22
|
+
|
|
23
|
+
ngOnChanges(changes: SimpleChanges): void {
|
|
24
|
+
this.renderAvatar();
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
private renderAvatar(): void {
|
|
28
|
+
const container = this.el.nativeElement.querySelector("#avatarContainer");
|
|
29
|
+
const avatarOptions: AvatarOptions = {
|
|
30
|
+
name: this.name,
|
|
31
|
+
backgroundColor: this.backgroundColor,
|
|
32
|
+
textColor: this.textColor,
|
|
33
|
+
fontSize: this.fontSize,
|
|
34
|
+
shape: this.shape,
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
if (container) {
|
|
38
|
+
container.innerHTML = "";
|
|
39
|
+
container.appendChild(createAvatar(avatarOptions));
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
}
|
package/src/index.ts
ADDED
package/tsconfig.json
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"declaration": true,
|
|
4
|
+
"declarationDir": "./dist/types",
|
|
5
|
+
"outDir": "./dist",
|
|
6
|
+
"esModuleInterop": true,
|
|
7
|
+
"module": "ESNext",
|
|
8
|
+
"moduleResolution": "Node",
|
|
9
|
+
"target": "ESNext",
|
|
10
|
+
"rootDir": "src",
|
|
11
|
+
"experimentalDecorators": true,
|
|
12
|
+
"emitDecoratorMetadata": true
|
|
13
|
+
},
|
|
14
|
+
"include": ["src"]
|
|
15
|
+
}
|