Skip to content

Commit 2824d12

Browse files
authored
Merge pull request #70 from xpquiz/feature/#66
#66 feedback window
2 parents eec6a7f + ac56be7 commit 2824d12

File tree

6 files changed

+143
-16
lines changed

6 files changed

+143
-16
lines changed

src/app/about-window/about-window.component.html

Lines changed: 42 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,54 @@
66

77
<label>Source code at&nbsp;<b><a href="https://github.com/xpquiz/xpquiz.github.io">GitHub</a></b></label>
88
<label>Questions provided by&nbsp;<b><a href="https://the-trivia-api.com/">The Trivia API</a></b>,&nbsp;<b><a
9-
href="https://opentdb.com/">Open Trivia Database</a></b>&nbsp;and&nbsp;<b><a href="https://quizapi.io/">QuizAPI</a></b></label>
9+
href="https://opentdb.com/">Open Trivia Database</a></b>&nbsp;and&nbsp;<b><a
10+
href="https://quizapi.io/">QuizAPI</a></b></label>
1011
<label>Windows XP theming provided by&nbsp;<b><a href="https://botoxparty.github.io/XP.css/">XP.css</a></b></label>
1112
<label>Windows XP sounds provided by&nbsp;<b><a href="https://archive.org/details/windowsxpstartup_201910/">The
1213
Internet Archive</a></b></label>
1314
<label>Windows XP icons provided by&nbsp;<b><a
1415
href="https://www.deviantart.com/marchmountain/art/Windows-XP-High-Resolution-Icon-Pack-916042853">marchmountain
1516
at DeviantArt</a></b></label>
1617

17-
<app-icon-button iconPath="home.png" title="Return to home"
18-
(onButtonClick)="this.router.navigateByUrl(PathsEnum.HOME)"></app-icon-button>
18+
<div class="window-body_buttons">
19+
<app-icon-button iconPath="home.png" title="Return home"
20+
(onButtonClick)="this.router.navigateByUrl(PathsEnum.HOME)"></app-icon-button>
21+
<app-icon-button iconPath="contact.png" title="Contact us!" [disabled]="this.showFeedbackWindow"
22+
(onButtonClick)="this.toggleFeedbackWindow()"></app-icon-button>
23+
</div>
1924
</div>
2025
</div>
26+
27+
<div class="window" *ngIf="this.showFeedbackWindow">
28+
<app-window-title-bar iconPath="about.png" title="Contact"></app-window-title-bar>
29+
<div class="window-body">
30+
<form [formGroup]="this.feedbackForm" (ngSubmit)="this.onSubmit()">
31+
<label class="window-body_feedback-title">✍️ Feel free to message us about suggestions, feedbacks or compliments!
32+
🤔</label>
33+
34+
<div class="window-body_feedback-inputs">
35+
<div class="field-row">
36+
<label for="name">Name (*):</label>
37+
<input id="name" type="text" formControlName="name" placeholder="Type in your name..."/>
38+
</div>
39+
<div class="field-row">
40+
<label for="message">Message (*):</label>
41+
<textarea id="message" rows="8" formControlName="message" placeholder="Write your message..."></textarea>
42+
</div>
43+
</div>
44+
45+
<div class="window-body_feedback-inputs-error">
46+
<label *ngIf="this.shouldShowErrorMessage('name')">Please type in your name.</label>
47+
<label *ngIf="this.shouldShowErrorMessage('message')">Please type your message.</label>
48+
</div>
49+
50+
<div class="window-body_feedback-buttons">
51+
<app-icon-button iconPath="no.png" title="Close"
52+
(onButtonClick)="this.toggleFeedbackWindow()"></app-icon-button>
53+
<app-icon-button [disabled]="this.shouldDisableSendButton()" iconPath="send.png" title="Send"
54+
type="submit"></app-icon-button>
55+
</div>
56+
</form>
57+
</div>
58+
</div>
59+
Lines changed: 65 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,69 @@
1-
.window-body
2-
display: flex
3-
flex-direction: column
4-
align-items: center
5-
justify-content: center
1+
.window
2+
margin: 10px
63

7-
label
8-
margin: 3px
4+
&-body
5+
display: flex
6+
flex-direction: column
7+
align-items: center
8+
justify-content: center
99

