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
+125
-9
@@ -1,6 +1,6 @@
|
||||
# white-label — admin panel branding from the admin panel
|
||||
|
||||
The admin panel shows the **client's brand** (logo + name) on the login screen and in
|
||||
The admin panel shows the **client's brand** (logo + name) on the sign-in screens and in
|
||||
the navigation, taken from **SiteSettings** — i.e. set by the editor in the admin panel,
|
||||
not hard-coded. Each client logs in to "their own" panel.
|
||||
|
||||
@@ -45,6 +45,8 @@ whiteLabel: {
|
||||
| `iconField` | `'favicon'` | `graphics.Icon` → `AdminIcon` (max 28×28 px) |
|
||||
| `titleSuffix` | none (`adminMeta` builds one from the site name) | static `admin.meta.titleSuffix`, wins over `adminMeta` |
|
||||
| `credit` | `true` | `false` or `{ text?, url? }` |
|
||||
| `signIn` | `true` | the look of the sign-in screens (below); `false` = Payload's own screens; `{ allScreens, accent, logoMadeFor, languages, svgLogo }` |
|
||||
| `brandAccess` | `'editor'` | who may change the name, logo and icon fields: `'admin'` = admins only (field-level access, no schema change) |
|
||||
|
||||
The plugin overrides `admin.components.graphics.Logo` / `Icon` from the project config (its
|
||||
values win over yours); `afterLogin` / `afterNavLinks` are appended.
|
||||
@@ -109,12 +111,123 @@ image. The plugin now fills the panel's `<head>` from Site settings, **with or w
|
||||
`og:site_name` = the site name, `og:image` = `/api/ipal/admin-og`; open `$URL/api/ipal/admin-og` → the
|
||||
preview image; paste the link in Slack → the site's name and image.
|
||||
|
||||
## Logo on the login screen
|
||||
## The sign-in screens — `whiteLabel.signIn` (on by default with `whiteLabel`)
|
||||
|
||||
`AdminLogo` is the LARGE logo on the login screen (Payload uses `graphics.Icon` for
|
||||
the small icon in the navigation). It renders quite a bit larger (`maxHeight 120 / maxWidth
|
||||
420`), so the client's brand is clear at login. The small nav icon is `favicon`
|
||||
through `AdminIcon`.
|
||||
One look for every screen a person passes before the panel: **a dark panel with the client's logo — or the site's
|
||||
name — beside the form**, the same look as the WordPress sibling (IAWL). On a phone the panel is a band above the
|
||||
form. The panel is dark in both themes; the form's side follows the admin theme (light or dark).
|
||||
|
||||
| On the panel | From | When it is missing |
|
||||
|---|---|---|
|
||||
| Label "Administration panel" (pl: "Panel administracyjny") | the plugin's texts (`ipal:signInPanelLabel`) | — |
|
||||
| The client's logo, a link to the site | Site settings → **Logo** (`logoField`) | the site's name |
|
||||
| The site's name, a link to the site | Site settings → **Site name** (`nameField`) | the site's host, then nothing |
|
||||
| Languages of the panel, as links | `i18n.supportedLanguages` (IAPL turns on English and Polish) | hidden with one language |
|
||||
|
||||
**Nothing is set in `.env` or in code: the logo and the name are the two fields of Site settings the public site
|
||||
uses too.** No new field, collection or global — so **no migration on Postgres / SQLite** and no change for MongoDB.
|
||||
With nothing set, the panel shows the label and the site's host: no Intecion and no Payload mark is put on a
|
||||
client's sign-in page (the credit line under the form is separate: `credit: false`).
|
||||
|
||||
**The logo.** Shown inside 240 × 72 px (192 × 56 on a phone), never enlarged or cropped, with its `width` and
|
||||
`height` set (no layout shift). It stands **on a white plate**, so any ordinary logo works on the dark panel; a
|
||||
logo drawn for dark grounds (a white logo) sets `signIn: { logoMadeFor: 'dark' }` and the plate is left out.
|
||||
Recommended upload: PNG or WebP, 480 px wide or more, without empty margins.
|
||||
|
||||
### Which screens
|
||||
|
||||
| Screens | How they get the look | What the project does |
|
||||
|---|---|---|
|
||||
| Login; the 2FA code, 2FA setup and "2FA setup required" screens; e-mail verification | through `AdminLogo` and `SafeTotpView` — components **already in the import map** of every site with `whiteLabel` / 2FA | nothing: an upgrade needs no edit and no `generate:importmap` |
|
||||
| Forgot password, reset password, create first user, logout, "unauthorized" | one admin provider, `SignInLook` | `whiteLabel: { signIn: { allScreens: true } }`, then `pnpm payload generate:importmap` and commit the map |
|
||||
|
||||
```ts
|
||||
iapl({
|
||||
whiteLabel: { signIn: { allScreens: true } }, // the project starter writes this for new sites
|
||||
})
|
||||
```
|
||||
|
||||
**Every sign-in screen (`allScreens`).** It adds `@intecion/ipal-kit/admin#SignInLook` to `admin.components.providers`
|
||||
— the one new import-map entry of this feature, which is why it is not on by default: a site must upgrade without
|
||||
touching its map. A provider the map lacks would render nothing, the whole panel included, so in production the
|
||||
plugin looks for the entry in `importMap.js` on disk at start and **leaves the provider out when it is not there**:
|
||||
the login and 2FA screens keep the look, and the log says `[iapl] The sign-in look covers only the login and 2FA
|
||||
screens … Run "pnpm payload generate:importmap"`. Without `allScreens` the other screens are Payload's own.
|
||||
|
||||
### Options
|
||||
|
||||
| `signIn:` | Default | Meaning |
|
||||
|---|---|---|
|
||||
| `false` | — | Payload's own sign-in screens; `AdminLogo` is the plain logo, as before |
|
||||
| `allScreens` | `false` | the look on every sign-in screen (above) |
|
||||
| `accent` | the shared blue `#0070c0` | a hex colour for the button, the links and the focus ring; it carries white text, so check its contrast (4.5:1) |
|
||||
| `logoMadeFor` | `'light'` | `'dark'`: no white plate behind the logo |
|
||||
| `languages` | shown when the panel has 2+ languages | `false`: no language links, and no `/api/ipal/admin-language` endpoint |
|
||||
| `svgLogo` | shown (as a picture) | `false`: an SVG logo is not shown on the sign-in screens; the site's name is |
|
||||
|
||||
**Language links.** Plain links, no script: `GET /api/ipal/admin-language?lng=pl` writes Payload's own language
|
||||
cookie (`payload-lng`, one year) and sends the browser back to the admin page it came from. Public, because nobody
|
||||
is signed in yet; it accepts only a language the panel supports (else `400`) and returns only to a path inside the
|
||||
admin route (taken from the `Referer`; anything else → the admin root), so it cannot be used to send someone to
|
||||
another site.
|
||||
|
||||
### What a public page may show — the security rules
|
||||
|
||||
The sign-in page is open to anyone, so what reaches it is narrow on purpose:
|
||||
|
||||
- **Text:** the site's name only, as plain text (escaped; one line, at most 80 characters). No description, no
|
||||
rich text, no link an editor can write: the panel's only links are the site's own root and the language links.
|
||||
- **Pictures:** the logo as an `<img>` — a picture in `<img>` never runs script, an SVG included. `svgLogo: false`
|
||||
leaves SVG out anyway. Only an `http(s)` or site-relative address is used. The plugin serves **no new file** for
|
||||
it: the logo is the media file at its own address, with the media collection's own headers and cache rules. On
|
||||
the 2FA screens (the session is refused `media`) the server fetches it as an anonymous visitor would — images
|
||||
only, at most 512 KB — and inlines it; when that fails the name is shown (`inlineImages`, above).
|
||||
- **Who can change it:** whoever may edit Site settings — editors and admins by default, as for the public site's
|
||||
name and logo. `whiteLabel: { brandAccess: 'admin' }` makes the three brand fields (name, logo, icon)
|
||||
admin-only with field-level access; other Site settings stay with editors.
|
||||
- **Accounts:** the forms, their messages and their limits are Payload's and the 2FA package's own, untouched.
|
||||
The look adds no text that depends on an account, so nothing new says whether an account exists.
|
||||
- **The stylesheet** is inline, has no `url()`, no font file and no request to another host; `accent` is accepted
|
||||
only as a hex colour. No script is added to the login screen. On the 2FA screens one small client component
|
||||
gives the six code boxes a name for screen readers ("Digit 2 of 6") and the numeric keyboard; it changes
|
||||
attributes only.
|
||||
|
||||
### Accessibility
|
||||
|
||||
Label and name contrast on the panel ≥ 7:1; text, links and the button on the form's side ≥ 4.5:1 in both themes;
|
||||
a visible focus ring on every control; no animation except the button's colour change, and none with
|
||||
`prefers-reduced-motion`; Windows high-contrast keeps the panel's edge; no sideways scroll from 320 px; the logo's
|
||||
alternative text is the site's name; the language links are a `<nav>` named "Language" with the current one marked
|
||||
(`aria-current`). The stylesheet and the panel come in the page's own response and are put on the page in the same
|
||||
step as the form: no flash of Payload's plain screen and no layout shift.
|
||||
A browser without `:has()` (Firefox before 121) shows Payload's plain layout.
|
||||
|
||||
### Restyle it
|
||||
|
||||
Set the custom properties on `:root` in the admin's `custom.scss` (the defaults have no specificity):
|
||||
`--iapl-signin-primary`, `--iapl-signin-primary-hover`, `--iapl-signin-primary-text`, `--iapl-signin-link`,
|
||||
`--iapl-signin-focus`, `--iapl-signin-bg`, `--iapl-signin-text`, `--iapl-signin-muted`, `--iapl-signin-border`,
|
||||
`--iapl-signin-field-border`, `--iapl-signin-panel`, `--iapl-signin-panel-text`, `--iapl-signin-panel-label`,
|
||||
`--iapl-signin-panel-glow` (three numbers, `R G B`), `--iapl-signin-panel-radius`, `--iapl-signin-panel-inset`,
|
||||
`--iapl-signin-split` (the panel's share of the width), `--iapl-signin-radius`. Classes you may rely on:
|
||||
`iapl-signin` (with `iapl-signin--logo` or `iapl-signin--name`), `iapl-signin__label`, `iapl-signin__brand`
|
||||
(`--plate`, `--name`), `iapl-signin__languages`, `iapl-credit--login`.
|
||||
|
||||
### Your own screens, or none
|
||||
|
||||
- **Off:** `whiteLabel: { signIn: false }` — Payload's screens with the plain logo; nothing else changes.
|
||||
- **Your own logo in code:** set `admin.components.graphics.Logo` yourself and do not use `whiteLabel` (the plugin's
|
||||
`Logo` wins while `whiteLabel` is on); or keep `whiteLabel` and filter what Site settings holds.
|
||||
- **Your own panel:** `SignInPanel` (the panel with its stylesheet) and `SignInLook` (the provider) are exported
|
||||
from `@intecion/ipal-kit/admin`; wire them in `admin.components` with `serverProps: { look: { … } }`
|
||||
(`SignInLookProps`). From the main entry: `resolveSignInLook`, `loadSignInBrand`, `signInLogo`, `signInName`,
|
||||
`fitLogo`, `isSvgUpload`, `languageLinks`, `LANGUAGE_NAMES`, `signInCss`, `isHexColour`, `signInProviderActive`,
|
||||
`buildAdminLanguageEndpoint`, `adminPathFromReferer`, and the constants `SIGN_IN_LOOK`, `SIGN_IN_STYLE_ID`,
|
||||
`SIGN_IN_LOGO_BOX`, `SIGN_IN_NAME_MAX`, `ADMIN_LANGUAGE_PATH`; types `SignInLookOptions`, `ResolvedSignInLook`,
|
||||
`SignInLookProps`, `SignInBrand`, `SignInLogo`, `LanguageLink`, `SignInPanelProps`, `SignInLookProviderProps`.
|
||||
- **Verify:** `curl -s $URL/admin/login | grep -c 'class="iapl-signin'` → `1`; open `/admin/login` at a phone
|
||||
width; with `allScreens`, `curl -s $URL/admin/forgot | grep -c 'class="iapl-signin'` → `1`;
|
||||
`curl -si "$URL/api/ipal/admin-language?lng=xx"` → `400`.
|
||||
|
||||
## How it works
|
||||
|
||||
@@ -141,15 +254,18 @@ through `AdminIcon`.
|
||||
|
||||
- [ ] `iapl({ whiteLabel: true })`
|
||||
- [ ] The editor uploaded `logo` and `favicon` in SiteSettings (+ `siteName`)
|
||||
- [ ] `signIn: { allScreens: true }` for the look on every sign-in screen (new sites: yes)
|
||||
- [ ] `pnpm generate:importmap`
|
||||
- [ ] Restart dev / rebuild → the panel shows the client's brand on login and in the nav
|
||||
|
||||
## Turn off, override, extend
|
||||
|
||||
- **Turn off:** without `whiteLabel` (default) the panel has Payload branding; `credit: false` hides the credit;
|
||||
- **Turn off:** without `whiteLabel` (default) the panel has Payload branding; `signIn: false` keeps Payload's
|
||||
sign-in screens; `credit: false` hides the credit;
|
||||
`agency: false` removes the agency everywhere; `adminMeta: false` restores Payload's link preview.
|
||||
- **Override:** other fields / global (`settingsSlug`, `nameField`, `logoField`, `iconField`), credit text and URL,
|
||||
`titleSuffix`. With `whiteLabel` on, the plugin overrides `graphics.Logo` / `Icon` from the project
|
||||
config — set your own graphics components without `whiteLabel`.
|
||||
- **Extend:** `AdminLogo`, `AdminIcon`, `IntecionCredit` (props `agency`, `text`, `url`, `variant`) from
|
||||
`@intecion/ipal-kit/admin` can be wired manually into `admin.components` with your own `serverProps`.
|
||||
- **Extend:** `AdminLogo`, `AdminIcon`, `IntecionCredit` (props `agency`, `text`, `url`, `variant`), `SignInPanel`
|
||||
and `SignInLook` from `@intecion/ipal-kit/admin` can be wired manually into `admin.components` with your own
|
||||
`serverProps`.
|
||||
|
||||
Reference in New Issue
Block a user