@prenta/admin 2.14.8 → 2.15.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (74) hide show
  1. package/CHANGELOG.md +9 -0
  2. package/dist/AdminRoot.d.ts.map +1 -1
  3. package/dist/AdminRoot.js +11 -6
  4. package/dist/AdminRoot.js.map +1 -1
  5. package/dist/LoginRoot.js +3 -3
  6. package/dist/LoginRoot.js.map +1 -1
  7. package/dist/__tests__/assets/prenta-logo.test.js +26 -10
  8. package/dist/__tests__/assets/prenta-logo.test.js.map +1 -1
  9. package/dist/__tests__/layout/sidebar-brand.render.test.js +25 -22
  10. package/dist/__tests__/layout/sidebar-brand.render.test.js.map +1 -1
  11. package/dist/__tests__/views/appearance-settings.render.test.js +9 -0
  12. package/dist/__tests__/views/appearance-settings.render.test.js.map +1 -1
  13. package/dist/__tests__/views/login-branding.render.test.js +15 -30
  14. package/dist/__tests__/views/login-branding.render.test.js.map +1 -1
  15. package/dist/assets/prenta-logo.d.ts +18 -21
  16. package/dist/assets/prenta-logo.d.ts.map +1 -1
  17. package/dist/assets/prenta-logo.js +24 -12
  18. package/dist/assets/prenta-logo.js.map +1 -1
  19. package/dist/components/AuthBranding.d.ts +40 -0
  20. package/dist/components/AuthBranding.d.ts.map +1 -0
  21. package/dist/components/AuthBranding.js +81 -0
  22. package/dist/components/AuthBranding.js.map +1 -0
  23. package/dist/index.d.ts +2 -0
  24. package/dist/index.d.ts.map +1 -1
  25. package/dist/index.js +1 -0
  26. package/dist/index.js.map +1 -1
  27. package/dist/layout/Sidebar.d.ts.map +1 -1
  28. package/dist/layout/Sidebar.js +15 -23
  29. package/dist/layout/Sidebar.js.map +1 -1
  30. package/dist/prenta-admin.css +1 -1
  31. package/dist/views/ForgotPassword.d.ts +3 -1
  32. package/dist/views/ForgotPassword.d.ts.map +1 -1
  33. package/dist/views/ForgotPassword.js +6 -4
  34. package/dist/views/ForgotPassword.js.map +1 -1
  35. package/dist/views/Login.d.ts +2 -5
  36. package/dist/views/Login.d.ts.map +1 -1
  37. package/dist/views/Login.js +9 -74
  38. package/dist/views/Login.js.map +1 -1
  39. package/dist/views/ResetPassword.d.ts +3 -1
  40. package/dist/views/ResetPassword.d.ts.map +1 -1
  41. package/dist/views/ResetPassword.js +5 -3
  42. package/dist/views/ResetPassword.js.map +1 -1
  43. package/dist/views/SetupWizard.d.ts +3 -1
  44. package/dist/views/SetupWizard.d.ts.map +1 -1
  45. package/dist/views/SetupWizard.js +5 -3
  46. package/dist/views/SetupWizard.js.map +1 -1
  47. package/dist/views/settings/BrandPreviewCard.d.ts.map +1 -1
  48. package/dist/views/settings/BrandPreviewCard.js +5 -6
  49. package/dist/views/settings/BrandPreviewCard.js.map +1 -1
  50. package/dist/views/settings/BrandingCard.d.ts.map +1 -1
  51. package/dist/views/settings/BrandingCard.js +4 -3
  52. package/dist/views/settings/BrandingCard.js.map +1 -1
  53. package/package.json +3 -3
  54. package/src/AdminRoot.tsx +15 -5
  55. package/src/LoginRoot.tsx +9 -2
  56. package/src/__tests__/assets/prenta-logo.test.tsx +27 -10
  57. package/src/__tests__/layout/sidebar-brand.render.test.tsx +29 -25
  58. package/src/__tests__/views/appearance-settings.render.test.tsx +11 -0
  59. package/src/__tests__/views/login-branding.render.test.tsx +15 -30
  60. package/src/assets/prenta-logo.tsx +55 -53
  61. package/src/components/AuthBranding.tsx +125 -0
  62. package/src/index.ts +2 -0
  63. package/src/layout/Sidebar.tsx +51 -49
  64. package/src/views/ForgotPassword.tsx +12 -5
  65. package/src/views/Login.tsx +15 -89
  66. package/src/views/ResetPassword.tsx +12 -5
  67. package/src/views/SetupWizard.tsx +12 -5
  68. package/src/views/settings/BrandPreviewCard.tsx +20 -27
  69. package/src/views/settings/BrandingCard.tsx +18 -1
  70. package/dist/components/LogoPlaceholder.d.ts +0 -17
  71. package/dist/components/LogoPlaceholder.d.ts.map +0 -1
  72. package/dist/components/LogoPlaceholder.js +0 -13
  73. package/dist/components/LogoPlaceholder.js.map +0 -1
  74. package/src/components/LogoPlaceholder.tsx +0 -55
