mirror of
https://github.com/pterodactyl/panel.git
synced 2026-12-03 04:45:44 -05:00
Added a configurable panel company/brand logo.
## Extra Details:
- New logo is used for:
- Login page
- Navigation bar
- Page Favicon
- Panel Falls back to the default Ptero logo when no custom one is set.
- Supported File Formats: PNG, JPEG, WebP, AVIF, ICO, and safe SVG
files.
---
## Preview:
<img width="912" height="151"
alt="{67E9647B-AD26-41F8-8272-8B7F4D1CDFB7}"
src="https://github.com/user-attachments/assets/1af9c52b-ad4a-4f82-bb67-14a2b662beb2"
/>
<img width="916" height="256"
alt="{F49323AE-974C-4C16-B129-D60D3494BA0F}"
src="https://github.com/user-attachments/assets/3e35d7f1-c95b-4007-bf1f-69e2ce9891a2"
/>
<img width="1749" height="940"
alt="{252E88D0-BA45-43C8-99E2-5B31E81B739E}"
src="https://github.com/user-attachments/assets/2e807035-bbd0-48ca-823a-4510a9be696e"
/>
<img width="996" height="452" alt="image"
src="https://github.com/user-attachments/assets/c0bef229-285c-4cda-9291-7295e70b2189"
/>
84 lines
2.7 KiB
TypeScript
84 lines
2.7 KiB
TypeScript
import { useEffect, useState } from 'react';
|
|
import type { AdminSettings } from '@/api/admin/settings/queries';
|
|
import Button from '@/components/elements/Button';
|
|
import Label from '@/components/elements/Label';
|
|
import { FileInput } from '@/components/form/controls';
|
|
|
|
const logoTypes = 'image/png,image/jpeg,image/webp,image/avif,image/x-icon,image/svg+xml';
|
|
|
|
type Props = {
|
|
settings: AdminSettings;
|
|
pendingFile: File | null;
|
|
removePending: boolean;
|
|
disabled: boolean;
|
|
onFileSelected: (file: File | undefined) => void;
|
|
onRemove: () => void;
|
|
};
|
|
|
|
export default function LogoSettingsForm({
|
|
settings,
|
|
pendingFile,
|
|
removePending,
|
|
disabled,
|
|
onFileSelected,
|
|
onRemove,
|
|
}: Props) {
|
|
const readOnly = settings.meta.load_environment_only;
|
|
const [previewUrl, setPreviewUrl] = useState<string | null>(null);
|
|
|
|
useEffect(() => {
|
|
if (!pendingFile) {
|
|
setPreviewUrl(null);
|
|
|
|
return;
|
|
}
|
|
|
|
const url = URL.createObjectURL(pendingFile);
|
|
setPreviewUrl(url);
|
|
|
|
return () => URL.revokeObjectURL(url);
|
|
}, [pendingFile]);
|
|
|
|
const logoPreview = removePending ? null : previewUrl ?? settings.logo;
|
|
|
|
return (
|
|
<div className='mt-6 border-t border-border pt-6'>
|
|
<Label as='h3'>Logo</Label>
|
|
<p className='input-help'>
|
|
Upload a logo to use as the Panel favicon, on the login page, and beside your company name.
|
|
</p>
|
|
<p className='input-help'>
|
|
PNG, JPEG, WebP, AVIF, ICO, and SVG files up to 10 MB are supported.
|
|
</p>
|
|
{logoPreview && (
|
|
<div className='mt-6 flex items-center gap-4'>
|
|
<img
|
|
src={logoPreview}
|
|
alt='Current panel logo'
|
|
className='h-20 w-20 rounded-sm border border-border bg-background object-contain p-2'
|
|
/>
|
|
<Button
|
|
type='button'
|
|
color='red'
|
|
isSecondary
|
|
disabled={readOnly || disabled}
|
|
onClick={onRemove}
|
|
>
|
|
Remove Logo
|
|
</Button>
|
|
</div>
|
|
)}
|
|
<div className='mt-6'>
|
|
<FileInput
|
|
aria-label='Upload logo'
|
|
accept={logoTypes}
|
|
disabled={readOnly || disabled}
|
|
onChange={(event) => {
|
|
onFileSelected(event.currentTarget.files?.[0]);
|
|
}}
|
|
/>
|
|
</div>
|
|
</div>
|
|
);
|
|
}
|