mirror of
https://github.com/Raghu-Ch/angular-challenges.git
synced 2026-02-10 12:53:03 -05:00
feat: challenge 42
This commit is contained in:
36
libs/static-dynamic-import/users/.eslintrc.json
Normal file
36
libs/static-dynamic-import/users/.eslintrc.json
Normal file
@@ -0,0 +1,36 @@
|
||||
{
|
||||
"extends": ["../../../.eslintrc.json"],
|
||||
"ignorePatterns": ["!**/*"],
|
||||
"overrides": [
|
||||
{
|
||||
"files": ["*.ts"],
|
||||
"extends": [
|
||||
"plugin:@nx/angular",
|
||||
"plugin:@angular-eslint/template/process-inline-templates"
|
||||
],
|
||||
"rules": {
|
||||
"@angular-eslint/directive-selector": [
|
||||
"error",
|
||||
{
|
||||
"type": "attribute",
|
||||
"prefix": "sdi",
|
||||
"style": "camelCase"
|
||||
}
|
||||
],
|
||||
"@angular-eslint/component-selector": [
|
||||
"error",
|
||||
{
|
||||
"type": "element",
|
||||
"prefix": "sdi",
|
||||
"style": "kebab-case"
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"files": ["*.html"],
|
||||
"extends": ["plugin:@nx/angular-template"],
|
||||
"rules": {}
|
||||
}
|
||||
]
|
||||
}
|
||||
3
libs/static-dynamic-import/users/README.md
Normal file
3
libs/static-dynamic-import/users/README.md
Normal file
@@ -0,0 +1,3 @@
|
||||
# users
|
||||
|
||||
This library was generated with [Nx](https://nx.dev).
|
||||
14
libs/static-dynamic-import/users/project.json
Normal file
14
libs/static-dynamic-import/users/project.json
Normal file
@@ -0,0 +1,14 @@
|
||||
{
|
||||
"name": "users",
|
||||
"$schema": "../../../node_modules/nx/schemas/project-schema.json",
|
||||
"sourceRoot": "libs/static-dynamic-import/users/src",
|
||||
"prefix": "sdi",
|
||||
"tags": [],
|
||||
"projectType": "library",
|
||||
"targets": {
|
||||
"lint": {
|
||||
"executor": "@nx/eslint:lint",
|
||||
"outputs": ["{options.outputFile}"]
|
||||
}
|
||||
}
|
||||
}
|
||||
3
libs/static-dynamic-import/users/src/index.ts
Normal file
3
libs/static-dynamic-import/users/src/index.ts
Normal file
@@ -0,0 +1,3 @@
|
||||
export type { User } from './lib/user.model';
|
||||
export { UserPipe } from './lib/user.pipe';
|
||||
export { default } from './lib/users.component';
|
||||
5
libs/static-dynamic-import/users/src/lib/user.model.ts
Normal file
5
libs/static-dynamic-import/users/src/lib/user.model.ts
Normal file
@@ -0,0 +1,5 @@
|
||||
export interface User {
|
||||
name: string;
|
||||
lastname: string;
|
||||
country: string;
|
||||
}
|
||||
12
libs/static-dynamic-import/users/src/lib/user.pipe.ts
Normal file
12
libs/static-dynamic-import/users/src/lib/user.pipe.ts
Normal file
@@ -0,0 +1,12 @@
|
||||
import { Pipe, PipeTransform } from '@angular/core';
|
||||
import { User } from './user.model';
|
||||
|
||||
@Pipe({
|
||||
name: 'user',
|
||||
standalone: true,
|
||||
})
|
||||
export class UserPipe implements PipeTransform {
|
||||
transform(user: User): string {
|
||||
return `${user.name} ${user.lastname} - ${user.country}`;
|
||||
}
|
||||
}
|
||||
36
libs/static-dynamic-import/users/src/lib/users.component.ts
Normal file
36
libs/static-dynamic-import/users/src/lib/users.component.ts
Normal file
@@ -0,0 +1,36 @@
|
||||
import { Component } from '@angular/core';
|
||||
|
||||
import { randCountry, randFirstName, randLastName } from '@ngneat/falso';
|
||||
import type { User } from './user.model';
|
||||
import { UserPipe } from './user.pipe';
|
||||
|
||||
export const randUser = (): User => ({
|
||||
name: randFirstName(),
|
||||
lastname: randLastName(),
|
||||
country: randCountry(),
|
||||
});
|
||||
|
||||
@Component({
|
||||
selector: 'sdi-users',
|
||||
standalone: true,
|
||||
imports: [UserPipe],
|
||||
template: `
|
||||
<h1 class="mt-4 text-xl">List of Users</h1>
|
||||
@for (user of users; track user) {
|
||||
<div>{{ user | user }}</div>
|
||||
}
|
||||
`,
|
||||
host: {
|
||||
class: 'flex flex-col',
|
||||
},
|
||||
})
|
||||
export default class UsersComponent {
|
||||
users = [
|
||||
randUser(),
|
||||
randUser(),
|
||||
randUser(),
|
||||
randUser(),
|
||||
randUser(),
|
||||
randUser(),
|
||||
];
|
||||
}
|
||||
26
libs/static-dynamic-import/users/tsconfig.json
Normal file
26
libs/static-dynamic-import/users/tsconfig.json
Normal file
@@ -0,0 +1,26 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"target": "es2022",
|
||||
"useDefineForClassFields": false,
|
||||
"forceConsistentCasingInFileNames": true,
|
||||
"strict": true,
|
||||
"noImplicitOverride": true,
|
||||
"noPropertyAccessFromIndexSignature": true,
|
||||
"noImplicitReturns": true,
|
||||
"noFallthroughCasesInSwitch": true
|
||||
},
|
||||
"files": [],
|
||||
"include": [],
|
||||
"references": [
|
||||
{
|
||||
"path": "./tsconfig.lib.json"
|
||||
}
|
||||
],
|
||||
"extends": "../../../tsconfig.base.json",
|
||||
"angularCompilerOptions": {
|
||||
"enableI18nLegacyMessageIdFormat": false,
|
||||
"strictInjectionParameters": true,
|
||||
"strictInputAccessModifiers": true,
|
||||
"strictTemplates": true
|
||||
}
|
||||
}
|
||||
12
libs/static-dynamic-import/users/tsconfig.lib.json
Normal file
12
libs/static-dynamic-import/users/tsconfig.lib.json
Normal file
@@ -0,0 +1,12 @@
|
||||
{
|
||||
"extends": "./tsconfig.json",
|
||||
"compilerOptions": {
|
||||
"outDir": "../../../dist/out-tsc",
|
||||
"declaration": true,
|
||||
"declarationMap": true,
|
||||
"inlineSources": true,
|
||||
"types": []
|
||||
},
|
||||
"exclude": ["src/**/*.spec.ts", "jest.config.ts", "src/**/*.test.ts"],
|
||||
"include": ["src/**/*.ts"]
|
||||
}
|
||||
Reference in New Issue
Block a user