@@ -24,6 +24,9 @@ import {
2424 createLogoSvg ,
2525 generateId ,
2626 ICON_HOME ,
27+ ICON_THEME_DARK ,
28+ ICON_THEME_LIGHT ,
29+ ICON_THEME_AUTO ,
2730 GROUP_ICONS ,
2831 GAUGE_ARC_LENGTH ,
2932 SCORE_RING_CIRCUMFERENCE ,
@@ -93,7 +96,7 @@ export const buildMethods = {
9396 } ,
9497
9598 /**
96- * Sticky title bar: logo + name + close button.
99+ * Sticky title bar: logo + name + theme toggle + close button.
97100 *
98101 * @returns {HTMLDivElement }
99102 */
@@ -105,15 +108,54 @@ export const buildMethods = {
105108 <div>${ createLogoSvg ( "#E5622A" ) } </div>
106109 <span class="mageforge-toolbar-menu-title-text">MageForge</span>
107110 </div>
108- <button type="button" class="mageforge-toolbar-menu-close" title="Close & deactivate all" aria-label="Close & deactivate all">
109- <svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M18 6L6 18M6 6l12 12"></path></svg>
110- </button>
111+ <div class="mageforge-toolbar-menu-actions"></div>
111112 ` ;
112- header . querySelector ( ".mageforge-toolbar-menu-close" ) . onclick = ( e ) => {
113+
114+ const actions = header . querySelector ( ".mageforge-toolbar-menu-actions" ) ;
115+
116+ // Theme toggle
117+ const themeGroup = document . createElement ( "div" ) ;
118+ themeGroup . className = "mageforge-theme-icon-group" ;
119+ themeGroup . setAttribute ( "role" , "group" ) ;
120+ themeGroup . setAttribute ( "aria-label" , "Colour theme" ) ;
121+ [
122+ [ "dark" , ICON_THEME_DARK , "Dark theme" ] ,
123+ [ "auto" , ICON_THEME_AUTO , "Auto theme" ] ,
124+ [ "light" , ICON_THEME_LIGHT , "Light theme" ] ,
125+ ] . forEach ( ( [ value , icon , label ] ) => {
126+ const btn = document . createElement ( "button" ) ;
127+ btn . type = "button" ;
128+ btn . className = "mageforge-theme-icon-btn" ;
129+ btn . dataset . themeValue = value ;
130+ btn . innerHTML = icon ;
131+ btn . setAttribute ( "aria-label" , label ) ;
132+ btn . title = label ;
133+ btn . setAttribute ( "aria-pressed" , "false" ) ;
134+ btn . onclick = ( e ) => {
135+ e . stopPropagation ( ) ;
136+ this . setTheme ( /** @type {'dark'|'auto'|'light' } */ ( value ) ) ;
137+ } ;
138+ themeGroup . appendChild ( btn ) ;
139+ } ) ;
140+ actions . appendChild ( themeGroup ) ;
141+ this . _themeToggleGroup = themeGroup ;
142+
143+ // Close button
144+ const closeBtn = document . createElement ( "button" ) ;
145+ closeBtn . type = "button" ;
146+ closeBtn . className = "mageforge-toolbar-menu-close" ;
147+ closeBtn . title = "Close & deactivate all" ;
148+ closeBtn . setAttribute ( "aria-label" , "Close & deactivate all" ) ;
149+ closeBtn . innerHTML =
150+ '<svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M18 6L6 18M6 6l12 12"></path></svg>' ;
151+ closeBtn . onclick = ( e ) => {
113152 e . stopPropagation ( ) ;
114153 this . deactivateAllAudits ( ) ;
115154 this . closeMenu ( ) ;
116155 } ;
156+ actions . appendChild ( closeBtn ) ;
157+
158+ this . _updateThemeToggle ( ) ;
117159 return header ;
118160 } ,
119161
@@ -718,24 +760,34 @@ export const buildMethods = {
718760 const footer = document . createElement ( "div" ) ;
719761 footer . className = "mageforge-toolbar-menu-footer" ;
720762
721- // Export format row ──────────────────────────────────────────────────
722- const exportRow = document . createElement ( "div" ) ;
723- exportRow . className = "mageforge-footer-theme-row" ;
724- this . _exportBtnRow = exportRow ;
725- const exportGroup = document . createElement ( "div" ) ;
726- exportGroup . className = "mageforge-theme-toggle" ;
763+ // Footer toolbar row: credit + theme toggle + export formats
764+ const footerRow = document . createElement ( "div" ) ;
765+ footerRow . className = "mageforge-footer-toolbar-row" ;
766+
767+ // Credit line
768+ const credit = document . createElement ( "div" ) ;
769+ credit . className = "mageforge-toolbar-menu-credit" ;
770+ credit . innerHTML =
771+ 'Built with <span class="mageforge-toolbar-menu-credit-heart">\u2764</span> by <a href="https://github.com/OpenForgeProject/mageforge" target="_blank" rel="noopener noreferrer" class="mageforge-toolbar-menu-credit-link">MageForge</a>' ;
772+ footerRow . appendChild ( credit ) ;
773+
774+ // Export format toggle
775+ this . _exportBtnRow = document . createElement ( "div" ) ;
776+ this . _exportBtnRow . className = "mageforge-segmented-toggle" ;
777+ this . _exportBtnRow . setAttribute ( "role" , "group" ) ;
778+ this . _exportBtnRow . setAttribute ( "aria-label" , "Export format" ) ;
727779 const exportLabel = document . createElement ( "span" ) ;
728- exportLabel . className = "mageforge-footer-theme -label" ;
780+ exportLabel . className = "mageforge-footer-toolbar -label" ;
729781 exportLabel . textContent = "Export" ;
730- exportGroup . appendChild ( exportLabel ) ;
782+ this . _exportBtnRow . appendChild ( exportLabel ) ;
731783 [
732784 [ "json" , "JSON" ] ,
733785 [ "md" , "MD" ] ,
734786 [ "txt" , "TXT" ] ,
735787 ] . forEach ( ( [ fmt , label ] ) => {
736788 const btn = document . createElement ( "button" ) ;
737789 btn . type = "button" ;
738- btn . className = "mageforge-theme -btn mageforge-export-btn--disabled" ;
790+ btn . className = "mageforge-segmented -btn mageforge-export-btn--disabled" ;
739791 btn . dataset . exportFormat = fmt ;
740792 btn . textContent = label ;
741793 btn . disabled = true ;
@@ -745,17 +797,11 @@ export const buildMethods = {
745797 e . stopPropagation ( ) ;
746798 this . exportFindings ( fmt ) ;
747799 } ;
748- exportGroup . appendChild ( btn ) ;
800+ this . _exportBtnRow . appendChild ( btn ) ;
749801 } ) ;
750- exportRow . appendChild ( exportGroup ) ;
751- footer . appendChild ( exportRow ) ;
802+ footerRow . appendChild ( this . _exportBtnRow ) ;
752803
753- // Credit line (left side of export row) ─────────────────────────────
754- const credit = document . createElement ( "div" ) ;
755- credit . className = "mageforge-toolbar-menu-credit" ;
756- credit . innerHTML =
757- 'Built with <span class="mageforge-toolbar-menu-credit-heart">\u2764</span> by <a href="https://github.com/OpenForgeProject/mageforge" target="_blank" rel="noopener noreferrer" class="mageforge-toolbar-menu-credit-link">MageForge</a>' ;
758- exportRow . insertBefore ( credit , exportRow . firstChild ) ;
804+ footer . appendChild ( footerRow ) ;
759805
760806 // Populate nav action bar for the initially active tab (home).
761807 // footerActionBar was already created in _buildTabNav().
0 commit comments