Adds smaller size messages
parent
bc5ae76534
commit
d5e30400d0
|
@ -124,19 +124,21 @@ class Messages {
|
|||
/**
|
||||
* Render message HTML
|
||||
*/
|
||||
public static function render($category, $key, $customMessage = null, $dismissible = null) {
|
||||
public static function render($category, $key, $customMessage = null, $dismissible = false, $small = false) {
|
||||
$config = self::get($category, $key);
|
||||
if (!$config) return '';
|
||||
|
||||
$message = $customMessage ?? $config['message'];
|
||||
$isDismissible = $dismissible ?? $config['dismissible'];
|
||||
$dismissClass = $isDismissible ? ' alert-dismissible fade show' : '';
|
||||
$dismissButton = $isDismissible ? '<button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"></button>' : '';
|
||||
$dismissButton = $isDismissible ? '<button type="button" class="btn-close' . ($small ? ' btn-close-sm' : '') . '" data-bs-dismiss="alert" aria-label="Close"></button>' : '';
|
||||
$smallClass = $small ? ' alert-sm' : '';
|
||||
|
||||
return sprintf(
|
||||
'<div class="alert alert-%s%s" role="alert">%s%s</div>',
|
||||
'<div class="alert alert-%s%s%s" role="alert">%s%s</div>',
|
||||
$config['type'],
|
||||
$dismissClass,
|
||||
$smallClass,
|
||||
htmlspecialchars($message),
|
||||
$dismissButton
|
||||
);
|
||||
|
@ -145,7 +147,7 @@ class Messages {
|
|||
/**
|
||||
* Store message in session for display after redirect
|
||||
*/
|
||||
public static function flash($category, $key, $customMessage = null, $dismissible = null) {
|
||||
public static function flash($category, $key, $customMessage = null, $dismissible = false, $small = false) {
|
||||
if (!isset($_SESSION['flash_messages'])) {
|
||||
$_SESSION['flash_messages'] = [];
|
||||
}
|
||||
|
@ -153,7 +155,8 @@ class Messages {
|
|||
'category' => $category,
|
||||
'key' => $key,
|
||||
'custom_message' => $customMessage,
|
||||
'dismissible' => $dismissible
|
||||
'dismissible' => $dismissible,
|
||||
'small' => $small
|
||||
];
|
||||
}
|
||||
|
||||
|
|
|
@ -188,7 +188,7 @@ if ($page == 'logout') {
|
|||
$server_endpoint = '/health';
|
||||
$server_status = $serverObject->getServerStatus($server_host, $server_port, $server_endpoint);
|
||||
if (!$server_status) {
|
||||
echo Messages::render('ERROR', 'DEFAULT', 'The Jilo Server is not running. Some data may be old and incorrect.', false);
|
||||
echo Messages::render('ERROR', 'DEFAULT', 'The Jilo Server is not running. Some data may be old and incorrect.', false, true);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -201,3 +201,17 @@ html, body {
|
|||
border: 1px solid gray;
|
||||
border-radius: 4px;
|
||||
}
|
||||
|
||||
/* messages system */
|
||||
.alert-sm {
|
||||
padding: 0.25rem 0.5rem;
|
||||
font-size: 0.875rem;
|
||||
line-height: 1.2;
|
||||
margin-bottom: 0.5rem;
|
||||
}
|
||||
|
||||
.alert-sm .btn-close-sm {
|
||||
padding: 0.25rem 0.25rem;
|
||||
margin: -0.125rem -0.125rem -0.125rem auto;
|
||||
font-size: 0.75rem;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue