103 lines
3.5 KiB
JavaScript
103 lines
3.5 KiB
JavaScript
import { jsx as _jsx } from "react/jsx-runtime";
|
|
import { getPayload } from 'payload';
|
|
async function loadBranding(settingsSlug, nameField, imageField) {
|
|
try {
|
|
// Consumer alias — resolved in the project's build, hidden from plugin tsc.
|
|
const spec = '@payload-config';
|
|
const mod = await import(spec);
|
|
const payload = await getPayload({
|
|
config: mod.default
|
|
});
|
|
const settings = await payload.findGlobal({
|
|
slug: settingsSlug,
|
|
depth: 1
|
|
});
|
|
const name = typeof settings[nameField] === 'string' ? settings[nameField] : null;
|
|
const image = settings[imageField];
|
|
const url = image && typeof image === 'object' && typeof image.url === 'string' ? image.url : null;
|
|
return {
|
|
name,
|
|
url
|
|
};
|
|
} catch {
|
|
return {
|
|
name: null,
|
|
url: null
|
|
};
|
|
}
|
|
}
|
|
/** Admin panel logo (login screen + nav). SiteSettings `logo`, falls back to `siteName`. */ export async function AdminLogo(props = {}) {
|
|
const { settingsSlug = 'site-settings', nameField = 'siteName', imageField = 'logo' } = props;
|
|
const { name, url } = await loadBranding(settingsSlug, nameField, imageField);
|
|
if (url) {
|
|
return /*#__PURE__*/ _jsx("img", {
|
|
src: url,
|
|
alt: name ?? '',
|
|
style: {
|
|
maxHeight: 60,
|
|
maxWidth: 240,
|
|
width: 'auto',
|
|
height: 'auto'
|
|
}
|
|
});
|
|
}
|
|
if (name) return /*#__PURE__*/ _jsx("div", {
|
|
style: {
|
|
fontSize: '1.5rem',
|
|
fontWeight: 600
|
|
},
|
|
children: name
|
|
});
|
|
return null // nothing configured → Payload's default
|
|
;
|
|
}
|
|
/** Admin panel icon (small nav glyph). SiteSettings `favicon`, falls back to initials. */ export async function AdminIcon(props = {}) {
|
|
const { settingsSlug = 'site-settings', nameField = 'siteName', imageField = 'favicon' } = props;
|
|
const { name, url } = await loadBranding(settingsSlug, nameField, imageField);
|
|
if (url) {
|
|
return /*#__PURE__*/ _jsx("img", {
|
|
src: url,
|
|
alt: name ?? '',
|
|
style: {
|
|
maxHeight: 28,
|
|
maxWidth: 28,
|
|
width: 'auto',
|
|
height: 'auto'
|
|
}
|
|
});
|
|
}
|
|
if (name) return /*#__PURE__*/ _jsx("div", {
|
|
style: {
|
|
fontWeight: 700
|
|
},
|
|
children: name.slice(0, 2).toUpperCase()
|
|
});
|
|
return null;
|
|
}
|
|
/**
|
|
* Discreet vendor credit shown at the bottom of the admin nav: "Technology by
|
|
* Intecion.com". This is the PLUGIN VENDOR's credit (Intecion ships ipal-kit),
|
|
* not client data — so a sensible default here is fine and A0-safe. The client's
|
|
* own brand still owns the logo/name above (AdminLogo); this is a small line
|
|
* stating who provides the technology. Text/URL overridable; turn it off with
|
|
* `whiteLabel: { credit: false }`.
|
|
*
|
|
* Wired by ipalKit into admin.components.afterNavLinks.
|
|
*/ export function IntecionCredit(props = {}) {
|
|
const { text = 'Technology by Intecion.com', url = 'https://intecion.com' } = props;
|
|
return /*#__PURE__*/ _jsx("a", {
|
|
href: url,
|
|
target: "_blank",
|
|
rel: "noopener noreferrer",
|
|
style: {
|
|
display: 'block',
|
|
padding: '0.75rem 1rem',
|
|
fontSize: '0.75rem',
|
|
opacity: 0.6,
|
|
textDecoration: 'none'
|
|
},
|
|
children: text
|
|
});
|
|
}
|
|
|
|
//# sourceMappingURL=adminGraphics.js.map
|