@@ -0,0 +1,125 @@
1
+ 'use client'
2
+
3
+ import { useEffect, useRef, useState, type ReactElement } from 'react'
4
+ import { PrentaBrandLogo } from '../assets/prenta-logo.js'
5
+ import { useTheme } from './ThemeProvider.js'
6
+ import { cmsApi } from '../lib/api.js'
7
+
8
+ export interface AuthBrandingConfig {
9
+ logo?: string | null
10
+ name?: string
11
+ tagline?: string
12
+ }
13
+
14
+ export interface ResolvedAuthBrand {
15
+ /** Resolved custom logo URL (uploaded in Appearance or set in config), if any. */
16
+ effectiveLogo: string | null
17
+ /** True when `branding.logo === null` explicitly hides the top hero logo. */
18
+ hideLogo: boolean
19
+ /** True when a custom logo or whitelabel opt-out replaces the default Prenta hero. */
20
+ showPermanentFooter: boolean
21
+ /** Brand display name (falls back to `'Prenta CMS'`). */
22
+ brandName: string
23
+ /** Handler to mark a broken custom logo URL as failed so the Prenta fallback renders. */
24
+ onLogoError: (src: string) => void
25
+ }
26
+
27
+ /**
28
+ * Resolve the brand lockup for pre-authenticated screens (Login, SetupWizard,
29
+ * ForgotPassword, ResetPassword). Uses the cached `adminBrand` when warm, and
30
+ * falls back to `/public/brand` on fresh browsers. Whenever no custom logo has
31
+ * been uploaded or configured, the bundled `Prënta` wordmark serves as the
32
+ * default placeholder.
33
+ */
34
+ export function useAuthBrand(branding?: AuthBrandingConfig): ResolvedAuthBrand {
35
+ const { adminBrand, resolvedTheme } = useTheme()
36
+ const [publicPrimaryUrl, setPublicPrimaryUrl] = useState<string | null>(null)
37
+ const [publicDarkUrl, setPublicDarkUrl] = useState<string | null>(null)
38
+ const [failedSrcs, setFailedSrcs] = useState<Set<string>>(new Set())
39
+ const fetchedRef = useRef(false)
40
+
41
+ const configLogo = branding?.logo
42
+ const hideLogo = configLogo === null
43
+
44
+ useEffect(() => {
45
+ if (adminBrand.primaryUrl || hideLogo) return
46
+ if (fetchedRef.current) return
47
+ fetchedRef.current = true
48
+
49
+ let cancelled = false
50
+ void (async () => {
51
+ const res = await cmsApi<{
52
+ public?: {
53
+ primary?: { url?: string } | null
54
+ dark?: { url?: string } | null
55
+ } | null
56
+ }>('/public/brand')
57
+ if (cancelled) return
58
+ const primary = res.data?.public?.primary?.url
59
+ const dark = res.data?.public?.dark?.url
60
+ if (primary) setPublicPrimaryUrl(primary)
61
+ if (dark) setPublicDarkUrl(dark)
62
+ })()
63
+ return () => {
64
+ cancelled = true
65
+ }
66
+ }, [adminBrand.primaryUrl, hideLogo])
67
+
68
+ const usable = (url: string | null | undefined): string | null =>
69
+ url && !failedSrcs.has(url) ? url : null
70
+
71
+ const darkPref = resolvedTheme === 'dark' ? (adminBrand.darkUrl ?? publicDarkUrl) : null
72
+ const appearanceLogo = usable(darkPref) ?? usable(adminBrand.primaryUrl ?? publicPrimaryUrl)
73
+ const staticLogo = typeof configLogo === 'string' ? usable(configLogo) : null
74
+ const effectiveLogo = hideLogo ? null : (appearanceLogo ?? staticLogo)
75
+ const brandName = branding?.name ?? 'Prenta CMS'
76
+
77
+ const onLogoError = (src: string) => {
78
+ setFailedSrcs((prev) => (prev.has(src) ? prev : new Set(prev).add(src)))
79
+ }
80
+
81
+ return {
82
+ effectiveLogo,
83
+ hideLogo,
84
+ showPermanentFooter: hideLogo || Boolean(effectiveLogo),
85
+ brandName,
86
+ onLogoError,
87
+ }
88
+ }
89
+
90
+ /**
91
+ * Top-of-card brand hero shared across Login, SetupWizard, ForgotPassword, and
92
+ * ResetPassword. Shows the uploaded/configured logo when present, otherwise the
93
+ * cropped `Prënta` placeholder wordmark.
94
+ */
95
+ export function AuthBrandHero({ brand }: { brand: ResolvedAuthBrand }): ReactElement | null {
96
+ if (brand.hideLogo) return null
97
+ if (brand.effectiveLogo) {
98
+ return (
99
+ <img
100
+ src={brand.effectiveLogo}
101
+ alt={brand.brandName}
102
+ className="mx-auto mb-4 max-h-16 w-auto object-contain"
103
+ draggable={false}
104
+ onError={() => brand.onLogoError(brand.effectiveLogo!)}
105
+ />
106
+ )
107
+ }
108
+ return <PrentaBrandLogo className="text-foreground mx-auto mb-4 h-11 w-auto" />
109
+ }
110
+
111
+ /**
112
+ * Subtle permanent CMS attribution rendered beneath auth cards whenever a
113
+ * tenant's custom logo (or whitelabel opt-out) replaces the top Prenta hero.
114
+ */
115
+ export function AuthPrentaFooter(): ReactElement {
116
+ return (
117
+ <div
118
+ aria-label="Powered by Prenta CMS"
119
+ className="text-muted-foreground mt-6 flex items-center justify-center gap-1.5 text-xs select-none"
120
+ >
121
+ <span>Powered by</span>
122
+ <PrentaBrandLogo decorative className="text-foreground/75 h-3.5 w-auto shrink-0" />
123
+ </div>
124
+ )
125
+ }
package/src/index.ts CHANGED
@@ -2,6 +2,8 @@ export { AdminRoot } from './AdminRoot.js'
2
2
  export type { AdminRootProps } from './AdminRoot.js'
