refactor(ui): collapse Tile static class into appTile() helper
Align dashboard-tile primitive with the established helper-function + partial convention (like tokenSelectForm / multiSelectForm). Keeps the reusable substance (app-tile.phtml, .app-tile CSS) and makes the primitive discoverable for modules via core/Support/helpers/ui.php. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -1,30 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace MintyPHP\Support;
|
||||
|
||||
class Tile
|
||||
{
|
||||
public static function render(array $options = []): void
|
||||
{
|
||||
$defaults = [
|
||||
'href' => '#',
|
||||
'label' => '',
|
||||
'count' => null,
|
||||
'icon' => 'bi bi-grid-1x2',
|
||||
'iconBg' => null,
|
||||
'iconColor' => null,
|
||||
'class' => '',
|
||||
'tooltip' => '',
|
||||
'tooltipPos' => 'top',
|
||||
];
|
||||
|
||||
$data = array_merge($defaults, $options);
|
||||
$template = dirname(__DIR__, 2) . '/templates/partials/app-tile.phtml';
|
||||
if (!is_file($template)) {
|
||||
return;
|
||||
}
|
||||
|
||||
extract($data, EXTR_SKIP);
|
||||
require $template;
|
||||
}
|
||||
}
|
||||
@@ -803,3 +803,43 @@ function renderPageStyles(): void
|
||||
{
|
||||
renderStylePaths(appPageStylePaths());
|
||||
}
|
||||
|
||||
/**
|
||||
* Render a dashboard tile (icon + count + label, linking to a target URL).
|
||||
*
|
||||
* Options:
|
||||
* - href (string) Link target. Default: '#'.
|
||||
* - label (string) Tile label. Default: ''.
|
||||
* - count (string|null) Numeric or short textual value. Default: null.
|
||||
* - icon (string) Bootstrap-icon class. Default: 'bi bi-grid-1x2'.
|
||||
* - iconBg (string|null) CSS color for icon background.
|
||||
* - iconColor (string|null) CSS color for icon glyph.
|
||||
* - class (string) Extra CSS classes appended to .app-tile.
|
||||
* - tooltip (string) Tooltip text (already translated).
|
||||
* - tooltipPos (string) Tooltip position. Default: 'top'.
|
||||
*
|
||||
* @param array<string, mixed> $options
|
||||
*/
|
||||
function appTile(array $options = []): void
|
||||
{
|
||||
$defaults = [
|
||||
'href' => '#',
|
||||
'label' => '',
|
||||
'count' => null,
|
||||
'icon' => 'bi bi-grid-1x2',
|
||||
'iconBg' => null,
|
||||
'iconColor' => null,
|
||||
'class' => '',
|
||||
'tooltip' => '',
|
||||
'tooltipPos' => 'top',
|
||||
];
|
||||
|
||||
$data = array_merge($defaults, $options);
|
||||
$template = templatePath('partials/app-tile.phtml');
|
||||
if (!is_file($template)) {
|
||||
return;
|
||||
}
|
||||
|
||||
extract($data, EXTR_SKIP);
|
||||
require $template;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user