Sign-in look: the client's logo or the site's name on a dark panel beside the form (whiteLabel.signIn)
On by default with whiteLabel. The login screen and the 2FA screens get the look through AdminLogo and SafeTotpView, which every site already has in its import map: an upgrade needs no edit. allScreens adds one provider (SignInLook) for forgot / reset password, first user and logout; a production start leaves it out when the import map on disk lacks it. Logo and name come from Site settings: no new field, no migration. Language links through GET /api/ipal/admin-language (Payload's own cookie, back to an admin path only). Options: accent, logoMadeFor, languages, svgLogo; whiteLabel.brandAccess 'admin'. The 2FA code boxes get names for screen readers. Reference site and starter: allScreens on. Docs, agent guide, skills, tests. Co-Authored-By: Claude Fable 5.2 <[email protected]>
This commit is contained in:
co-authored by
Claude Fable 5.2
parent
e821d52d19
commit
b6c91a3a11
@@ -4,6 +4,8 @@ import { iaplT } from '../admin-i18n/t.js'
|
||||
import { settingsTexts } from '../admin-i18n/texts/settings.js'
|
||||
import { secondFactorPassed } from '../security/totp/secondFactor.js'
|
||||
import { publicImageDataUri, siteOrigin } from './publicImage.js'
|
||||
import { type SignInLookProps, signInProviderActive } from './signIn/brand.js'
|
||||
import { SignInPanel } from './signIn/SignInPanel.js'
|
||||
|
||||
/**
|
||||
* White-label admin branding: the Payload admin panel's logo (login + nav) and
|
||||
@@ -25,6 +27,8 @@ import { publicImageDataUri, siteOrigin } from './publicImage.js'
|
||||
*/
|
||||
|
||||
type BrandingProps = {
|
||||
/** Injected by Payload into admin server components. */
|
||||
i18n?: { language?: string; t: (key: never, vars?: Record<string, unknown>) => string }
|
||||
/** Upload field to render as the image. Default 'logo' (Logo) / 'favicon' (Icon). */
|
||||
imageField?: string
|
||||
/** `whiteLabel.inlineImages: false` — never fetch the image on the server for the 2FA screens. */
|
||||
@@ -37,6 +41,11 @@ type BrandingProps = {
|
||||
payload?: Payload
|
||||
/** SiteSettings global slug. Default 'site-settings'. */
|
||||
settingsSlug?: string
|
||||
/**
|
||||
* `whiteLabel.signIn`, set by the plugin on `graphics.Logo`: the logo's place on the login screen then holds
|
||||
* the sign-in panel (docs/white-label.md). Not set: the plain logo, as before.
|
||||
*/
|
||||
signIn?: SignInLookProps
|
||||
/** Injected by Payload into admin server components — the account looking at the panel. */
|
||||
user?: null | Record<string, unknown>
|
||||
}
|
||||
@@ -94,9 +103,17 @@ async function loadBranding(
|
||||
* Admin panel logo — this is the LARGE logo on the login / unauthorized screens
|
||||
* (Payload uses `graphics.Icon` for the small nav glyph). SiteSettings `logo`,
|
||||
* falls back to `siteName` text. Sized generously for the login screen.
|
||||
*
|
||||
* With `signIn` (the sign-in look, on by default with `whiteLabel`) it prints the sign-in panel instead: this
|
||||
* component is in the import map of every white-label site, so the look needs no new entry. When the provider
|
||||
* `SignInLook` already prints the panel (`signIn.allScreens`), it prints nothing.
|
||||
*/
|
||||
export async function AdminLogo(props: BrandingProps = {}) {
|
||||
const { imageField = 'logo', nameField = 'siteName', settingsSlug = 'site-settings' } = props
|
||||
if (props.signIn) {
|
||||
if (signInProviderActive(props.payload)) {return null}
|
||||
return <SignInPanel i18n={props.i18n} locale={props.locale} look={props.signIn} payload={props.payload} user={props.user} />
|
||||
}
|
||||
const { name, url } = await loadBranding(props, settingsSlug, nameField, imageField)
|
||||
if (url) {
|
||||
return (
|
||||
@@ -178,7 +195,7 @@ export function IntecionCredit(
|
||||
textDecoration: 'none',
|
||||
}
|
||||
return (
|
||||
<a href={url} rel="noopener noreferrer" style={style} target="_blank">
|
||||
<a className={`iapl-credit iapl-credit--${variant}`} href={url} rel="noopener noreferrer" style={style} target="_blank">
|
||||
{text}
|
||||
</a>
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user