From 46d681c6b825d21b3f698d793c4e630c687d90ad Mon Sep 17 00:00:00 2001
From: Jake Vanderwerf <get@jakevanderwerf.ca>
Date: Thu, 21 May 2026 21:41:53 +0000
Subject: [PATCH] =Major CustomBlocks.php overhaul, expanding block support and customization from the editor. theme.json should now be updated on new themes to set brand colours, etc. Also note: major change to .col vs .row alignment: simplifying it to .top .bottom vs the confusion of the differences for .col/.row .start and .a-start

---
 inc/helpers/ui.php |  123 ++++++++++++++++++++++++++---------------
 1 files changed, 78 insertions(+), 45 deletions(-)

diff --git a/inc/helpers/ui.php b/inc/helpers/ui.php
index 7b72fc1..aed22d6 100644
--- a/inc/helpers/ui.php
+++ b/inc/helpers/ui.php
@@ -19,19 +19,17 @@
     }
 
     ?>
-    <aside id="queue" class="left col start btw main" aria-expanded="false" >
-        <div class="status-actions row start nowrap">
-			<div class="refresh row btw">
-                <span class="countdown row" title="Will refresh again...">5</span>
-                <button class="refreshNow row" title="Check now">
-                    <?= jvbIcon('arrows-clockwise', ['title'=> 'Check now']) ?>
-                </button>
-            </div>
+    <aside id="queue" class="left col top main" aria-expanded="false" >
+        <div class="m-actions row left nowrap">
+			<button class="refresh row" title="Check now">
+				<?= jvbIcon('arrows-clockwise', ['title'=> 'Check now']) ?>
+				<span class="countdown row indicator" title="Will refresh again...">5</span>
+			</button>
             <div class="popup row"><span></span></div>
         </div>
 
-		<div class="header col start">
-			<h3>Queue Status</h3>
+		<div class="header col top">
+			<h2>Queue Status</h2>
 			<nav class="filters">
 				<?php
 				$filters = [
@@ -49,7 +47,7 @@
 					$active = ($i === 0) ? ' active': '';
 					?>
 					<input type="radio" id="qfilter-<?=$filter?>" name="qfilter" class="btn filter<?=$active?>" data-filter="<?=$filter?>">
-					<label for="qfilter-<?=$filter?>" data-count="0"><span class="count row"></span><?=$title?></label>
+					<label for="qfilter-<?=$filter?>" data-count="0"><span class="count indicator row"></span><?=$title?></label>
 					<?php
 					$i++;
 				}
@@ -57,14 +55,14 @@
 				?>
 			</nav>
 		</div>
-		<div class="qitems col a-start nowrap">
+		<div class="qitems item-grid col left nowrap">
 		</div>
-		<div class="queue-actions row btw nowrap">
+		<div class="queue-actions row x-btw nowrap">
 			<button class="dismiss-all">Clear Completed</button>
 			<button class="retry-all">Retry Failed</button>
 		</div>
     </aside>
-	<button class="qtoggle row" title="Show Queue" aria-controls="queue" >
+	<button class="qtoggle sticky" title="Show Queue" aria-controls="queue" >
 		<?= jvbIcon('floppy-disk') ?>
 		<span class="screen-reader-text"></span>
 		<span class="indicator"></span>
@@ -72,20 +70,20 @@
 	</button>
 	<template class="queueItem">
 		<div class="item">
-			<div class="header row btw">
+			<div class="header row x-btw">
 				<span class="type"></span>
 				<span class="status row"><?= jvbIcon('arrows-clockwise') ?><span class="screen-reader-text"></span></span>
 			</div>
 			<?php jvbRenderProgressBar('',false,false) ?>
 			<div class="info">
 				<div class="details"></div>
-				<div class="time row start">
+				<div class="time row left">
 					<?= jvbIcon('clock') ?>
 					<span class="started">Started: <time></time></span>
 					<span class="completed" hidden><span>Completed: </span><time></time></span>
 				</div>
 			</div>
-			<div class="actions row end">
+			<div class="actions row right">
 				<button class="retry" data-action="retry"><span>Retry</span><?= jvbIcon('arrows-clockwise')?></button>
 				<button class="cancel" data-action="cancel"><span>Cancel</span><?= jvbIcon('x-square')?></button>
 				<button class="refresh" data-action="refresh" title="Refresh to see changes"><span>Refresh</span><?= jvbIcon('arrows-clockwise')?></button>
@@ -101,7 +99,7 @@
 		<button></button>
 	</template>
 	<template class="emptyQueue">
-		<div class="empty-queue row">Everything is up to date.</div>
+		<div class="empty queue row">Everything is up to date.</div>
 	</template>
     <?php
 }
