From 19d54778f508085bdf1ba46cfec8943f54d16154 Mon Sep 17 00:00:00 2001 From: miloschwartz Date: Tue, 15 Jul 2025 16:24:16 -0700 Subject: [PATCH] add branding logo component --- server/setup/copyInConfig.ts | 8 ++- .../[orgId]/settings/domains/DomainsTable.tsx | 23 ++++----- src/app/auth/login/DashboardLoginForm.tsx | 41 +++++---------- src/app/auth/signup/SignupForm.tsx | 36 +++++++------ src/components/BrandingLogo.tsx | 50 +++++++++++++++++++ 5 files changed, 97 insertions(+), 61 deletions(-) create mode 100644 src/components/BrandingLogo.tsx diff --git a/server/setup/copyInConfig.ts b/server/setup/copyInConfig.ts index 2c8e1110..eccee475 100644 --- a/server/setup/copyInConfig.ts +++ b/server/setup/copyInConfig.ts @@ -69,7 +69,13 @@ async function copyInDomains() { } else { await trx .insert(domains) - .values({ domainId, baseDomain, configManaged: true, type: "wildcard" }) + .values({ + domainId, + baseDomain, + configManaged: true, + type: "wildcard", + verified: true + }) .execute(); } } diff --git a/src/app/[orgId]/settings/domains/DomainsTable.tsx b/src/app/[orgId]/settings/domains/DomainsTable.tsx index cb26b357..84bc8bc6 100644 --- a/src/app/[orgId]/settings/domains/DomainsTable.tsx +++ b/src/app/[orgId]/settings/domains/DomainsTable.tsx @@ -210,18 +210,17 @@ export default function DomainsTable({ domains }: Props) { : t("restart", { fallback: "Restart" })} )} - {!domain.configManaged && ( - - )} + ); } diff --git a/src/app/auth/login/DashboardLoginForm.tsx b/src/app/auth/login/DashboardLoginForm.tsx index 1dcdff4a..2a98ab0b 100644 --- a/src/app/auth/login/DashboardLoginForm.tsx +++ b/src/app/auth/login/DashboardLoginForm.tsx @@ -14,6 +14,7 @@ import { useRouter } from "next/navigation"; import { useEffect } from "react"; import Image from "next/image"; import { cleanRedirect } from "@app/lib/cleanRedirect"; +import BrandingLogo from "@app/components/BrandingLogo"; import { useTranslations } from "next-intl"; type DashboardLoginFormProps = { @@ -26,42 +27,24 @@ export default function DashboardLoginForm({ idps }: DashboardLoginFormProps) { const router = useRouter(); - // const api = createApiClient(useEnvContext()); - // - // useEffect(() => { - // const logout = async () => { - // try { - // await api.post("/auth/logout"); - // console.log("user logged out"); - // } catch (e) {} - // }; - // - // logout(); - // }); - + const { env } = useEnvContext(); const t = useTranslations(); + function getSubtitle() { + return t("loginStart"); + } + return ( - - + +
- {t('pangolinLogoAlt')} +
-
-

- {t('welcome')} -

-

- {t('loginStart')} -

+
+

{getSubtitle()}

- + { console.error(e); - setError( - formatAxiosError(e, t('signupError')) - ); + setError(formatAxiosError(e, t("signupError"))); }); if (res && res.status === 200) { @@ -117,24 +116,21 @@ export default function SignupForm({ setLoading(false); } + function getSubtitle() { + return t("authCreateAccount"); + } + return (
- {t('pangolinLogoAlt')}
-
-

- {t('welcome')} -

-

- {t('authCreateAccount')} -

+
+

{getSubtitle()}

@@ -148,7 +144,7 @@ export default function SignupForm({ name="email" render={({ field }) => ( - {t('email')} + {t("email")} @@ -161,7 +157,7 @@ export default function SignupForm({ name="password" render={({ field }) => ( - {t('password')} + {t("password")} @@ -174,7 +170,9 @@ export default function SignupForm({ name="confirmPassword" render={({ field }) => ( - {t('confirmPassword')} + + {t("confirmPassword")} + @@ -190,7 +188,7 @@ export default function SignupForm({ )} diff --git a/src/components/BrandingLogo.tsx b/src/components/BrandingLogo.tsx new file mode 100644 index 00000000..34771333 --- /dev/null +++ b/src/components/BrandingLogo.tsx @@ -0,0 +1,50 @@ +"use client"; + +import { useEnvContext } from "@app/hooks/useEnvContext"; +import { useTheme } from "next-themes"; +import Image from "next/image"; +import { useEffect, useState } from "react"; + +type BrandingLogoProps = { + width: number; + height: number; +}; + +export default function BrandingLogo(props: BrandingLogoProps) { + const { env } = useEnvContext(); + const { theme } = useTheme(); + const [path, setPath] = useState(""); // Default logo path + + useEffect(() => { + function getPath() { + let lightOrDark = theme; + + if (theme === "system" || !theme) { + lightOrDark = window.matchMedia("(prefers-color-scheme: dark)") + .matches + ? "dark" + : "light"; + } + + if (lightOrDark === "light") { + return "/logo/word_mark_black.png"; + } + + return "/logo/word_mark_white.png"; + } + + const path = getPath(); + setPath(path); + }, [theme, env]); + + return ( + path && ( + Logo + ) + ); +}