3
3
  export { LoginRoot } from './LoginRoot.js'
4
4
  export type { LoginRootProps } from './LoginRoot.js'
5
+ export { PrentaBrandLogo, PrentaMark, PRENTA_ACCENT } from './assets/prenta-logo.js'
6
+ export type { BrandLogoProps } from './assets/prenta-logo.js'
5
7
 
6
8
  // Pluggable canvas renderers for custom section types (see `AdminRoot`'s
7
9
  // `sectionRenderers` prop). The types structurally mirror
@@ -8,30 +8,25 @@ import { adminPortalContainer } from '../lib/portal-container.js'
8
8
  import { TIER_MEDIA } from '../lib/tiers.js'
9
9
  import { useTheme } from '../components/ThemeProvider.js'
10
10
  import { PrentaBrandLogo, PrentaMark } from '../assets/prenta-logo.js'
11
- import { LogoPlaceholder } from '../components/LogoPlaceholder.js'
12
11
  import { activeChildPath, hasActiveDescendant, isPathActive, type NavItem } from './nav-config.js'
13
12
  import { useNavItems } from './use-nav-items.js'
14
13
 
15
14
  /**
16
15
  * Sidebar brand lockup.
17
16
  *
18
- * Resolution order follows the Appearance spec, sourcing from the live
19
- * appearance context (DB-backed brand, cached in localStorage) and falling
20
- * back to legacy `config.admin.branding`, then a neutral logo placeholder for
21
- * branded-but-logo-less installs, then the bundled Prenta mark/wordmark for
22
- * un-branded installs. The placeholder replaces the old initials badge, which
23
- * read as a user avatar (the real account avatar already sits top-right).
24
- * Dark-mode uses the dark logo when one is configured. Logos are never
25
- * stretched/cropped (object-contain). Kit sizes (cms-responsive.css): the
26
- * full logo is 24px tall and at most 150px wide; the rail mark is 26px.
17
+ * Resolution order sources from the live appearance context (DB-backed brand,
18
+ * cached in localStorage) and falls back to legacy `config.admin.branding`,
19
+ * then to the bundled Prenta wordmark / `Prë` mark as the default placeholder
20
+ * until the operator uploads their own logo in Settings → Admin appearance.
21
+ * Dark mode uses the dark logo when one is configured. Logos are never
22
+ * stretched/cropped (`object-contain`).
27
23
  */
