Skip to content

Commit d9b1f2d

Browse files
committed
fix: format existing UI code
1 parent 5161ce0 commit d9b1f2d

126 files changed

Lines changed: 2447 additions & 1627 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Lines changed: 28 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,34 @@
1-
import { animate, state, style, transition, trigger } from '@angular/animations';
2-
1+
import {
2+
animate,
3+
state,
4+
style,
5+
transition,
6+
trigger
7+
} from '@angular/animations';
38

49
export const fadeInOutActiveAnimation = trigger('fadeInOutActive', [
5-
state('false', style({
6-
'visibility': 'hidden',
7-
'opacity': '0',
8-
})),
10+
state(
11+
'false',
12+
style({
13+
visibility: 'hidden',
14+
opacity: '0'
15+
})
16+
),
917
transition('false => true', [
10-
animate('200ms ease-out', style({
11-
'visibility': '*',
12-
'opacity': '*',
13-
})),
18+
animate(
19+
'200ms ease-out',
20+
style({
21+
visibility: '*',
22+
opacity: '*'
23+
})
24+
)
1425
]),
1526
transition('true => false', [
16-
animate('200ms ease-in', style({
17-
'opacity': '0',
18-
})),
19-
]),
27+
animate(
28+
'200ms ease-in',
29+
style({
30+
opacity: '0'
31+
})
32+
)
33+
])
2034
]);
Lines changed: 28 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,34 @@
1-
import { animate, state, style, transition, trigger } from '@angular/animations';
2-
1+
import {
2+
animate,
3+
state,
4+
style,
5+
transition,
6+
trigger
7+
} from '@angular/animations';
38

49
export const fadeInOutAnimation = trigger('fadeInOut', [
5-
state('void', style({
6-
'visibility': 'hidden',
7-
'opacity': '0',
8-
})),
10+
state(
11+
'void',
12+
style({
13+
visibility: 'hidden',
14+
opacity: '0'
15+
})
16+
),
917
transition('void => *', [
10-
animate('300ms ease-in', style({
11-
'visibility': 'visible',
12-
'opacity': '1',
13-
})),
18+
animate(
19+
'300ms ease-in',
20+
style({
21+
visibility: 'visible',
22+
opacity: '1'
23+
})
24+
)
1425
]),
1526
transition('* => void', [
16-
animate('300ms ease-out', style({
17-
'opacity': '0',
18-
})),
19-
]),
27+
animate(
28+
'300ms ease-out',
29+
style({
30+
opacity: '0'
31+
})
32+
)
33+
])
2034
]);

Code/skyrim_ui/src/app/app.module.ts

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,6 @@ import { SoundService } from './services/sound.service';
4545
import { StoreService } from './services/store.service';
4646
import { TranslocoRootModule } from './transloco-root.module';
4747

48-
4948
@NgModule({
5049
declarations: [
5150
ChatComponent,
@@ -75,7 +74,7 @@ import { TranslocoRootModule } from './transloco-root.module';
7574
CheckboxDirective,
7675
HealthDirective,
7776
RadioDirective,
78-
SliderDirective,
77+
SliderDirective
7978
],
8079
imports: [
8180
BrowserAnimationsModule,
@@ -86,7 +85,7 @@ import { TranslocoRootModule } from './transloco-root.module';
8685
ReactiveFormsModule,
8786
ScrollingModule,
8887
TranslocoRootModule,
89-
OverlayModule,
88+
OverlayModule
9089
],
9190
providers: [
9291
ClientService,
@@ -99,9 +98,8 @@ import { TranslocoRootModule } from './transloco-root.module';
9998
StoreService,
10099
SettingService,
101100

102-
...environment.providers,
101+
...environment.providers
103102
],
104-
bootstrap: [RootComponent],
103+
bootstrap: [RootComponent]
105104
})
106-
export class AppModule {
107-
}
105+
export class AppModule {}
Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
11
:host {
22
display: flex;
33
}
4-
5-
Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
11
import { Component } from '@angular/core';
22

