feat: nwaifu-ui lib with btn

This commit is contained in:
2024-06-08 01:18:39 +03:00
parent 169930cbf9
commit 16b6e34ed9
35 changed files with 337 additions and 164 deletions

46
nwaifu-ui/.eslintrc.json Normal file
View File

@@ -0,0 +1,46 @@
{
"extends": [
"../.eslintrc.base.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": "nwui",
"style": "camelCase"
}
],
"@angular-eslint/component-selector": [
"error",
{
"type": "element",
"prefix": "nwui",
"style": "kebab-case"
}
]
}
},
{
"files": [
"*.html"
],
"extends": [
"plugin:@nx/angular-template"
],
"rules": {}
}
]
}

7
nwaifu-ui/README.md Normal file
View File

@@ -0,0 +1,7 @@
# nwaifu-ui
This library was generated with [Nx](https://nx.dev).
## Running unit tests
Run `nx test nwaifu-ui` to execute the unit tests.

22
nwaifu-ui/jest.config.ts Normal file
View File

@@ -0,0 +1,22 @@
/* eslint-disable */
export default {
displayName: 'nwaifu-ui',
preset: '../jest.preset.js',
setupFilesAfterEnv: ['<rootDir>/src/test-setup.ts'],
coverageDirectory: '../coverage/nwaifu-ui',
transform: {
'^.+\\.(ts|mjs|js|html)$': [
'jest-preset-angular',
{
tsconfig: '<rootDir>/tsconfig.spec.json',
stringifyContentPathRegex: '\\.(html|svg)$',
},
],
},
transformIgnorePatterns: ['node_modules/(?!.*\\.mjs$)'],
snapshotSerializers: [
'jest-preset-angular/build/serializers/no-ng-attributes',
'jest-preset-angular/build/serializers/ng-snapshot',
'jest-preset-angular/build/serializers/html-comment',
],
};

9
nwaifu-ui/project.json Normal file
View File

@@ -0,0 +1,9 @@
{
"name": "nwaifu-ui",
"$schema": "../node_modules/nx/schemas/project-schema.json",
"sourceRoot": "nwaifu-ui/src",
"prefix": "nwui",
"projectType": "library",
"tags": [],
"targets": {}
}

1
nwaifu-ui/src/index.ts Normal file
View File

@@ -0,0 +1 @@
export * from './lib';

View File

@@ -0,0 +1 @@
<button [disabled]="disabled" [type]="type"><ng-content></ng-content></button>

View File

@@ -0,0 +1,23 @@
button {
outline: none;
border: none;
cursor: pointer;
background-color: #5b3f45;
padding: 1em 1.5em;
color: #f5f6fa;
border-radius: 15px;
transition: ease-in-out 0.2s;
margin: 2rem;
&:hover,
&:active {
transform: scale(1.2);
}
&:disabled {
opacity: 0.5;
&:hover,
&:active {
cursor: not-allowed;
transform: scale(1);
}
}
}

View File

@@ -0,0 +1,15 @@
import { CommonModule } from '@angular/common';
import { ChangeDetectionStrategy, Component, Input } from '@angular/core';
@Component({
selector: 'nwui-button',
templateUrl: './button.component.html',
styleUrls: ['./button.component.scss'],
standalone: true,
imports: [CommonModule],
changeDetection: ChangeDetectionStrategy.OnPush,
})
export class ButtonComponent {
@Input() disabled = false;
@Input() type: string | undefined;
}

View File

@@ -0,0 +1 @@
export * from './button.component';

View File

@@ -0,0 +1 @@
export * from './button';

View File

@@ -0,0 +1 @@
export * from './components';

View File

@@ -0,0 +1,8 @@
// @ts-expect-error https://thymikee.github.io/jest-preset-angular/docs/getting-started/test-environment
globalThis.ngJest = {
testEnvironmentOptions: {
errorOnUnknownElements: true,
errorOnUnknownProperties: true,
},
};
import 'jest-preset-angular/setup-jest';

29
nwaifu-ui/tsconfig.json Normal file
View File

@@ -0,0 +1,29 @@
{
"compilerOptions": {
"target": "es2022",
"useDefineForClassFields": false,
"forceConsistentCasingInFileNames": true,
"strict": true,
"noImplicitOverride": true,
"noPropertyAccessFromIndexSignature": true,
"noImplicitReturns": true,
"noFallthroughCasesInSwitch": true
},
"files": [],
"include": [],
"references": [
{
"path": "./tsconfig.lib.json"
},
{
"path": "./tsconfig.spec.json"
}
],
"extends": "../tsconfig.base.json",
"angularCompilerOptions": {
"enableI18nLegacyMessageIdFormat": false,
"strictInjectionParameters": true,
"strictInputAccessModifiers": true,
"strictTemplates": true
}
}

View File

@@ -0,0 +1,12 @@
{
"extends": "./tsconfig.json",
"compilerOptions": {
"outDir": "../dist/out-tsc",
"declaration": true,
"declarationMap": true,
"inlineSources": true,
"types": []
},
"exclude": ["src/**/*.spec.ts", "src/test-setup.ts", "jest.config.ts", "src/**/*.test.ts"],
"include": ["src/**/*.ts"]
}

View File

@@ -0,0 +1,11 @@
{
"extends": "./tsconfig.json",
"compilerOptions": {
"outDir": "../dist/out-tsc",
"module": "commonjs",
"target": "es2016",
"types": ["jest", "node"]
},
"files": ["src/test-setup.ts"],
"include": ["jest.config.ts", "src/**/*.test.ts", "src/**/*.spec.ts", "src/**/*.d.ts"]
}