@@ -214,9 +212,9 @@
  * Outputs the search bar (likely don't need anymore)
  * @return string
  */
-function jvbSearch(string $placeholder = 'Search...', string $id = 'search'):string
+function jvbSearch(string $placeholder = 'Search...', string $id = 'search', string $label = '', string $buttonText = '', bool $buttonInside = false, bool $hideSearch = false):string
 {
-	return Form::search($placeholder, $id);
+	return Form::search($placeholder, $id, $label, $buttonText, $buttonInside, $hideSearch);
 }
 
 
@@ -273,7 +271,7 @@
     </aside>
     <template class="notificationPopup">
         <div class="toast" role="status" aria-live="polite">
-            <div class="toast-content row btw">
+            <div class="toast-content row x-btw">
                 <p></p>
                 <button type="button" class="close-toast" aria-label="Close">
                     <?= jvbIcon('x') ?>
@@ -364,7 +362,7 @@
 		echo '';
 		return '';
 	}
-	$header = '<nav class="tabs row start" role="tablist">';
+	$header = '<nav class="tabs row left" role="tablist">';
 	$content = '';
 	$i = 0;
 
@@ -377,12 +375,11 @@
 		$active = ($i === 0) ? ' active' : '';
 		$selected = ($i === 0) ? 'true' : 'false';
 		$hidden = (array_key_exists('hidden', $config)) ? ' hidden' : '';
-		$header .= '<button type="button" class="button tab'.$active.'" data-tab="'.$slug.'" role="tab" aria-selected="'.$selected.'"'.$hidden.'>
-			<h2 class="row">';
+		$header .= '<button type="button" class="button tab'.$active.'" data-tab="'.$slug.'" role="tab" aria-selected="'.$selected.'"'.$hidden.'>';
 			if (array_key_exists('icon', $config)) {
 				$header .= jvbIcon($config['icon']);
 			}
-			$header .= $config['title'].'</h2>
+			$header .= $config['title'].'
 		</button>';
 
 		//Content
@@ -391,8 +388,12 @@
 		if ($i !== 0) {
 			$content .= ' hidden';
 		}
-		$content .= '>
-			<h2>'.$config['title'].'</h2>';
+		$content .= '>';
+
+		if (array_key_exists('header', $config)) {
+			$content .= $config['header'];
+		} else {
+			$content .= '<h2>'.$config['title'].'</h2>';
 			if ( array_key_exists('description', $config)) {
 				if (!is_array($config['description'])) {
 					$content .= jvb_filter_content( $config['description']);
@@ -406,6 +407,9 @@
 				}
 
 			}
+		}
+
+
 
 		$content .= $config['content'].'
 		</div>';
@@ -430,7 +434,7 @@
 		<div class="bar">
 			<div class="fill"></div>
 		</div>
-		<div class="row btw">
+		<div class="row x-btw">
 			%s
 			<div class="details">
 				%s
@@ -447,24 +451,53 @@
 	return $bar;
 }
 
-function jvbFormStatus(string $message = '') {
-	return '<div class="restore-form col" hidden>
-			<h3>Looks like we left things hanging...</h3>
-			<p>We\'ve filled in the fields with what you put last time.</p>
-			<div class="actions">
-				<button type="button" data-action="clear-form">
-					'.jvbIcon('arrows-clockwise').'
-					<span>Start Over</span>
-				</button>
-				<button type="button" data-action="dismiss-restore">
-					'.jvbIcon('x').'
-					<span>Dismiss</span>
-				</button>
-			</div>
-		</div>
+function jvbFormStatus(string $message = ''):string
+{
+	return sprintf(
+		'%s
 		<div class="fstatus row" hidden>
 			<div class="spinner"></div>
 			<i class="icon"></i>
-			<p class="message">'.$message.'</p>
-		</div>';
+			<p class="message">%s</p>
+		</div>',
+		jvbFormRestore(),
+		$message
+	);
+}
+function jvbFormRestore():string
+{
+	return sprintf(
+		'<div class="restore-form col" hidden>
+			<h3>Looks like we left things hanging...</h3>
+			<p>Would you like to continue where you left off?</p>
+			<div class="actions">
+				<button class="restore" type="button" data-action="restore">%s<span>Restore</span></button>
+				<button type="button" class="discard" data-action="clear">
+					%s
+					<span>Discard</span>
+				</button>
+			</div>
+		</div>',
+		jvbFormIcon('clock-clockwise'),
+		jvbFormIcon('x'),
+	);
+}
+
+
+function jvbDarkModeToggle():string
+{
+	$checked = (is_user_logged_in() && current_user_can('prefers_dark_theme', true)) ? ' checked' : '';
+	$title = ($checked == '') ? 'Toggle Dark Mode' : 'Toggle Light Mode';
+	$showThemeSwitch = (bool)apply_filters('jvb_show_theme_switch', true);
+	$themeSwitch = sprintf(
+'<label title="%s" id="theme-switch" class="switch" for="theme-switcher">
+			<input class="theme-switch row" id="theme-switcher" name="theme-switcher" type="checkbox"%s data-setting="theme" data-theme role="switch" name="dark-mode" aria-label="Toggle dark mode">
+			<span class="slider">%s%s</span>
+		</label>',
+		$title,
+		$checked,
+		jvbIcon('sun-dim', ['title'=> 'Light Mode']),
+		jvbIcon('moon', ['title'=>'Dark Mode'])
+	);
+	return ($showThemeSwitch) ? $themeSwitch : '';
 }

--
Gitblit v1.10.0