3-
43
@Component({
54
selector: 'app-action-buttons',
65
templateUrl: './action-buttons.component.html',
7-
styleUrls: ['./action-buttons.component.scss'],
6+
styleUrls: ['./action-buttons.component.scss']
87
})
9-
export class ActionButtonsComponent {
10-
}
8+
export class ActionButtonsComponent {}

Code/skyrim_ui/src/app/components/chat/chat.component.html

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,19 @@
1-
<div #log (scroll)="onLogScroll()" class="app-chat-messages" [style.padding-top.px]="padding">
2-
<p
3-
#entry
4-
*ngFor="let message of messages"
5-
[ngClass]="message.typeClass"
6-
>
1+
<div
2+
#log
3+
(scroll)="onLogScroll()"
4+
class="app-chat-messages"
5+
[style.padding-top.px]="padding">
6+
<p #entry *ngFor="let message of messages" [ngClass]="message.typeClass">
77
<span class="app-chat-date">[{{ message.date | date: 'HH:mm:ss' }}] </span>
8-
<span class="app-chat-name" *ngIf="message.senderName">{{ message.senderName }}: </span>
9-
<span class="app-chat-message" *ngIf="message.typeClass === 'system'">{{ message.content | transloco: message.translationParams }}</span>
10-
<span class="app-chat-message" *ngIf="message.typeClass !== 'system'">{{ message.content }}</span>
8+
<span class="app-chat-name" *ngIf="message.senderName"
9+
>{{ message.senderName }}:
10+
</span>
11+
<span class="app-chat-message" *ngIf="message.typeClass === 'system'">{{
12+
message.content | transloco: message.translationParams
13+
}}</span>
14+
<span class="app-chat-message" *ngIf="message.typeClass !== 'system'">{{
15+
message.content
16+
}}</span>
1117
</p>
1218
</div>
1319
<div class="app-chat-input">
@@ -19,8 +25,7 @@
1925
autocapitalize="off"
2026
spellcheck="false"
2127
[(ngModel)]="message"
22-
(keydown.enter)="sendMessage()"
23-
>
28+
(keydown.enter)="sendMessage()" />
2429
<button (click)="sendMessage()">
2530
{{ 'COMPONENT.CHAT.SEND' | transloco }}
2631
</button>