28
24
  function BrandLogo({ config, collapsed }: { config?: any; collapsed: boolean }) {
29
25
  const { adminBrand, resolvedTheme } = useTheme()
30
26
  const branding = config?.admin?.branding
31
27
  const configLogo = branding?.logo
28
+ const hideLogo = configLogo === null
32
29
  const brandName = branding?.name
33
- const initials = adminBrand.initials
34
- const hasInitials = Boolean(initials) && initials !== 'A'
35
30
 
36
31
  // Track image URLs that fail to load (broken/expired/deleted asset) so the
37
32
  // resolution falls through to the next option instead of showing the browser's
@@ -50,7 +45,7 @@ function BrandLogo({ config, collapsed }: { config?: any; collapsed: boolean })
50
45
  const darkPref = resolvedTheme === 'dark' ? adminBrand.darkUrl : null
51
46
  const primary = usable(darkPref) ?? usable(adminBrand.primaryUrl)
52
47
  const mark = usable(adminBrand.markUrl)
53
- const cfg = usable(configLogo)
48
+ const cfg = typeof configLogo === 'string' ? usable(configLogo) : null
54
49
  const alt = brandName ?? 'Admin'
55
50
 
56
51
  // Wide horizontal logos scale down to fit the rail / sidebar header instead
@@ -72,8 +67,8 @@ function BrandLogo({ config, collapsed }: { config?: any; collapsed: boolean })
72
67
  if (primary)
73
68
  return <img src={primary} alt={alt} className={logoClass} onError={onErr(primary)} />
74
69
  if (cfg) return <img src={cfg} alt={alt} className={logoClass} onError={onErr(cfg)} />
75
- if (hasInitials) return <LogoPlaceholder tone="sidebar" />
76
- return <PrentaMark className="h-[26px] w-[26px]" />
70
+ if (hideLogo) return null
71
+ return <PrentaMark className="text-txt h-auto w-8 object-contain" />
77
72
  }
78
73
 
79
74
  if (primary) {
@@ -106,20 +101,13 @@ function BrandLogo({ config, collapsed }: { config?: any; collapsed: boolean })
106
101
  )
107
102
  }
108
103
 
109
- if (hasInitials) {
110
- return <LogoPlaceholder tone="sidebar" label={brandName ?? alt} />
104
+ if (hideLogo) {
105
+ return brandName ? (
106
+ <span className="text-body text-txt truncate font-medium">{brandName}</span>
107
+ ) : null
111
108
  }
112
109
 
113
- if (brandName) {
114
- return (
115
- <div className="flex min-w-0 items-center gap-2.5">
116
- <PrentaMark className="h-[26px] w-[26px] shrink-0" />
117
- <span className="text-body text-txt truncate font-medium">{brandName}</span>
118
- </div>
119
- )
120
- }
121
-
122
- return <PrentaBrandLogo className="h-6 w-auto" />
110
+ return <PrentaBrandLogo className="text-txt h-6 w-auto" />
123
111
  }
124
112
 
