feat: nitroplus translate. Needs to fix

This commit is contained in:
2024-06-20 16:55:57 +03:00
parent 7cc5cbaac3
commit 0d6a56c9a3
48 changed files with 765 additions and 69 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.

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;
width: 100%;
&: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 NWUIButtonComponent {
@Input() disabled = false;
@Input() type = 'button';
}

View File

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

View File

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

View File

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

View File

@@ -0,0 +1,5 @@
<div [attr.contenteditable]="contenteditable" [className]="className" #ref (blur)="leaveFn()">
@if(!value) {
<ng-content></ng-content>
}
</div>

View File

@@ -0,0 +1,20 @@
.nwui-textarea {
border-radius: 8px;
height: auto;
color: #efdee0;
outline: none;
padding-inline: 2rem 1rem;
background-color: transparent;
border: 2px solid #e4bdc3;
font-size: 1rem;
font-weight: inherit;
min-height: 3rem;
line-height: 3rem;
&:focus {
border: 2px solid #efdee0;
}
&.disabled {
opacity: 0.5;
}
word-wrap: break-word;
}

View File

@@ -0,0 +1,35 @@
import { CommonModule } from '@angular/common';
import { AfterViewInit, Component, ElementRef, EventEmitter, Input, Output, ViewChild } from '@angular/core';
@Component({
selector: 'nwui-textarea',
imports: [CommonModule],
standalone: true,
styleUrls: ['./textarea.component.scss'],
templateUrl: './textarea.component.html',
// changeDetection: ChangeDetectionStrategy.OnPush,
})
export class NWUITextAreaComponent implements AfterViewInit {
@Input() disabled = false;
@Input() value = '';
@Input() contenteditable = true;
@Output() leave = new EventEmitter<string>();
@ViewChild('ref') ref: ElementRef<HTMLDivElement> | null = null;
get className(): string {
return `nwui-textarea ${this.disabled && !this.contenteditable ? 'disabled' : ''}`;
}
leaveFn() {
if (this.ref) {
const target = this.ref.nativeElement;
const text = target.textContent || '';
if (this.leave) this.leave.emit(text);
target.textContent = text;
}
}
ngAfterViewInit(): void {
if (this.ref && this.value) this.ref.nativeElement.textContent = this.value;
}
}

View File

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

26
nwaifu-ui/tsconfig.json Normal file
View 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
}
}

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"]
}