11 Commits

Author SHA1 Message Date
1fd6dd632e Merge pull request 'Some additions' (#4) from dev into master
Reviewed-on: #4
2024-03-11 15:37:03 +03:00
e291379602 Icon title translate 2024-03-11 14:37:32 +03:00
1237ee4439 Style updates 2024-03-10 14:36:37 +03:00
935d1f5dd9 Modal window btns cursor fix 2024-03-10 13:56:25 +03:00
2a31e85e50 Hide lang modal on click 2024-03-10 13:56:09 +03:00
c4665737dc Lang save 2024-03-10 13:53:57 +03:00
e3dac5bc83 Merge pull request 'Modal window and translations' (#3) from dev into master
Reviewed-on: #3
2024-03-10 00:20:08 +03:00
90582949d5 Added i18n translations 2024-03-10 00:14:00 +03:00
a9436a5af7 Min sizes 2024-03-09 18:25:06 +03:00
8cd5dd1f8e Added info modal window 2024-03-09 18:16:20 +03:00
f9a7b812fe Merge pull request 'Full reformat' (#2) from dev into master
Reviewed-on: #2
2024-03-09 14:07:55 +03:00
25 changed files with 342 additions and 25 deletions

View File

@@ -24,6 +24,7 @@
"@fortawesome/free-brands-svg-icons": "^6.4.2",
"@fortawesome/free-regular-svg-icons": "^6.4.2",
"@fortawesome/free-solid-svg-icons": "^6.4.2",
"@ngneat/dialog": "5.0.0",
"rxjs": "~7.8.0",
"tslib": "^2.3.0",
"zone.js": "~0.14.3"

18
pnpm-lock.yaml generated
View File

@@ -44,6 +44,9 @@ dependencies:
'@fortawesome/free-solid-svg-icons':
specifier: ^6.4.2
version: 6.5.1
'@ngneat/dialog':
specifier: 5.0.0
version: 5.0.0(@angular/core@17.2.3)
rxjs:
specifier: ~7.8.0
version: 7.8.1
@@ -2433,6 +2436,15 @@ packages:
call-bind: 1.0.7
dev: true
/@ngneat/dialog@5.0.0(@angular/core@17.2.3):
resolution: {integrity: sha512-+qLGaLcNXQ5PVtlv4htqHsJ4JV9TZ+wy89rtYMsno/jZuB63usMITPEB7TgtEPgpbyDDcYVagA6eQqYMEgZPOA==}
peerDependencies:
'@angular/core': '>=17.0.0'
dependencies:
'@angular/core': 17.2.3(rxjs@7.8.1)(zone.js@0.14.4)
tslib: 2.3.1
dev: false
/@ngtools/webpack@17.2.2(@angular/compiler-cli@17.2.3)(typescript@5.3.3)(webpack@5.90.1):
resolution: {integrity: sha512-HgvClGO6WVq4VA5d0ZvlDG5hrj8lQzRH99Gt87URm7G8E5XkatysdOsMqUQsJz+OwFWhP4PvTRWVblpBDiDl/A==}
engines: {node: ^18.13.0 || >=20.9.0, npm: ^6.11.0 || ^7.5.6 || >=8.0.0, yarn: '>= 1.13.0'}
@@ -5893,8 +5905,6 @@ packages:
peerDependenciesMeta:
webpack:
optional: true
webpack-sources:
optional: true
dependencies:
webpack: 5.90.1(esbuild@0.20.0)
webpack-sources: 3.2.3
@@ -8054,6 +8064,10 @@ packages:
strip-bom: 3.0.0
dev: true
/tslib@2.3.1:
resolution: {integrity: sha512-77EbyPPpMz+FRFRuAFlWMtmgUWGe9UOG2Z25NqCwiIjRhOf5iKGuzSe5P2w1laq+FkRy4p+PCuVkJSGkzTEKVw==}
dev: false
/tslib@2.6.2:
resolution: {integrity: sha512-AEYxH93jGFPn/a2iVAwW87VuUIkR1FVUKB77NwMF7nBTDkDrrT/Hpt/IrCJ0QXhW27jTBDcf5ZY7w6RiqTMw2Q==}

View File

@@ -2,5 +2,6 @@
<app-panel></app-panel>
</header>
<main class="main">
<app-modal></app-modal>
<app-dock></app-dock>
</main>

View File

@@ -2,6 +2,7 @@
display: block;
width: 100%;
height: calc(100% - 2rem);
background: url("../assets/img/wallpaper.png");
background-size: cover;
background-image: url("../assets/img/wallpaper.png");
background-repeat: no-repeat;
background-size: 100% 100%;
}

View File

@@ -1,12 +1,12 @@
import { Component } from "@angular/core";
import { RouterOutlet } from "@angular/router";
import { DockComponent } from "./modules/dock/dock.component";
import { ModalComponent } from "./modules/modal/modal.component";
import { PanelComponent } from "./modules/panel/panel.component";
@Component({
selector: "app-root",
standalone: true,
imports: [RouterOutlet, PanelComponent, DockComponent],
imports: [PanelComponent, DockComponent, ModalComponent],
templateUrl: "./app.component.html",
styleUrl: "./app.component.less",
})

View File

@@ -1,8 +1,22 @@
import { ApplicationConfig } from '@angular/core';
import { provideRouter } from '@angular/router';
import { APP_INITIALIZER, ApplicationConfig } from "@angular/core";
import { routes } from './app.routes';
import { provideHttpClient } from "@angular/common/http";
import { TranslateService } from "./services/translate.service";
export function setupTranslateServiceFactory(service: TranslateService) {
const lang = localStorage.getItem("lang") ?? "en";
return () => service.use(lang);
}
export const appConfig: ApplicationConfig = {
providers: [provideRouter(routes)]
providers: [
provideHttpClient(),
TranslateService,
{
provide: APP_INITIALIZER,
useFactory: setupTranslateServiceFactory,
deps: [TranslateService],
multi: true,
},
],
};

View File

@@ -16,19 +16,19 @@ export class DockComponent {
id: 0,
svg: "../../../assets/svg/logo-telegram.svg",
url: "https://t.me/neur0w0men",
text: "Telegram channel",
text: "TELEGRAM_LABEL",
},
{
id: 1,
svg: "../../../assets/svg/logo-github.svg",
url: "https://github.com/MrSedan",
text: "Admin's GitHub",
text: "GITHUB_LABEL",
},
{
id: 2,
svg: "../../../assets/svg/logo-gitea.svg",
url: "https://git.nwaifu.su",
text: "Gitea",
text: "GITEA_LABEL",
},
];
}