125
113
  export interface SidebarProps {
@@ -177,28 +165,42 @@ export function Sidebar({
177
165
  <NavTree items={navItems} ctx={{ collapsed, currentPath, onNavigate }} />
178
166
  </nav>
179
167
 
180
- {/* Only at >=1025px: the 769-1024px rail can't expand, and the mobile
181
- drawer has its own dismiss. */}
182
- <div className="border-bdr not-narrow:block hidden shrink-0 border-t p-2">
183
- <button
184
- type="button"
185
- onClick={onToggleCollapse}
186
- className={`rounded-7 text-meta text-sub hover:bg-acc-l hover:text-acc flex w-full cursor-pointer items-center gap-[9px] overflow-hidden border-0 bg-transparent px-2.5 py-[7px] leading-[normal] font-normal whitespace-nowrap ${
187
- collapsed ? 'justify-center' : ''
188
- }`}
189
- aria-expanded={!collapsed}
190
- aria-label={collapsed ? 'Expand sidebar' : 'Collapse sidebar'}
191
- >
192
- {/* 19px: the kit's inline chevron sits on the 12px text baseline, so the button is 33px. */}
193
- <span className="flex h-[19px] shrink-0 items-center">
194
- {collapsed ? (
195
- <ChevronRight className="h-[15px] w-[15px]" strokeWidth={1.75} aria-hidden />
196
- ) : (
197
- <ChevronLeft className="h-[15px] w-[15px]" strokeWidth={1.75} aria-hidden />
198
- )}
199
- </span>
200
- <span className={collapsed ? 'sr-only' : ''}>Collapse sidebar</span>
201
- </button>
168
+ {/* Permanent CMS brand footer + desktop collapse toggle (>=1025px). */}
169
+ <div className="border-bdr shrink-0 border-t p-2">
170
+ {collapsed ? (
171
+ <div className="flex items-center justify-center py-1.5" title="Powered by Prenta CMS">
172
+ <PrentaMark label="Powered by Prenta CMS" className="text-sub h-auto w-6 opacity-80" />
173
+ </div>
174
+ ) : (
175
+ <div
176
+ aria-label="Powered by Prenta CMS"
177
+ className="text-hint text-faint flex items-center gap-1.5 px-2.5 py-1.5 whitespace-nowrap select-none"
178
+ >
179
+ <span>Powered by</span>
180
+ <PrentaBrandLogo decorative className="text-sub h-3.5 w-auto shrink-0" />
181
+ </div>
182
+ )}
183
+ <div className="not-narrow:block hidden">
184
+ <button
185
+ type="button"
186
+ onClick={onToggleCollapse}
187
+ className={`rounded-7 text-meta text-sub hover:bg-acc-l hover:text-acc flex w-full cursor-pointer items-center gap-[9px] overflow-hidden border-0 bg-transparent px-2.5 py-[7px] leading-[normal] font-normal whitespace-nowrap ${
188
+ collapsed ? 'justify-center' : ''
189
+ }`}
190
+ aria-expanded={!collapsed}
191
+ aria-label={collapsed ? 'Expand sidebar' : 'Collapse sidebar'}
192
+ >
193
+ {/* 19px: the kit's inline chevron sits on the 12px text baseline, so the button is 33px. */}
194
+ <span className="flex h-[19px] shrink-0 items-center">
195
+ {collapsed ? (
196
+ <ChevronRight className="h-[15px] w-[15px]" strokeWidth={1.75} aria-hidden />
197
+ ) : (
198
+ <ChevronLeft className="h-[15px] w-[15px]" strokeWidth={1.75} aria-hidden />
199
+ )}
200
+ </span>
201
+ <span className={collapsed ? 'sr-only' : ''}>Collapse sidebar</span>
202
+ </button>
203
+ </div>
202
204
  </div>
203
205
  </aside>
204
206
  )
@@ -1,17 +1,25 @@
1
1
  'use client'
2
2
 
3
3
  import { useState, type FormEvent } from 'react'
4
- import { Shield, ArrowLeft, Loader2, CheckCircle2, AlertTriangle } from 'lucide-react'
4
+ import { ArrowLeft, Loader2, CheckCircle2, AlertTriangle } from 'lucide-react'
5
+ import {
6
+ AuthBrandHero,
7
+ AuthPrentaFooter,
8
+ useAuthBrand,
9
+ type AuthBrandingConfig,
10
+ } from '../components/AuthBranding.js'
5
11
  import { cmsApi } from '../lib/api.js'
6
12
 
7
13
  export interface ForgotPasswordProps {
8
14
  onNavigate: (path: string) => void
15
+ branding?: AuthBrandingConfig
9
16
  }
10
17
 
11
18
  const fieldClass =
12
19
  'w-full rounded-lg border border-border bg-input-background px-3 py-2.5 text-sm text-foreground focus-visible:border-ring focus-visible:ring-2 focus-visible:ring-ring/50 focus-visible:outline-none'
13
20
 
14
- export function ForgotPassword({ onNavigate }: ForgotPasswordProps) {
21
+ export function ForgotPassword({ onNavigate, branding }: ForgotPasswordProps) {
22
+ const brand = useAuthBrand(branding)
15
23
  const [email, setEmail] = useState('')
16
24
  const [submitting, setSubmitting] = useState(false)
17
25
  const [sent, setSent] = useState(false)
@@ -48,9 +56,7 @@ export function ForgotPassword({ onNavigate }: ForgotPasswordProps) {
48
56
  <div className="bg-muted flex min-h-screen items-center justify-center px-4">
49
57
  <div className="w-full max-w-md">
50
58
  <div className="mb-8 text-center">
51
- <div className="bg-primary mx-auto mb-4 flex h-14 w-14 items-center justify-center rounded-xl">
52
- <Shield className="text-primary-foreground h-7 w-7" />
53
- </div>
59
+ <AuthBrandHero brand={brand} />
54
60
  <h1 className="text-foreground text-2xl font-medium">Reset Password</h1>
55
61
  <p className="text-muted-foreground mt-2">
56
62
  {sent
@@ -137,6 +143,7 @@ export function ForgotPassword({ onNavigate }: ForgotPasswordProps) {
137
143
  </button>
138
144
  )}
139
145
  </div>
146
+ {brand.showPermanentFooter && <AuthPrentaFooter />}
140
147
  </div>
141
148
  </div>
142
149
  )
@@ -1,11 +1,13 @@
1
1
  'use client'
2
2
 
3
- import { useState, useEffect, useRef, type FormEvent } from 'react'
3
+ import { useState, useEffect, type FormEvent } from 'react'
4
4
  import { Eye, EyeOff, AlertTriangle, CheckCircle2, Loader2 } from 'lucide-react'
5
- import { PrentaBrandLogo } from '../assets/prenta-logo.js'
6
- import { LogoPlaceholder } from '../components/LogoPlaceholder.js'
7
- import { useTheme } from '../components/ThemeProvider.js'
8
- import { cmsApi } from '../lib/api.js'
5
+ import {
6
+ AuthBrandHero,
7
+ AuthPrentaFooter,
8
+ useAuthBrand,
9
+ type AuthBrandingConfig,
10
+ } from '../components/AuthBranding.js'
9
11
  import { hasLoggedOutQuery } from '../lib/logout-redirect.js'
10
12
 
11
13
  export interface CaptchaConfig {
@@ -18,11 +20,7 @@ export interface CaptchaConfig {
18
20
  * sidebar so integrators only need to set it once. `logo` should be a URL or
19
21
  * data URL; pass `null` to opt out of any logo entirely.
20
22
  */
21
- interface LoginBrandingConfig {
22
- logo?: string | null
23
- name?: string
24
- tagline?: string
25
- }
23
+ type LoginBrandingConfig = AuthBrandingConfig
26
24
 
27
25
  export interface LoginProps {
28
26
  onLogin: (
@@ -254,45 +252,10 @@ export function Login({
254
252
  const [totpError, setTotpError] = useState('')
255
253
  const [verifying, setVerifying] = useState(false)
256
254
 
257
- // Brand logo, sourced to match the admin sidebar (see resolution note below).
258
- // `adminBrand` is the ThemeProvider cache the sidebar paints from (hydrated
259
- // from localStorage on mount); `publicLogo` is fetched only when that cache
260
- // is empty (a fresh browser that hasn't loaded the admin yet).
261
- const { adminBrand } = useTheme()
262
- const [publicLogo, setPublicLogo] = useState<string | null>(null)
263
- // Site initials resolved from `/public/brand`. Used only to detect whether
264
- // the install is "branded" on a fresh browser (no cache, no config name), so
265
- // the logo-less fallback can pick the placeholder over the Prenta wordmark.
266
- const [publicInitials, setPublicInitials] = useState<string | null>(null)
267
- const publicBrandFetched = useRef(false)
255
+ const brand = useAuthBrand(branding)
268
256
 
269
257
  useCaptchaScript(captchaConfig?.provider, captchaConfig?.siteKey)
270
258
 
271
- useEffect(() => {
272
- // The cached admin brand (exactly what the sidebar last rendered) wins and
273
- // needs no network. Only reach for the unauthenticated `/public/brand`
274
- // endpoint on a fresh browser with no cache, and never when the integrator
275
- // opted out of a logo entirely (`branding.logo === null`).
276
- if (adminBrand.primaryUrl || branding?.logo === null) return
277
- if (publicBrandFetched.current) return
278
- publicBrandFetched.current = true
279
-
280
- let cancelled = false
281
- void (async () => {
282
- const res = await cmsApi<{
283
- public?: { primary?: { url?: string } | null; initials?: string } | null
284
- }>('/public/brand')
285
- if (cancelled) return
286
- const url = res.data?.public?.primary?.url
287
- if (url) setPublicLogo(url)
288
- const initials = res.data?.public?.initials
289
- if (initials) setPublicInitials(initials)
290
- })()
291
- return () => {
292
- cancelled = true
293
- }
294
- }, [adminBrand.primaryUrl, branding?.logo])
295
-
296
259
  const loggedOut = hasLoggedOutQuery()
297
260
  const canSubmit = email.trim() && password && !submitting
298
261
 
@@ -374,55 +337,17 @@ export function Login({
374
337
  const enabledProviders =
375
338
  oauthProviders?.filter((p) => ['google', 'github', 'microsoft'].includes(p)) ?? []
376
339
 
377
- // Logo resolution mirrors the admin sidebar so the login screen shows the
378
- // same brand mark a user sees once signed in. Precedence (best available
379
- // pre-auth):
380
- // 1. the logo uploaded in Settings → Appearance — read from the
381
- // ThemeProvider cache the sidebar paints from, then (fresh browsers with
382
- // no cache) the unauthenticated `/public/brand` endpoint;
383
- // 2. the static `config.admin.branding.logo` URL;
384
- // 3. a neutral logo placeholder when the install is branded (a site/brand
385
- // name is set) but no logo has been uploaded yet — matching the sidebar;
386
- // 4. the bundled Prenta wordmark for a fully un-branded install.
387
- // `branding.logo === null` still hides the logo entirely (whitelabel opt-out).
388
- const configLogo = branding?.logo
389
- const hideLogo = configLogo === null
390
- const appearanceLogo = adminBrand.primaryUrl ?? publicLogo
391
- const effectiveLogo = appearanceLogo ?? (typeof configLogo === 'string' ? configLogo : null)
392
- const brandName = branding?.name ?? 'Prenta CMS'
340
+ const brandName = brand.brandName
393
341
  const brandTagline = branding?.tagline ?? 'Sign in to your account'
394
- const showLogo = !hideLogo
395
- // "Branded" = the operator has set a brand identity. Mirrors the sidebar's
396
- // `hasInitials` signal (initials are derived from the site title) plus an
397
- // explicit `branding.name` and, for fresh browsers, the initials returned by
398
- // `/public/brand`. Drives the placeholder vs. Prenta-wordmark fallback so a
399
- // configured client install never shows Prenta branding. `'A'` is the
400
- // unset-title default, so it counts as un-branded.
401
- const hasInitials = (value: string | null | undefined) => Boolean(value) && value !== 'A'
402
- const isBranded =
403
- Boolean(branding?.name) || hasInitials(adminBrand.initials) || hasInitials(publicInitials)
404
- // A logo image or the bundled wordmark already carries the brand — a
405
- // separate headline would duplicate it. Keep the name only for the
406
- // branded-but-logo-less placeholder.
407
- const showBrandName = !effectiveLogo && isBranded
342
+ // Show the configured brand name as a heading when no custom logo image
343
+ // already displays it.
344
+ const showBrandName = !brand.effectiveLogo && Boolean(branding?.name)
408
345
 
409
346
  return (
410
347
  <main className="bg-muted flex min-h-screen items-center justify-center px-4">
411
348
  <div className="w-full max-w-md">
412
349
  <div className="mb-8 text-center">
413
- {showLogo &&
414
- (effectiveLogo ? (
415
- <img
416
- src={effectiveLogo}
417
- alt={brandName}
418
- className="mx-auto mb-4 max-h-16 w-auto object-contain"
419
- draggable={false}
420
- />
421
- ) : isBranded ? (
422
- <LogoPlaceholder tone="login" />
423
- ) : (
424
- <PrentaBrandLogo className="mx-auto mb-4 h-14 w-auto" />
425
- ))}
350
+ <AuthBrandHero brand={brand} />
426
351
  {!showBrandName && <h1 className="sr-only">Sign in</h1>}
427
352
  {showBrandName && <h1 className="text-foreground text-2xl font-medium">{brandName}</h1>}
428
353
  <p className="text-muted-foreground mt-2">{brandTagline}</p>
@@ -642,6 +567,7 @@ export function Login({
642
567
  )}
643
568
  </form>
644
569
  )}
570
+ {brand.showPermanentFooter && <AuthPrentaFooter />}
645
571
  </div>
646
572
  </main>
647
573
  )
@@ -1,18 +1,26 @@
1
1
  'use client'
2
2
 
3
3
  import { useState, type FormEvent } from 'react'
4
- import { Shield, Eye, EyeOff, Loader2, CheckCircle2, AlertTriangle, XCircle } from 'lucide-react'
4
+ import { Eye, EyeOff, Loader2, CheckCircle2, AlertTriangle, XCircle } from 'lucide-react'
5
+ import {
6
+ AuthBrandHero,
7
+ AuthPrentaFooter,
8
+ useAuthBrand,
9
+ type AuthBrandingConfig,
10
+ } from '../components/AuthBranding.js'
5
11
  import { cmsApi } from '../lib/api.js'
6
12
 
7
13
  export interface ResetPasswordProps {
8
14
  onNavigate: (path: string) => void
9
15
  token: string | null
16
+ branding?: AuthBrandingConfig
10
17
  }
11
18
 
12
19
  const fieldClass =
13
20
  'w-full rounded-lg border border-border bg-input-background px-3 py-2.5 text-sm text-foreground focus-visible:border-ring focus-visible:ring-2 focus-visible:ring-ring/50 focus-visible:outline-none'
14
21
 
15
- export function ResetPassword({ onNavigate, token }: ResetPasswordProps) {
22
+ export function ResetPassword({ onNavigate, token, branding }: ResetPasswordProps) {
23
+ const brand = useAuthBrand(branding)
16
24
  const [password, setPassword] = useState('')
17
25
  const [confirmPassword, setConfirmPassword] = useState('')
18
26
  const [showPassword, setShowPassword] = useState(false)
@@ -87,9 +95,7 @@ export function ResetPassword({ onNavigate, token }: ResetPasswordProps) {
87
95
  <div className="bg-muted flex min-h-screen items-center justify-center px-4">
88
96
  <div className="w-full max-w-md">
89
97
  <div className="mb-8 text-center">
90
- <div className="bg-primary mx-auto mb-4 flex h-14 w-14 items-center justify-center rounded-xl">
91
- <Shield className="text-primary-foreground h-7 w-7" />
92
- </div>
98
+ <AuthBrandHero brand={brand} />
93
99
  <h1 className="text-foreground text-2xl font-medium">
94
100
  {success ? 'Password Reset' : 'Choose New Password'}
95
101
  </h1>
@@ -200,6 +206,7 @@ export function ResetPassword({ onNavigate, token }: ResetPasswordProps) {
200
206
  </form>
201
207
  )}
202
208
  </div>
209
+ {brand.showPermanentFooter && <AuthPrentaFooter />}
203
210
  </div>
204
211
  </div>
205
212
  )
@@ -1,7 +1,13 @@
1
1
  'use client'
2
2
 
3
3
  import { useState, type FormEvent } from 'react'
4
- import { Shield, Eye, EyeOff, CheckCircle2, AlertTriangle } from 'lucide-react'
4
+ import { Eye, EyeOff, CheckCircle2, AlertTriangle } from 'lucide-react'
5
+ import {
6
+ AuthBrandHero,
7
+ AuthPrentaFooter,
8
+ useAuthBrand,
9
+ type AuthBrandingConfig,
10
+ } from '../components/AuthBranding.js'
5
11
 
6
12
  export interface SetupWizardProps {
7
13
  onComplete: (data: {
@@ -10,6 +16,7 @@ export interface SetupWizardProps {
10
16
  password: string
11
17
  }) => Promise<{ success: boolean; error?: string }>
12
18
  siteName?: string
19
+ branding?: AuthBrandingConfig
13
20
  }
14
21
 
15
22
  function passwordStrength(pw: string): { score: number; label: string; color: string } {
@@ -29,7 +36,8 @@ function passwordStrength(pw: string): { score: number; label: string; color: st
29
36
  const fieldClass =
30
37
  'w-full rounded-lg border border-border bg-input-background px-3 py-2.5 text-sm text-foreground focus-visible:border-ring focus-visible:ring-2 focus-visible:ring-ring/50 focus-visible:outline-none'
31
38
 
32
- export function SetupWizard({ onComplete, siteName = 'Prenta CMS' }: SetupWizardProps) {
39
+ export function SetupWizard({ onComplete, siteName = 'Prenta CMS', branding }: SetupWizardProps) {
40
+ const brand = useAuthBrand(branding)
33
41
  const [name, setName] = useState('')
34
42
  const [email, setEmail] = useState('')
35
43
  const [password, setPassword] = useState('')
@@ -96,9 +104,7 @@ export function SetupWizard({ onComplete, siteName = 'Prenta CMS' }: SetupWizard
96
104
  <div className="bg-muted flex min-h-screen items-center justify-center px-4">
97
105
  <div className="w-full max-w-md">
98
106
  <div className="mb-8 text-center">
99
- <div className="bg-primary mx-auto mb-4 flex h-14 w-14 items-center justify-center rounded-xl">
100
- <Shield className="text-primary-foreground h-7 w-7" />
101
- </div>
107
+ <AuthBrandHero brand={brand} />
102
108
  <h1 className="text-foreground text-2xl font-medium">Welcome to {siteName}</h1>
103
109
  <p className="text-muted-foreground mt-2">Create your admin account to get started</p>
104
110
  </div>
@@ -233,6 +239,7 @@ export function SetupWizard({ onComplete, siteName = 'Prenta CMS' }: SetupWizard
233
239
  be replaced by the login screen.
234
240
  </p>
235
241
  </form>
242
+ {brand.showPermanentFooter && <AuthPrentaFooter />}
236
243
  </div>
237
244
  </div>
238
245
  )