forked from fa/breadcrumb-the-shire
- Server renders initial file-upload state (src, alt, label text, has-current class) so there is no flash of broken-image icon while JS boots. JS no longer duplicates that work — it only reacts to user input (select, clear, drag-and-drop) and uses data-current-src solely to restore the server file after a blob preview. - Clicking the current preview image now opens the file dialog, mirrors the Replace button, with hover affordance (cursor + primary border). - Drop the transparency checker pattern in the preview — the admin UI does not need Figma-style transparency semantics. Preview is now a flat theme-aware surface (--app-preview-bg) that keeps white or black logos visible against a neutral gray. - Move tenant favicon out of the aside into the Master-data tab as its own details block next to the Tenant-logos section. Uses the same barrier-form pattern (HTML5 form attribute + app-file-upload.phtml) for a consistent instant-upload UX. - Tenant-logo slot label is a native <label> element — picks up the global form-label typography and spacing, no custom muted-color class needed. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
49 lines
1.9 KiB
PHTML
49 lines
1.9 KiB
PHTML
<?php
|
|
|
|
/**
|
|
* Single-theme tenant-logo slot. Uses the standard app-file-upload.phtml
|
|
* partial for the drop-zone UI (upload + current preview + replace + delete),
|
|
* wired to a pair of barrier forms via the HTML5 form attribute.
|
|
*
|
|
* Required view vars:
|
|
* $tenantUuid, $logoTheme ('light'|'dark'), $hasLogo (bool),
|
|
* $fieldLabel, $uploadFormId, $deleteFormId, $canUpdate (bool)
|
|
*/
|
|
|
|
$tenantUuid = (string) ($tenantUuid ?? '');
|
|
$logoTheme = (string) ($logoTheme ?? 'light');
|
|
$hasLogo = (bool) ($hasLogo ?? false);
|
|
$fieldLabel = (string) ($fieldLabel ?? '');
|
|
$uploadFormId = (string) ($uploadFormId ?? '');
|
|
$deleteFormId = (string) ($deleteFormId ?? '');
|
|
$canUpdate = (bool) ($canUpdate ?? false);
|
|
$previewUrl = $hasLogo
|
|
? 'admin/tenants/logo-file?uuid=' . rawurlencode($tenantUuid) . '&theme=' . rawurlencode($logoTheme) . '&size=256'
|
|
: '';
|
|
?>
|
|
<div class="tenant-logo-slot">
|
|
<label><?php e($fieldLabel); ?></label>
|
|
<?php if ($canUpdate && $uploadFormId !== ''): ?>
|
|
<?php
|
|
$fileUpload = [
|
|
'name' => 'logo',
|
|
'accept' => 'image/svg+xml,image/png,image/jpeg,image/webp',
|
|
'hint' => t('Allowed file types: SVG, PNG, JPG, WEBP'),
|
|
'currentSrc' => $previewUrl,
|
|
'currentLabel' => $fieldLabel,
|
|
'formId' => $uploadFormId,
|
|
'deleteFormId' => $hasLogo && $deleteFormId !== '' ? $deleteFormId : '',
|
|
'deleteConfirm' => t('Delete this logo?'),
|
|
];
|
|
require templatePath('partials/app-file-upload.phtml');
|
|
?>
|
|
<div class="tenant-logo-actions">
|
|
<button type="submit" form="<?php e($uploadFormId); ?>" class="secondary outline small">
|
|
<?php e(t('Save')); ?>
|
|
</button>
|
|
</div>
|
|
<?php elseif ($hasLogo): ?>
|
|
<img class="tenant-logo-readonly-preview" src="<?php e($previewUrl); ?>" alt="<?php e($fieldLabel); ?>">
|
|
<?php endif; ?>
|
|
</div>
|