add primary color branding to the page

This commit is contained in:
Fred KISSIE
2025-11-15 02:38:46 +01:00
parent d003436179
commit 8f152bdf9f
4 changed files with 53 additions and 4 deletions

View File

@@ -1743,6 +1743,7 @@
"authPageBrandingQuestionRemove": "Are you sure you want to remove the branding for Auth Pages ?", "authPageBrandingQuestionRemove": "Are you sure you want to remove the branding for Auth Pages ?",
"authPageBrandingDeleteConfirm": "Confirm Delete Branding", "authPageBrandingDeleteConfirm": "Confirm Delete Branding",
"brandingLogoURL": "Logo URL", "brandingLogoURL": "Logo URL",
"brandingPrimaryColor": "Primary Color",
"brandingLogoWidth": "Width (px)", "brandingLogoWidth": "Width (px)",
"brandingLogoHeight": "Height (px)", "brandingLogoHeight": "Height (px)",
"brandingOrgTitle": "Title for Organization Auth Page", "brandingOrgTitle": "Title for Organization Auth Page",

View File

@@ -43,7 +43,11 @@ const bodySchema = z
resourceTitle: z.string(), resourceTitle: z.string(),
resourceSubtitle: z.string().optional(), resourceSubtitle: z.string().optional(),
orgTitle: z.string().optional(), orgTitle: z.string().optional(),
orgSubtitle: z.string().optional() orgSubtitle: z.string().optional(),
primaryColor: z
.string()
.regex(/^#([0-9a-f]{6}|[0-9a-f]{3})$/i)
.optional()
}) })
.strict(); .strict();

View File

@@ -76,7 +76,11 @@ const AuthPageFormSchema = z.object({
orgTitle: z.string().optional(), orgTitle: z.string().optional(),
orgSubtitle: z.string().optional(), orgSubtitle: z.string().optional(),
resourceTitle: z.string(), resourceTitle: z.string(),
resourceSubtitle: z.string().optional() resourceSubtitle: z.string().optional(),
primaryColor: z
.string()
.regex(/^#([0-9a-f]{6}|[0-9a-f]{3})$/i)
.optional()
}); });
export default function AuthPageBrandingForm({ export default function AuthPageBrandingForm({
@@ -114,7 +118,8 @@ export default function AuthPageBrandingForm({
`Authenticate to access {{resourceName}}`, `Authenticate to access {{resourceName}}`,
resourceSubtitle: resourceSubtitle:
branding?.resourceSubtitle ?? branding?.resourceSubtitle ??
`Choose your preferred authentication method for {{resourceName}}` `Choose your preferred authentication method for {{resourceName}}`,
primaryColor: branding?.primaryColor ?? `#f36117` // default pangolin primary color
} }
}); });
@@ -204,6 +209,40 @@ export default function AuthPageBrandingForm({
id="auth-page-branding-form" id="auth-page-branding-form"
className="flex flex-col gap-8 items-stretch" className="flex flex-col gap-8 items-stretch"
> >
<FormField
control={form.control}
name="primaryColor"
render={({ field }) => (
<FormItem className="">
<FormLabel>
{t("brandingPrimaryColor")}
</FormLabel>
<div className="flex items-center gap-2">
<label
className="size-8 rounded-sm"
aria-hidden="true"
style={{
backgroundColor:
field.value
}}
>
<input
type="color"
{...field}
className="sr-only"
/>
</label>
<FormControl>
<Input {...field} />
</FormControl>
</div>
<FormMessage />
</FormItem>
)}
/>
<div className="grid md:grid-cols-5 gap-3 items-start"> <div className="grid md:grid-cols-5 gap-3 items-start">
<FormField <FormField
control={form.control} control={form.control}

View File

@@ -390,7 +390,12 @@ export default function ResourceAuthPortal(props: ResourceAuthPortalProps) {
: 100; : 100;
return ( return (
<div> <div
style={{
// @ts-expect-error
"--primary": isUnlocked() ? props.branding?.primaryColor : null
}}
>
{!accessDenied ? ( {!accessDenied ? (
<div> <div>
{isUnlocked() && build === "enterprise" ? ( {isUnlocked() && build === "enterprise" ? (