View File

@@ -1,4 +1,4 @@
<a [href]="url">
<img [src]="svg" [alt]="url" [title]="text" />
<span>{{ text }}</span>
<img [src]="svg" [alt]="url" [title]="text | translate" />
<span>{{ text | translate }}</span>
</a>

View File

@@ -10,7 +10,7 @@ a {
flex-direction: column;
justify-content: center;
gap: 0;
transition: 0.3s ease-in-out;
transition: 0.5s ease-in-out;
span {
opacity: 0;
visibility: hidden;
@@ -21,7 +21,7 @@ a {
font-size: 0.8rem;
height: 0;
font-weight: 600;
transition: opacity 0.3s ease-in-out;
transition: all 0.6s ease-in-out;
}
&:hover {
transform: translateY(-1rem);

View File

@@ -1,10 +1,11 @@
import { CommonModule } from "@angular/common";
import { Component, Input } from "@angular/core";
import { TranslationPipe } from "../../pipes/translation.pipe";
@Component({
standalone: true,
selector: "app-link",
imports: [CommonModule],
imports: [CommonModule, TranslationPipe],
templateUrl: "./link.component.html",
styleUrls: ["./link.component.less"],
})

View File

@@ -0,0 +1 @@
<div class="modal-window" #modal></div>

View File

@@ -0,0 +1,31 @@
import { CommonModule } from "@angular/common";
import { AfterViewInit, Component, ElementRef, ViewChild } from "@angular/core";
import { DialogRef, DialogService } from "@ngneat/dialog";
import { WindowComponent } from "../window/window.component";
@Component({
selector: "app-modal",
templateUrl: "./modal.component.html",
styleUrls: ["./modal.component.less"],
imports: [CommonModule],
standalone: true,
})
export class ModalComponent implements AfterViewInit {
dialogRef: DialogRef | undefined = undefined;
@ViewChild("modal") modal: ElementRef | undefined = undefined;
constructor(private dialogService: DialogService, private ref: ElementRef) {}
ngAfterViewInit(): void {
this.dialogRef = this.dialogService.open(WindowComponent, {
resizable: true,
draggable: true,
backdrop: false,
closeButton: false,
container: this.modal ?? this.ref,
enableClose: false,
dragConstraint: "constrain",
id: "info-modal",
minWidth: "300px",
minHeight: "10rem",
});
}
}

View File

@@ -7,11 +7,23 @@
<span>{{ time }}</span>
</div>
<div class="right-menu">
<span class="lang">en</span>
<a href="https://git.nwaifu.su/neuro_llc/NwaifuWeb">
<fa-icon [icon]="faGithub" class="sourcecode-icon" title="Source code"></fa-icon>
<span
class="lang cursor-pointer"
(click)="toggleModal()"
(keydown)="toggleModal()"
tabindex="0"
#lang_btn
>{{ getLang() }}</span
>
<a href="https://git.nwaifu.su/neuro_llc/NwaifuWeb" [title]="source_code_btn_title | translate">
<fa-icon [icon]="faGithub" class="sourcecode-icon"></fa-icon>
</a>
<fa-icon [icon]="faVolume"></fa-icon>
<fa-icon [icon]="faPower"></fa-icon>
</div>
</div>
<div class="lang-choose" #lang_modal>
<p (click)="useLang('en')" (keypress)="useLang('en')" tabindex="0"><b>en</b> - English</p>
<p (click)="useLang('ru')" (keypress)="useLang('ru')" tabindex="0"><b>ru</b> - Русский</p>
<p (click)="useLang('ja')" (keypress)="useLang('ja')" tabindex="0"><b>ja</b> - 日本語</p>
</div>

View File

@@ -1,4 +1,5 @@
.panel {
z-index: 99999;
position: relative;
left: 0;
top: 0;
@@ -56,9 +57,51 @@
align-items: center;
span {
font-weight: 600;
user-select: none;
-webkit-user-select: none;
}
fa-icon {
font-size: 1.2rem;
cursor: pointer;
}
}
.lang-choose {
position: absolute;
display: none;
&.active {
display: flex;
}
top: 0;
flex-direction: column;
justify-content: space-around;
gap: 0;
background-color: var(--black);
margin-block-start: 3rem;
z-index: 9999;
margin-inline-end: 1rem;
color: var(--white);
padding: 1rem 0;
border-radius: 15px;
&::before {
content: "";
position: absolute;
left: 50%;
transform: translateX(-50%) rotate(45deg);
vertical-align: middle;
top: -0.5rem;
width: 0;
height: 0;
border: 10px solid var(--black);
}
p {
line-height: 2rem;
width: 100%;
padding: 0.5rem 1rem;
user-select: none;
-webkit-user-select: none;
cursor: pointer;
&:hover {
background-color: #000;
}
}
}

View File

@@ -1,23 +1,31 @@
import { CommonModule } from "@angular/common";
import { Component } from "@angular/core";
import { Component, ElementRef, HostListener, ViewChild } from "@angular/core";
import { FontAwesomeModule } from "@fortawesome/angular-fontawesome";
import { faGithub } from "@fortawesome/free-brands-svg-icons";
import { faPowerOff, faVolumeHigh } from "@fortawesome/free-solid-svg-icons";
import { TranslationPipe } from '../../pipes/translation.pipe';
import { PanelSevice } from "../../services/panel.service";
import { TranslateService } from "../../services/translate.service";
@Component({
standalone: true,
selector: "app-panel",
imports: [CommonModule, FontAwesomeModule],
imports: [CommonModule, FontAwesomeModule, TranslationPipe],
templateUrl: "./panel.component.html",
styleUrls: ["./panel.component.less"],
})
export class PanelComponent {
source_code_btn_title = "SOURCE_CODE_TITLE"
public time = "";
faGithub = faGithub;
faVolume = faVolumeHigh;
faPower = faPowerOff;
constructor(private panelService: PanelSevice) {
showLangModalBool = false;
@ViewChild("lang_modal") langModal: ElementRef<HTMLDivElement> | null = null;
@ViewChild("lang_btn") langBtn: ElementRef<HTMLSpanElement> | null = null;
constructor(private panelService: PanelSevice, private translateService: TranslateService) {
this.time = this.getTime();
setInterval(() => {
this.time = this.getTime();
@@ -26,7 +34,7 @@ export class PanelComponent {
private getTime() {
const time = this.panelService.getTime();
return time.toLocaleDateString("en-US", {
return time.toLocaleDateString(this.translateService.translate("TIME_SCHEMA"), {
month: "short",
day: "numeric",
hour: "numeric",
@@ -37,4 +45,44 @@ export class PanelComponent {
goToSource() {
window.open("https://git.nwaifu.su/neuro_llc/NwaifuWeb", "_blank");
}
@HostListener("window:resize")
private moveLangModal() {
if (!this.langModal || !this.langBtn) {
return;
}
const x = this.langBtn.nativeElement.getBoundingClientRect().x;
this.langModal.nativeElement.style.left = `calc(${x}px - 3.5rem)`;
}
@HostListener("window:click", ["$event"])
private closeLangModal(event: MouseEvent) {
if (
this.langModal &&
this.langBtn &&
!this.langModal.nativeElement.contains(event.target as Node) &&
!this.langBtn.nativeElement.contains(event.target as Node)
) {
this.langModal.nativeElement.classList.remove("active");
}
}
toggleModal() {
if (this.langModal) {
this.langModal.nativeElement.classList.toggle("active");
if (this.langModal.nativeElement.classList.contains("active")) {
this.moveLangModal();
}
}
}
useLang(lang: string) {
this.langModal && this.langModal.nativeElement.classList.remove("active");
this.translateService.use(lang);
}
getLang() {
return this.translateService.lang;
}
}

View File

@@ -0,0 +1,10 @@
<div class="panel">
<span>{{ modal_title | translate }}</span>
<div class="btns">
<fa-icon [icon]="faMenu"></fa-icon>
<fa-icon [icon]="faClose"></fa-icon>
</div>
</div>
<div class="content">
<h1>{{ modal_text | translate }}</h1>
</div>

View File

@@ -0,0 +1,24 @@
.panel {
width: 100%;
display: flex;
height: 3rem;
flex-direction: row;
justify-content: space-between;
align-items: center;
padding: 0 1rem;
background-color: var(--black);
color: var(--white);
span {
font-size: 600;
}
.btns {
display: flex;
flex-direction: row;
justify-content: flex-end;
align-items: center;
gap: 1rem;
}
}
.content {
margin: 1rem;
}

View File

@@ -0,0 +1,22 @@
import { CommonModule } from "@angular/common";
import { Component } from "@angular/core";
import { FontAwesomeModule } from "@fortawesome/angular-fontawesome";
import { faBars, faXmark } from "@fortawesome/free-solid-svg-icons";
import { DialogRef } from "@ngneat/dialog";
import { TranslationPipe } from "../../pipes/translation.pipe";
@Component({
selector: "app-window",
standalone: true,
imports: [CommonModule, FontAwesomeModule, TranslationPipe],
templateUrl: "./window.component.html",
styleUrls: ["./window.component.less"],
// changeDetection: ChangeDetectionStrategy.OnPush,
})
export class WindowComponent {
modal_text = "MODAL_TEXT";
modal_title = "MODAL_TITLE";
faClose = faXmark;
faMenu = faBars;
constructor(public ref: DialogRef) {}
}

View File

@@ -0,0 +1,14 @@
import { Pipe, PipeTransform } from "@angular/core";
import { TranslateService } from "../services/translate.service";
@Pipe({
name: "translate",
standalone: true,
pure: false,
})
export class TranslationPipe implements PipeTransform {
constructor(private translateService: TranslateService) {}
transform(key: string) {
return this.translateService.data[key] ?? key;
}
}

View File

@@ -0,0 +1,31 @@
import { HttpClient } from "@angular/common/http";
import { Injectable } from "@angular/core";
@Injectable({ providedIn: "root" })
export class TranslateService {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
data: Record<string, any> = {};
lang: string | null = null;
constructor(private http: HttpClient) {}
use(lang: string): Promise<object> {
this.lang = lang ?? "en";
localStorage.setItem("lang", this.lang);
return new Promise<object>((resolve) => {
const langPath = `assets/i18n/${this.lang}.json`;
this.http.get(langPath).subscribe({
next: (response) => {
this.data = response ?? {};
resolve(this.data);
},
error: () => {
this.data = {};
resolve(this.data);
},
});
});
}
translate(key: string) {
return this.data[key] ?? key;
}
}

9
src/assets/i18n/en.json Normal file
View File

@@ -0,0 +1,9 @@
{
"MODAL_TITLE": "Info",
"TIME_SCHEMA": "en-US",
"MODAL_TEXT": "Hello, World!",
"TELEGRAM_LABEL": "Telegram channel",
"GITHUB_LABEL": "Admin's Github",
"GITEA_LABEL": "Neuro LLC Gitea",
"SOURCE_CODE_TITLE": "Source code"
}

9
src/assets/i18n/ja.json Normal file
View File

@@ -0,0 +1,9 @@
{
"MODAL_TITLE": "情報",
"TIME_SCHEMA": "ja-JP",
"MODAL_TEXT": "こんにちは、世界!",
"TELEGRAM_LABEL": "Telegramチャンネル",
"GITHUB_LABEL": "管理者Github",
"GITEA_LABEL": "Neuro LLC Gitea",
"SOURCE_CODE_TITLE": "ソースコード"
}

9
src/assets/i18n/ru.json Normal file
View File

@@ -0,0 +1,9 @@
{
"MODAL_TITLE": "Информация",
"TIME_SCHEMA": "ru-RU",
"MODAL_TEXT": "Здравствуйте, мир!",
"TELEGRAM_LABEL": "Телеграм канал",
"GITHUB_LABEL": "Github админа",
"GITEA_LABEL": "Neuro LLC Gitea",
"SOURCE_CODE_TITLE": "Исходный код"
}

View File

@@ -35,3 +35,25 @@ body {
top: 0;
left: 0;
}
ngneat-dialog {
.ngneat-dialog-backdrop {
pointer-events: none;
.ngneat-dialog-content {
pointer-events: all;
border-radius: 10px;
span {
font-weight: 600;
user-select: none;
}
.btns {
fa-icon {
z-index: 999;
cursor: not-allowed;
}
}
.ngneat-drag-marker {
height: 3rem;
}
}
}
}