Code/skyrim_ui/src/app/components/chat/chat.component.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
}
3535
&.dialogue {
3636
.app-chat-message {
37-
color: #00FF33;
37+
color: #00ff33;
3838
}
3939
}
4040
&.party {

Code/skyrim_ui/src/app/components/chat/chat.component.ts

Lines changed: 33 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,45 +1,55 @@
1-
import { AfterViewChecked, Component, ElementRef, HostListener, QueryList, ViewChild, ViewChildren } from '@angular/core';
1+
import {
2+
AfterViewChecked,
3+
Component,
4+
ElementRef,
5+
HostListener,
6+
QueryList,
7+
ViewChild,
8+
ViewChildren
9+
} from '@angular/core';
210
import { TranslocoService } from '@ngneat/transloco';
311
import { takeUntil } from 'rxjs';
412
import { DestroyService } from '../../services/destroy.service';
513
import { Sound, SoundService } from '../../services/sound.service';
614
import { MessageHistory } from './message-history';
7-
import { ChatMessage, ChatService, MessageTypes } from 'src/app/services/chat.service';
15+
import {
16+
ChatMessage,
17+
ChatService,
18+
MessageTypes
19+
} from 'src/app/services/chat.service';
820
import { ClientService } from 'src/app/services/client.service';
921

1022
interface ChatComponentMessage extends ChatMessage {
1123
date: number;
1224
typeClass: string;
1325
}
1426

15-
1627
function messageTypeToClassName(type: MessageTypes): string {
1728
switch (type) {
1829
case MessageTypes.SYSTEM_MESSAGE:
19-
return "system";
20-
30+
return 'system';
31+
2132
case MessageTypes.PLAYER_DIALOGUE:
22-
return "dialogue";
23-
33+
return 'dialogue';
34+
2435
case MessageTypes.PARTY_CHAT:
25-
return "party";
26-
36+
return 'party';
37+
2738
case MessageTypes.LOCAL_CHAT:
28-
return "local";
39+
return 'local';
2940

3041
default:
31-
return "global";
42+
return 'global';
3243
}
3344
}
3445

3546
@Component({
3647
selector: 'app-chat',
3748
templateUrl: './chat.component.html',
3849
styleUrls: ['./chat.component.scss'],
39-
providers: [DestroyService],
50+
providers: [DestroyService]
4051
})
4152
export class ChatComponent implements AfterViewChecked {
42-
4353
public padding = 0;
4454

4555
public message = '';
@@ -51,14 +61,15 @@ export class ChatComponent implements AfterViewChecked {
5161

5262
private scrollBack = 0;
5363

54-
private history = new MessageHistory({maxHistoryLength: 50});
64+
private history = new MessageHistory({ maxHistoryLength: 50 });
5565

5666
private get maxScroll(): number {
57-
return this.logRef.nativeElement.scrollHeight - this.logRef.nativeElement.clientHeight;
67+
return (
68+
this.logRef.nativeElement.scrollHeight -
69+
this.logRef.nativeElement.clientHeight
70+
);
5871
}
5972

60-
61-
6273
@ViewChild('input') private inputRef!: ElementRef;
6374
@ViewChildren('entry') private entryRefQuery!: QueryList<ElementRef>;
6475
@ViewChild('log') private logRef!: ElementRef;
@@ -68,8 +79,7 @@ export class ChatComponent implements AfterViewChecked {
6879
private readonly clientService: ClientService,
6980
private readonly chatService: ChatService,
7081
private readonly sound: SoundService,
71-
private readonly translocoService: TranslocoService,
72-
82+
private readonly translocoService: TranslocoService
7383
) {
7484
chatService.messageList
7585
.pipe(takeUntil(this.destroy$))
@@ -95,7 +105,7 @@ export class ChatComponent implements AfterViewChecked {
95105
this.sound.play(Sound.Message);
96106
});
97107

98-
clientService.activationStateChange
108+
clientService.activationStateChange
99109
.pipe(takeUntil(this.destroy$))
100110
.subscribe(state => {
101111
if (!state && this.inputRef) {
@@ -128,7 +138,7 @@ export class ChatComponent implements AfterViewChecked {
128138
if (this.message) {
129139
this.chatService.sendMessage(MessageTypes.GLOBAL_CHAT, this.message);
130140
this.sound.play(Sound.Focus);
131-
this.history.push(this.message)
141+
this.history.push(this.message);
132142
this.message = '';
133143
}
134144

@@ -160,15 +170,14 @@ export class ChatComponent implements AfterViewChecked {
160170
event.preventDefault();
161171
event.stopPropagation();
162172

163-
this.message = this.history.prev(this.message)
173+
this.message = this.history.prev(this.message);
164174
}
165175

166176
@HostListener('keydown.ArrowDown', ['$event'])
167177
private onArrowDown(event: KeyboardEvent) {
168178
event.preventDefault();
169179
event.stopPropagation();
170180

171-
this.message = this.history.next()
181+
this.message = this.history.next();
172182
}
173-
174183
}

Code/skyrim_ui/src/app/components/chat/message-history.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
11
/** Helper for storing sent message history */
22
export class MessageHistory {
3-
43
private stack: string[] = [];
54
private offset = 0;
65
/** When the history exeeds this number, the first item will be removed */
76
private maxHistoryLength: number;
87

9-
constructor({maxHistoryLength}) {
8+
constructor({ maxHistoryLength }) {
109
this.maxHistoryLength = maxHistoryLength;
1110
}
1211

@@ -30,13 +29,13 @@ export class MessageHistory {
3029
this.offset -= 1;
3130

3231
const isHistotyEmpty = this.stack.length === 0;
33-
if(isHistotyEmpty) {
32+
if (isHistotyEmpty) {
3433
this.offset = 0;
3534
return fallback;
3635
}
3736

3837
const isOffsetTooLow = this.offset < 0;
39-
if(isOffsetTooLow) {
38+
if (isOffsetTooLow) {
4039
this.offset = 0;
4140
return this.stack[this.offset];
4241
}

0 commit comments

Comments
 (0)