10-
&.main
11-
margin-bottom: 10px
10+
label
11+
margin: 3px
12+
13+
&.main
14+
margin-bottom: 10px
15+
font-style: italic
16+
17+
&_buttons
18+
display: flex
19+
flex-direction: row
20+
align-items: center
21+
justify-content: center
22+
margin: 5px
23+
24+
app-icon-button
25+
margin: 5px
26+
27+
label.window-body_feedback-title
1228
font-style: italic
29+
margin-bottom: 10px
30+
31+
&_feedback-inputs
32+
display: flex
33+
flex-direction: column
34+
align-items: center
35+
justify-content: center
36+
margin: 10px
37+
width: 300px
38+
39+
.field-row
40+
width: 100%
41+
42+
textarea
43+
border: 1px solid #7f9db9
44+
45+
label
46+
width: 25%
47+
display: block
48+
text-align: end
49+
align-self: flex-start
50+
51+
input, textarea
52+
width: 75%
53+
54+
&_feedback-inputs-error
55+
color: red
56+
display: flex
57+
flex-direction: column
58+
align-items: center
59+
justify-content: center
60+
61+
&_feedback-buttons
62+
display: flex
63+
flex-direction: row
64+
align-items: center
65+
justify-content: center
66+
margin: 5px
1367

14-
app-icon-button
15-
margin-top: 15px
68+
app-icon-button
69+
margin: 5px

src/app/about-window/about-window.component.ts

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import {Component} from '@angular/core';
22
import {Router} from "@angular/router";
33
import {PathsEnum} from "../../model/enums/PathsEnum";
4+
import {AbstractControl, FormBuilder, FormGroup, Validators} from "@angular/forms";
45

56
@Component({
67
selector: 'app-about-window',
@@ -11,9 +12,40 @@ export class AboutWindowComponent {
1112

1213
protected readonly PathsEnum = PathsEnum;
1314

15+
public showFeedbackWindow: boolean = false;
16+
public feedbackForm: FormGroup = this.formBuilder.group({
17+
name: ['', Validators.required],
18+
message: [undefined, Validators.required]
19+
});
20+
1421
constructor(
15-
public readonly router: Router
22+
public readonly router: Router,
23+
public readonly formBuilder: FormBuilder
1624
) {
1725
}
1826

27+
protected toggleFeedbackWindow(): void {
28+
this.feedbackForm.reset();
29+
this.showFeedbackWindow = !this.showFeedbackWindow;
30+
}
31+
32+
public async onSubmit(): Promise<void> {
33+
const subject: string = `XPQuiz - Suggestions from ${this.feedbackForm.controls['name'].value}`;
34+
const body: string = encodeURI(this.feedbackForm.controls['message'].value)
35+
36+
window.location.href = `mailto:[email protected]?subject=${subject}&body=${body}`;
37+
}
38+
39+
public shouldDisableSendButton(): boolean {
40+
return !this.feedbackForm.valid;
41+
}
42+
43+
public shouldShowErrorMessage(formControlName: string): boolean {
44+
const formControl: AbstractControl = this.feedbackForm.controls[formControlName];
45+
46+
if (!this.feedbackForm.touched && !formControl.touched)
47+
return false;
48+
49+
return !formControl.valid;
50+
}
1951
}

src/app/app.module.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import {CopyClipboardDirective} from "./directives/CopyClipboardDirective";
1717
import { GameModeWindowComponent } from './game-mode-window/game-mode-window.component';
1818
import { IconTextButtonComponent } from './common/icon-text-button/icon-text-button.component';
1919
import { QuestionTrifectaWindowComponent } from './question-trifecta-window/question-trifecta-window.component';
20+
import {ReactiveFormsModule} from "@angular/forms";
2021

2122
@NgModule({
2223
declarations: [
@@ -38,7 +39,8 @@ import { QuestionTrifectaWindowComponent } from './question-trifecta-window/ques
3839
BrowserModule,
3940
AppRoutingModule,
4041
HttpClientModule,
41-
NgOptimizedImage
42+
NgOptimizedImage,
43+
ReactiveFormsModule
4244
],
4345
providers: [],
4446
bootstrap: [AppComponent]

src/assets/icons/20x20/contact.png

6.79 KB
Loading

src/assets/icons/20x20/send.png

6.65 KB
Loading

0 commit comments

Comments
 (0)