utility: let setInfoBlock also clear

This commit is contained in:
Wolfsblvt
2025-02-22 21:50:58 +01:00
parent 7f9960fa7a
commit 8aadada0e2

View File

@ -2260,10 +2260,15 @@ export function arraysEqual(a, b) {
/**
* Updates the content and style of an information block
* @param {string | HTMLElement} target - The CSS selector or the HTML element of the information block
* @param {string | HTMLElement} content - The message to display inside the information block (supports HTML) or an HTML element
* @param {string | HTMLElement?} content - The message to display inside the information block (supports HTML) or an HTML element
* @param {'hint' | 'info' | 'warning' | 'error'} [type='info'] - The type of message, which determines the styling of the information block
*/
export function setInfoBlock(target, content, type = 'info') {
if (!content) {
clearInfoBlock(target);
return;
}
const infoBlock = typeof target === 'string' ? document.querySelector(target) : target;
if (infoBlock) {
infoBlock.className = `info-block ${type}`;