Skip to content

Commit a326acb

Browse files
committed
Enhance accessibility and user experience across modals and dialogs
- Added ARIA roles and labels to modals in haproxy_config templates for improved screen reader support. - Included aria-label attributes on buttons to provide context for actions (e.g., close, cancel). - Implemented live value displays next to chart titles in metrics page for better visibility of current data. - Updated keydown event handlers to prevent default actions on Escape key to avoid unintended navigation or dialog closures. - Improved handling of focusable elements and overlays to ensure a smoother user experience when interacting with modals.
1 parent ba0f284 commit a326acb

11 files changed

Lines changed: 352 additions & 69 deletions

File tree

gearbox/internal/framework/templates/pages/alert_rules.templ

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -112,11 +112,11 @@ templ AlertRulesPage(user *models.User, serverID string, serverName string, serv
112112
</div>
113113

114114
<!-- Add/Edit Rule Modal -->
115-
<div id="add-rule-modal" class="hidden fixed inset-0 bg-black/50 flex items-center justify-center z-50">
115+
<div id="add-rule-modal" role="dialog" aria-modal="true" aria-labelledby="modal-title" class="hidden fixed inset-0 bg-black/50 flex items-center justify-center z-50">
116116
<div class="bg-white dark:bg-slate-800 rounded-lg shadow-xl max-w-lg w-full mx-4 max-h-[90vh] overflow-y-auto">
117117
<div class="p-4 border-b border-gray-200 dark:border-slate-700 flex items-center justify-between">
118118
<h3 id="modal-title" class="text-lg font-semibold text-gray-800 dark:text-gray-200">Add Alert Rule</h3>
119-
<button onclick="hideAddRuleModal()" class="text-gray-400 hover:text-gray-600 dark:hover:text-gray-300">
119+
<button onclick="hideAddRuleModal()" aria-label="Close" class="text-gray-400 hover:text-gray-600 dark:hover:text-gray-300">
120120
<svg class="w-6 h-6" fill="none" stroke="currentColor" viewBox="0 0 24 24">
121121
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M6 18L18 6M6 6l12 12"></path>
122122
</svg>

gearbox/internal/framework/templates/pages/alerts.templ

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -162,11 +162,11 @@ templ AlertsPage(user *models.User, servers []models.BoxConfig, perms *models.Us
162162
</div>
163163

164164
<!-- Alert Detail Modal -->
165-
<div id="alert-detail-modal" class="hidden fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center z-50">
165+
<div id="alert-detail-modal" role="dialog" aria-modal="true" aria-labelledby="alert-detail-modal-title" class="hidden fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center z-50">
166166
<div class="bg-white dark:bg-slate-800 rounded-lg shadow-xl max-w-2xl w-full mx-4 max-h-[90vh] overflow-y-auto">
167167
<div class="p-4 border-b border-gray-200 dark:border-slate-700 flex justify-between items-center">
168-
<h3 class="text-lg font-semibold text-gray-800 dark:text-gray-100">Alert Details</h3>
169-
<button onclick="hideAlertDetailModal()" class="text-gray-400 hover:text-gray-600 dark:hover:text-gray-300">
168+
<h3 id="alert-detail-modal-title" class="text-lg font-semibold text-gray-800 dark:text-gray-100">Alert Details</h3>
169+
<button onclick="hideAlertDetailModal()" aria-label="Close" class="text-gray-400 hover:text-gray-600 dark:hover:text-gray-300">
170170
<svg class="w-5 h-5" fill="none" stroke="currentColor" viewBox="0 0 24 24">
171171
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M6 18L18 6M6 6l12 12"></path>
172172
</svg>
@@ -251,11 +251,11 @@ templ AlertsPage(user *models.User, servers []models.BoxConfig, perms *models.Us
251251
</div>
252252

253253
<!-- Bulk Action Prompt Modal -->
254-
<div id="bulk-action-modal" class="hidden fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center z-50">
254+
<div id="bulk-action-modal" role="dialog" aria-modal="true" aria-labelledby="bulk-action-title" class="hidden fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center z-50">
255255
<div class="bg-white dark:bg-slate-800 rounded-lg shadow-xl max-w-md w-full mx-4">
256256
<div class="p-4 border-b border-gray-200 dark:border-slate-700 flex justify-between items-center">
257257
<h3 id="bulk-action-title" class="text-lg font-semibold text-gray-800 dark:text-gray-100">Bulk Action</h3>
258-
<button onclick="closeBulkActionModal(false)" class="text-gray-400 hover:text-gray-600 dark:hover:text-gray-300">
258+
<button onclick="closeBulkActionModal(false)" aria-label="Close" class="text-gray-400 hover:text-gray-600 dark:hover:text-gray-300">
259259
<svg class="w-5 h-5" fill="none" stroke="currentColor" viewBox="0 0 24 24">
260260
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M6 18L18 6M6 6l12 12"></path>
261261
</svg>

gearbox/internal/framework/templates/pages/firewall_config.templ

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ templ FirewallConfigPage(user *models.User, server *database.BoxDB, config *agen
144144
<!-- Validation Error Modal — shown when Save & Apply runs into errors.
145145
Real-time errors stay inline on the editor lines; this modal is
146146
specifically for the "you tried to save invalid config" case. -->
147-
<div id="firewall-error-modal" class="hidden fixed inset-0 z-50 overflow-y-auto">
147+
<div id="firewall-error-modal" role="dialog" aria-modal="true" aria-label="Configuration error" class="hidden fixed inset-0 z-50 overflow-y-auto">
148148
<div class="flex items-center justify-center min-h-screen px-4">
149149
<div class="fixed inset-0 bg-black bg-opacity-50" data-firewall-error-dismiss></div>
150150
<div class="relative bg-white dark:bg-slate-800 rounded-lg shadow-xl max-w-2xl w-full">
@@ -171,7 +171,7 @@ templ FirewallConfigPage(user *models.User, server *database.BoxDB, config *agen
171171
</div>
172172

173173
<!-- Snippets Modal — curated nftables patterns the user can insert. -->
174-
<div id="firewall-snippets-modal" class="hidden fixed inset-0 z-50 overflow-y-auto">
174+
<div id="firewall-snippets-modal" role="dialog" aria-modal="true" aria-label="Insert nftables snippet" class="hidden fixed inset-0 z-50 overflow-y-auto">
175175
<div class="flex items-center justify-center min-h-screen px-4">
176176
<div class="fixed inset-0 bg-black bg-opacity-50" data-firewall-snippets-dismiss></div>
177177
<div class="relative bg-white dark:bg-slate-800 rounded-lg shadow-xl max-w-4xl w-full max-h-[85vh] flex flex-col">
@@ -207,7 +207,7 @@ templ FirewallConfigPage(user *models.User, server *database.BoxDB, config *agen
207207
</div>
208208

209209
<!-- Backups Modal (kept simple; matches the existing site pattern) -->
210-
<div id="firewall-backups-modal" class="hidden fixed inset-0 z-50 overflow-y-auto">
210+
<div id="firewall-backups-modal" role="dialog" aria-modal="true" aria-label="Configuration backups" class="hidden fixed inset-0 z-50 overflow-y-auto">
211211
<div class="flex items-center justify-center min-h-screen px-4">
212212
<div class="fixed inset-0 bg-black bg-opacity-50" data-firewall-modal-dismiss></div>
213213
<div class="relative bg-white dark:bg-slate-800 rounded-lg shadow-xl max-w-2xl w-full p-6">

gearbox/internal/framework/templates/pages/haproxy_config/modals.templ

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ package haproxy_config
22

33
templ Modals() {
44
<!-- Backups Modal -->
5-
<div id="backups-modal" class="hidden fixed inset-0 z-50 overflow-y-auto">
5+
<div id="backups-modal" role="dialog" aria-modal="true" aria-label="Configuration backups" class="hidden fixed inset-0 z-50 overflow-y-auto">
66
<div class="flex items-center justify-center min-h-screen px-4">
77
<div id="backups-modal-backdrop" class="fixed inset-0 bg-black bg-opacity-50"></div>
88
<div class="relative bg-white dark:bg-slate-800 rounded-lg shadow-xl max-w-2xl w-full p-6">
@@ -19,7 +19,7 @@ templ Modals() {
1919
</div>
2020
</div>
2121
<!-- Error Dialog for tampered markers -->
22-
<div id="marker-error-modal" class="hidden fixed inset-0 z-50 overflow-y-auto">
22+
<div id="marker-error-modal" role="dialog" aria-modal="true" aria-label="Configuration error" class="hidden fixed inset-0 z-50 overflow-y-auto">
2323
<div class="flex items-center justify-center min-h-screen px-4">
2424
<div class="fixed inset-0 bg-black bg-opacity-50"></div>
2525
<div class="relative bg-white dark:bg-slate-800 rounded-lg shadow-xl max-w-2xl w-full">
@@ -56,7 +56,7 @@ templ Modals() {
5656
</div>
5757
</div>
5858
<!-- Save Reason Dialog -->
59-
<div id="save-reason-modal" class="hidden fixed inset-0 z-50 overflow-y-auto">
59+
<div id="save-reason-modal" role="dialog" aria-modal="true" aria-label="Save configuration" class="hidden fixed inset-0 z-50 overflow-y-auto">
6060
<div class="flex items-center justify-center min-h-screen px-4">
6161
<div id="save-reason-backdrop" class="fixed inset-0 bg-black bg-opacity-50"></div>
6262
<div class="relative bg-white dark:bg-slate-800 rounded-lg shadow-xl max-w-md w-full">
@@ -103,7 +103,7 @@ templ Modals() {
103103
</div>
104104
</div>
105105
<!-- Validation Output Dialog -->
106-
<div id="validation-modal" class="hidden fixed inset-0 z-50 overflow-y-auto">
106+
<div id="validation-modal" role="dialog" aria-modal="true" aria-labelledby="validation-modal-title" class="hidden fixed inset-0 z-50 overflow-y-auto">
107107
<div class="flex items-center justify-center min-h-screen px-4">
108108
<div id="validation-modal-backdrop" class="fixed inset-0 bg-black bg-opacity-50"></div>
109109
<div class="relative bg-white dark:bg-slate-800 rounded-lg shadow-xl max-w-2xl w-full">
@@ -134,7 +134,7 @@ templ Modals() {
134134
</div>
135135
</div>
136136
<!-- Insert Snippets Modal -->
137-
<div id="snippets-modal" class="hidden fixed inset-0 z-50 overflow-y-auto">
137+
<div id="snippets-modal" role="dialog" aria-modal="true" aria-label="Insert configuration snippet" class="hidden fixed inset-0 z-50 overflow-y-auto">
138138
<div class="flex items-center justify-center min-h-screen px-4">
139139
<div id="snippets-modal-backdrop" class="fixed inset-0 bg-black bg-opacity-50"></div>
140140
<div class="relative bg-white dark:bg-slate-800 rounded-lg shadow-xl max-w-4xl w-full max-h-[85vh] flex flex-col">

gearbox/internal/framework/templates/pages/haproxy_settings.templ

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,7 @@ templ HAProxyBoxesPageContent(user *models.User, servers []*database.BoxDB) {
225225
</div>
226226
</div>
227227
<div class="mt-5 sm:mt-4 sm:flex sm:flex-row-reverse">
228-
<button type="button" onclick="closeNotesModal()" class="w-full inline-flex justify-center rounded-md border border-gray-300 dark:border-gray-600 shadow-sm px-4 py-2 bg-white dark:bg-slate-700 text-base font-medium text-gray-700 dark:text-gray-300 hover:bg-gray-50 dark:hover:bg-slate-600 sm:w-auto sm:text-sm">
228+
<button type="button" onclick="closeNotesModal()" aria-label="Close" class="w-full inline-flex justify-center rounded-md border border-gray-300 dark:border-gray-600 shadow-sm px-4 py-2 bg-white dark:bg-slate-700 text-base font-medium text-gray-700 dark:text-gray-300 hover:bg-gray-50 dark:hover:bg-slate-600 sm:w-auto sm:text-sm">
229229
Close
230230
</button>
231231
</div>
@@ -263,7 +263,7 @@ templ HAProxyBoxesPageContent(user *models.User, servers []*database.BoxDB) {
263263
<button type="button" id="delete-confirm-btn" onclick="confirmDeleteServer()" class="w-full inline-flex justify-center rounded-md border border-transparent shadow-sm px-4 py-2 bg-red-600 text-base font-medium text-white hover:bg-red-700 sm:ml-3 sm:w-auto sm:text-sm">
264264
Yes, Delete
265265
</button>
266-
<button type="button" onclick="closeDeleteModal()" class="mt-3 w-full inline-flex justify-center rounded-md border border-gray-300 dark:border-gray-600 shadow-sm px-4 py-2 bg-white dark:bg-slate-700 text-base font-medium text-gray-700 dark:text-gray-300 hover:bg-gray-50 dark:hover:bg-slate-600 sm:mt-0 sm:w-auto sm:text-sm">
266+
<button type="button" onclick="closeDeleteModal()" aria-label="Cancel" class="mt-3 w-full inline-flex justify-center rounded-md border border-gray-300 dark:border-gray-600 shadow-sm px-4 py-2 bg-white dark:bg-slate-700 text-base font-medium text-gray-700 dark:text-gray-300 hover:bg-gray-50 dark:hover:bg-slate-600 sm:mt-0 sm:w-auto sm:text-sm">
267267
No, Cancel
268268
</button>
269269
</div>

0 commit comments

Comments
 (0)