diff --git a/src/components/FrameCustomiser.svelte b/src/components/FrameCustomiser.svelte index 7d8be39..6bb9bd5 100644 --- a/src/components/FrameCustomiser.svelte +++ b/src/components/FrameCustomiser.svelte @@ -62,6 +62,7 @@ command: "setColors", backgroundColor: "#000000", foregroundColor: "#ffffff", + foregroundSecondary: "#fefefe", }, "*") `, }, @@ -76,6 +77,11 @@ return `theme=${this.value ? "dark" : "light"}`; }, }, + { + key: "display-name", + name: "Show Display Name", + value: true, + }, { key: "banner", name: "Show Banner", @@ -121,6 +127,12 @@ placeholder: "#fff", value: "", }, + { + key: "foreground-secondary", + name: "Secondary Colour (for Display Name)", + placeholder: "#fff", + value: "", + }, ]; let userId = "343383572805058560"; diff --git a/src/discord_api.ts b/src/discord_api.ts index 144ff4e..7fc58d7 100644 --- a/src/discord_api.ts +++ b/src/discord_api.ts @@ -37,6 +37,7 @@ export interface User { banner_color: string | null; accent_color: number; avatar_decoration: string; + global_name: string | null; } const flagNames: Record = { diff --git a/src/pages/user.astro b/src/pages/user.astro index aa88ff2..1417a18 100644 --- a/src/pages/user.astro +++ b/src/pages/user.astro @@ -40,14 +40,15 @@ if (!user) { const roundedCorners = Astro.url.searchParams.get("rounded-corners") !== "false"; -const fulllBanner = Astro.url.searchParams.get("full-banner") === "true"; +const fullBanner = Astro.url.searchParams.get("full-banner") === "true"; const showBanner = Astro.url.searchParams.get("banner") !== "false"; const showIcon = Astro.url.searchParams.get("discord-icon") === "true"; const showFlags = Astro.url.searchParams.get("badges") === "true"; const guessNitro = Astro.url.searchParams.get("guess-nitro") === "true"; +const showDisplayName = Astro.url.searchParams.get("display-name") !== "false"; let style = ""; -for (const key of ["background-color", "foreground-color"]) { +for (const key of ["background-color", "foreground-color", "foreground-secondary"]) { const value = Astro.url.searchParams.get(key); if (!value) continue; @@ -89,7 +90,7 @@ if (import.meta.env.PROD) "theme-light": theme === "light", "theme-dark": theme !== "light", "rounded-corners": roundedCorners, - "full-banner": fulllBanner, + "full-banner": fullBanner, "no-banner": !showBanner, }} style={style} @@ -103,34 +104,37 @@ if (import.meta.env.PROD) ) } -
- -
-

+

+
+ +
+ {user.global_name && showDisplayName && {user.global_name}} + + { + user.username + + (isPomelod(user) + ? "" + : "#" + user.discriminator) + } + +
+
+
+
{ - user.username + - (isPomelod(user) - ? "" - : "#" + user.discriminator) - } -

- { - showFlags && ( -
- {getUserFlags(user, guessNitro).map(flag => ( + showFlags && ( + getUserFlags(user, guessNitro).map(flag => ( - ))} -
- ) - } -
- { - showIcon && ( + )) + ) + } +
+ {showIcon &&
- ) - } +
} +
@@ -163,7 +167,7 @@ if (import.meta.env.PROD) document.body.classList.toggle("theme-dark", theme !== "light"); break; case "setColors": - const { foregroundColor, backgroundColor } = data; + const { foregroundColor, backgroundColor, foregroundSecondary } = data; if (hexColorRegex.test(foregroundColor)) document.body.style.setProperty( @@ -177,6 +181,12 @@ if (import.meta.env.PROD) backgroundColor ); + if (hexColorRegex.test(foregroundSecondary)) + document.body.style.setProperty( + "--foreground-secondary", + foregroundSecondary + ); + break; } }); @@ -201,12 +211,14 @@ if (import.meta.env.PROD) .theme-dark { --background-color: #2b2d31; - --foreground-color: #f2f3f5; + --foreground-color: #dedede; + --foreground-secondary: #b5bac1; } .theme-light { --background-color: white; --foreground-color: #313338; + --foreground-secondary: #4e5058; } .root { @@ -254,19 +266,28 @@ if (import.meta.env.PROD) z-index: 2; } - .profile { + .container { + align-items: start; + justify-content: space-between; + flex-direction: row; + display: flex; + background: var(--background-color); color: var(--foreground-color); + border-bottom-left-radius: var(--border-radius); + border-bottom-right-radius: var(--border-radius); + } + + .profile { position: relative; display: flex; flex-direction: row; + justify-content: start; align-items: center; - border-bottom-left-radius: var(--border-radius); - border-bottom-right-radius: var(--border-radius); } - .no-banner .profile { + .no-banner .container { border-radius: var(--border-radius); } @@ -277,11 +298,11 @@ if (import.meta.env.PROD) margin: 12px; } - p { + p, span { font-family: "gg sans", system-ui, sans-serif; font-size: 20px; font-weight: 600; - line-height: 24px; + line-height: 1; text-rendering: optimizeLegibility; } @@ -294,6 +315,11 @@ if (import.meta.env.PROD) filter: brightness(0.8); } + .flags { + margin-right: 10px; + margin-top: 10px; + } + .flags img { width: 18px; } @@ -302,6 +328,12 @@ if (import.meta.env.PROD) margin: 8px 0; } + .username.with-display-name { + color: var(--foreground-secondary); + font-size: 16px; + margin: 2px 0; + } + .userinfo { display: flex; flex-direction: column;