Skip to content

Commit

Permalink
feat(pmp-web): ui lib for picture-label element
Browse files Browse the repository at this point in the history
  • Loading branch information
adrianzaorski authored and MaciejSikorski committed Jan 17, 2020
1 parent 12023d1 commit e5a65fd
Show file tree
Hide file tree
Showing 19 changed files with 139 additions and 31 deletions.
28 changes: 27 additions & 1 deletion angular.json
Original file line number Diff line number Diff line change
Expand Up @@ -675,7 +675,7 @@
"sourceRoot": "libs/pmp-web/user/single-user-statistics/feature/src",
"projectType": "library",
"schematics": {},
"prefix": "pimp-my-pr",
"prefix": "pmp",
"architect": {
"lint": {
"builder": "@angular-devkit/build-angular:tslint",
Expand Down Expand Up @@ -794,6 +794,32 @@
"styleext": "scss"
}
}
},
"pmp-web-shared-ui-picture-label": {
"root": "libs/pmp-web/shared/ui-picture-label",
"sourceRoot": "libs/pmp-web/shared/ui-picture-label/src",
"projectType": "library",
"schematics": {},
"prefix": "pmp",
"architect": {
"lint": {
"builder": "@angular-devkit/build-angular:tslint",
"options": {
"tsConfig": [
"libs/pmp-web/shared/ui-picture-label/tsconfig.lib.json",
"libs/pmp-web/shared/ui-picture-label/tsconfig.spec.json"
],
"exclude": ["**/node_modules/**", "!libs/pmp-web/shared/ui-picture-label/**"]
}
},
"test": {
"builder": "@nrwl/jest:jest",
"options": {
"jestConfig": "libs/pmp-web/shared/ui-picture-label/jest.config.js",
"tsConfig": "libs/pmp-web/shared/ui-picture-label/tsconfig.spec.json"
}
}
}
}
},
"cli": {
Expand Down
7 changes: 7 additions & 0 deletions libs/pmp-web/shared/ui-picture-label/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# pmp-web-shared-ui-picture-label

This library was generated with [Nx](https://nx.dev).

## Running unit tests

Run `ng test pmp-web-shared-ui-picture-label` to execute the unit tests via [Jest](https://jestjs.io).
9 changes: 9 additions & 0 deletions libs/pmp-web/shared/ui-picture-label/jest.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
module.exports = {
name: 'pmp-web-shared-ui-picture-label',
preset: '../../../../jest.config.js',
transform: {
'^.+\\.[tj]sx?$': 'ts-jest'
},
moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx', 'html'],
coverageDirectory: '../../../../coverage/libs/pmp-web/shared/ui-picture-label'
};
1 change: 1 addition & 0 deletions libs/pmp-web/shared/ui-picture-label/src/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from './lib/pmp-web-shared-ui-picture-label.module';
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<div>
<img [src]="picture" [style.width]="pictureSize + 'px'" />
<span>
{{ label }}
</span>
</div>
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
div {
display: flex;
align-items: center;
}

img {
border-radius: 50%;
}

span {
margin-left: 1em;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import { Component, Input } from '@angular/core';

@Component({
selector: 'pmp-picture-label',
templateUrl: './picture-label.component.html',
styleUrls: ['./picture-label.component.scss']
})
export class PictureLabelComponent {
@Input() label: string;
@Input() picture: string;
@Input() pictureSize = 32;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';

import { PictureLabelComponent } from './components/picture-label/picture-label.component';

@NgModule({
imports: [CommonModule],
declarations: [PictureLabelComponent],
exports: [PictureLabelComponent]
})
export class PmpWebSharedUiPictureLabelModule {}
7 changes: 7 additions & 0 deletions libs/pmp-web/shared/ui-picture-label/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"extends": "../../../../tsconfig.json",
"compilerOptions": {
"types": ["node", "jest"]
},
"include": ["**/*.ts"]
}
9 changes: 9 additions & 0 deletions libs/pmp-web/shared/ui-picture-label/tsconfig.lib.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"extends": "./tsconfig.json",
"compilerOptions": {
"outDir": "../../../../dist/out-tsc",
"types": []
},
"exclude": ["**/*.spec.ts"],
"include": ["**/*.ts"]
}
9 changes: 9 additions & 0 deletions libs/pmp-web/shared/ui-picture-label/tsconfig.spec.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"extends": "./tsconfig.json",
"compilerOptions": {
"outDir": "../../../../dist/out-tsc",
"module": "commonjs",
"types": ["jest", "node"]
},
"include": ["**/*.spec.ts", "**/*.spec.tsx", "**/*.spec.js", "**/*.spec.jsx", "**/*.d.ts"]
}
1 change: 1 addition & 0 deletions libs/pmp-web/shared/ui-picture-label/tslint.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{ "extends": "../../../../tslint.json", "rules": [] }
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
<div class="user-statistics">
<div *ngFor="let repo of mockedData">
{{ repo.repository.name }}
<pmp-picture-label
[label]="repo.repository.name"
[picture]="repo.repository.picture"
[pictureSize]="32"
>
</pmp-picture-label>
</div>
</div>

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,10 @@ import { first } from 'rxjs/operators';

const mockedData = [
{
repository: { name: 'java', picture: '' },
repository: {
name: 'java',
picture: 'https://d301sr5gafysq2.cloudfront.net/39e6dc2e5ab0/img/repo-avatars/java.png'
},
data: [
{
title: 'crud users',
Expand Down Expand Up @@ -41,7 +44,10 @@ const mockedData = [
]
},
{
repository: { name: 'php', picture: '' },
repository: {
name: 'php',
picture: 'https://d301sr5gafysq2.cloudfront.net/39e6dc2e5ab0/img/repo-avatars/php.png'
},
data: [
{
title: 'crud users',
Expand Down Expand Up @@ -81,7 +87,7 @@ const mockedData = [

@Component({
// tslint:disable-next-line:component-selector
selector: 'pimp-my-pr-single-user-statistics',
selector: 'pmp-single-user-statistics',
templateUrl: './single-user-statistics.component.html',
styleUrls: ['./single-user-statistics.component.scss']
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,14 @@ import { NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';
import { PmpWebUserSingleUserStatisticsRoutingModule } from './pmp-web-user-single-user-statistics-routing.module';
import { SingleUserStatisticsComponent } from './containers/single-user-statistics/single-user-statistics.component';
import { PmpWebSharedUiPictureLabelModule } from '@pimp-my-pr/pmp-web/shared/ui-picture-label';

@NgModule({
imports: [CommonModule, PmpWebUserSingleUserStatisticsRoutingModule],
imports: [
CommonModule,
PmpWebUserSingleUserStatisticsRoutingModule,
PmpWebSharedUiPictureLabelModule
],
declarations: [SingleUserStatisticsComponent]
})
export class PmpWebUserSingleUserStatisticsFeatureModule {}
3 changes: 3 additions & 0 deletions nx.json
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,9 @@
"pmp-web-user-single-user-statistics-feature": {
"tags": ["scope:pmp-web-user", "type:feature"]
},
"pmp-web-shared-ui-picture-label": {
"tags": ["scope:pmp-web-shared", "type:ui"]
},
"pmp-web-user-data-access": {
"tags": ["scope:pmp-web-user", "type:data-access"]
},
Expand Down
3 changes: 3 additions & 0 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,9 @@
"@pimp-my-pr/pmp-web/user/domain": ["libs/pmp-web/user/domain/src/index.ts"],
"@pimp-my-pr/pmp-web/repository/data-access-repository-statistics": [
"libs/pmp-web/repository/data-access-repository-statistics/src/index.ts"
],
"@pimp-my-pr/pmp-web/shared/ui-picture-label": [
"libs/pmp-web/shared/ui-picture-label/src/index.ts"
]
}
},
Expand Down
2 changes: 1 addition & 1 deletion tslint.json
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@
}
],
"directive-selector": [true, "attribute", "app", "camelCase"],
"component-selector": [true, "element", "app", "kebab-case"],
"component-selector": [true, "element", "app", "kebab-case", "pmp"],
"no-conflicting-lifecycle": true,
"no-host-metadata-property": true,
"no-input-rename": true,
Expand Down

0 comments on commit e5a65fd

Please sign in to comment.