Skip to content

Commit a53211c

Browse files
committed
Add footer also in auth page
Signed-off-by: Seonghyeon Cho <seonghyeoncho96@gmail.com>
1 parent 28fcd60 commit a53211c

3 files changed

Lines changed: 47 additions & 24 deletions

File tree

packages/client/src/scenes/AuthScene.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import type { IScene } from "../types";
33
import { COLORS } from "../constants";
44
import { HtmlOverlay } from "../ui/HtmlOverlay";
55
import { createBetaBadge } from "../ui/pixiBetaBadge";
6+
import { createGithubFooter } from "../ui/pixiGithubFooter";
67
import { authState } from "../managers/AuthStateManager";
78
import { ApiError, authApi } from "../network/rest";
89
import { game } from "../core/Game";
@@ -16,6 +17,7 @@ export class AuthScene extends Container implements IScene {
1617
private title: Text | null = null;
1718
private logo: Sprite | null = null;
1819
private betaBadge: Container | null = null;
20+
private footerText: Text | null = null;
1921
private view: AuthView = "chooser";
2022
private totpTicket: string | null = null;
2123

@@ -26,9 +28,21 @@ export class AuthScene extends Container implements IScene {
2628

2729
async init(): Promise<void> {
2830
this.createTitle();
31+
this.createFooter();
2932
this.render();
3033
}
3134

35+
private createFooter(): void {
36+
this.footerText = createGithubFooter();
37+
this.positionFooter();
38+
this.addChild(this.footerText);
39+
}
40+
41+
private positionFooter(): void {
42+
if (!this.footerText) return;
43+
this.footerText.position.set(this.app.screen.width / 2, this.app.screen.height - 16);
44+
}
45+
3246
private createTitle(): void {
3347
this.title = new Text({
3448
text: "Differ: Spot the Difference",
@@ -481,6 +495,7 @@ export class AuthScene extends Container implements IScene {
481495

482496
resize(_width: number, _height: number): void {
483497
this.positionTitle();
498+
this.positionFooter();
484499
}
485500

486501
destroy(): void {

packages/client/src/scenes/MainMenuScene.ts

Lines changed: 2 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import { HtmlOverlay } from "../ui/HtmlOverlay";
88
import { ApiError, authApi } from "../network/rest";
99
import { evaluatePassword, PASSWORD_HINT } from "../managers/passwordStrength";
1010
import { createBetaBadge } from "../ui/pixiBetaBadge";
11+
import { createGithubFooter } from "../ui/pixiGithubFooter";
1112

1213
export class MainMenuScene extends Container implements IScene {
1314
private app: Application;
@@ -657,30 +658,7 @@ export class MainMenuScene extends Container implements IScene {
657658
}
658659

659660
private createFooter(): void {
660-
const sha = __GIT_SHA__;
661-
const label = sha
662-
? `github.com/joe-brothers/differ (${sha})`
663-
: "github.com/joe-brothers/differ";
664-
this.footerText = new Text({
665-
text: label,
666-
style: {
667-
fontFamily: "Arial, sans-serif",
668-
fontSize: 12,
669-
fill: COLORS.textSecondary,
670-
},
671-
});
672-
this.footerText.anchor.set(0.5, 1);
673-
this.footerText.eventMode = "static";
674-
this.footerText.cursor = "pointer";
675-
this.footerText.on("pointerover", () => {
676-
if (this.footerText) this.footerText.style.fill = COLORS.text;
677-
});
678-
this.footerText.on("pointerout", () => {
679-
if (this.footerText) this.footerText.style.fill = COLORS.textSecondary;
680-
});
681-
this.footerText.on("pointerdown", () => {
682-
window.open("https://github.com/joe-brothers/differ", "_blank", "noopener,noreferrer");
683-
});
661+
this.footerText = createGithubFooter();
684662
this.positionFooter();
685663
this.addChild(this.footerText);
686664
}
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
import { Text } from "pixi.js";
2+
import { COLORS } from "../constants";
3+
4+
// GitHub repo link rendered at the bottom-center of AuthScene/MainMenuScene.
5+
// Anchor is (0.5, 1) so callers can place it at (width / 2, height - 16).
6+
export function createGithubFooter(): Text {
7+
const sha = __GIT_SHA__;
8+
const label = sha ? `github.com/joe-brothers/differ (${sha})` : "github.com/joe-brothers/differ";
9+
const text = new Text({
10+
text: label,
11+
style: {
12+
fontFamily: "Arial, sans-serif",
13+
fontSize: 12,
14+
fill: COLORS.textSecondary,
15+
},
16+
});
17+
text.anchor.set(0.5, 1);
18+
text.eventMode = "static";
19+
text.cursor = "pointer";
20+
text.on("pointerover", () => {
21+
text.style.fill = COLORS.text;
22+
});
23+
text.on("pointerout", () => {
24+
text.style.fill = COLORS.textSecondary;
25+
});
26+
text.on("pointerdown", () => {
27+
window.open("https://github.com/joe-brothers/differ", "_blank", "noopener,noreferrer");
28+
});
29+
return text;
30+
}

0 commit comments

Comments
 (0)