From f85b88a3ef28cdc62030d8f22ec1497d07e94339 Mon Sep 17 00:00:00 2001 From: Gabriel Logan <96627244+gabriel-logan@users.noreply.github.com> Date: Wed, 15 May 2024 13:23:19 -0300 Subject: [PATCH] chore: improving homepage styling (#268) * chore: improving homepage styling More pleasant stylization and ease of generating your trophies * fix: (no-inferrable-types) inferrable types are not allowed Update error_page.ts * Update error_page.ts --- api/index.ts | 38 +++++++++++++++-- src/error_page.ts | 104 ++++++++++++++++++++++++++++++++++++++++++++-- 2 files changed, 135 insertions(+), 7 deletions(-) diff --git a/api/index.ts b/api/index.ts index 059fdeb..e40ba7a 100644 --- a/api/index.ts +++ b/api/index.ts @@ -64,9 +64,41 @@ async function app(req: Request): Promise { if (username === null) { const [base] = req.url.split("?"); const error = new Error400( - `

"username" is a required query parameter

-

The URL should look like ${base}?username=USERNAME, where -USERNAME is your GitHub username.`, + `

+
+

"username" is a required query parameter

+

The URL should look like +

+

${base}?username=USERNAME

+ + +
where + USERNAME is your GitHub username. +
+
+

You can use this form:

+

Enter your username and click get trophies

+
+ + + +
+
+ +
`, ); return new Response( error.render(), diff --git a/src/error_page.ts b/src/error_page.ts index 160bba4..be4688b 100644 --- a/src/error_page.ts +++ b/src/error_page.ts @@ -2,10 +2,106 @@ abstract class BaseError { readonly status!: number; readonly message!: string; constructor(readonly content?: string) {} - render(): string { - return `

${this.status} - ${this.message}

${ - this.content ?? "" - }`; + render() { + const page = this.renderPage(); + return page; + } + + private renderPage() { + const htmlPage = ` + + + + GitHub Profile Trophy + + + + +

${this.status} - ${this.message}

+

${this.content ?? ""}

+ + `; + + return htmlPage; } }