@@ -35,36 +35,11 @@ class ThemeManager {
3535 * Create theme toggle button
3636 */
3737 createToggleButton ( ) {
38- // Check if toggle button already exists
39- let toggleButton = document . querySelector ( `. ${ this . themeToggleClass } ` ) ;
38+ // We don't need to create a toggle button here anymore
39+ // as it's already included in the pf-header component
4040
41- if ( ! toggleButton ) {
42- // Create toggle button if it doesn't exist
43- toggleButton = document . createElement ( 'button' ) ;
44- toggleButton . className = this . themeToggleClass ;
45- toggleButton . setAttribute ( 'aria-label' , 'Toggle theme' ) ;
46- toggleButton . setAttribute ( 'title' , 'Toggle light/dark theme' ) ;
47-
48- // Append toggle button to body
49- document . body . appendChild ( toggleButton ) ;
50- }
51-
52- // Create SVG icons for sun and moon
53- const lightIcon = `
54- <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" class="theme-icon-light">
55- <path d="M12 18C8.68629 18 6 15.3137 6 12C6 8.68629 8.68629 6 12 6C15.3137 6 18 8.68629 18 12C18 15.3137 15.3137 18 12 18ZM12 16C14.2091 16 16 14.2091 16 12C16 9.79086 14.2091 8 12 8C9.79086 8 8 9.79086 8 12C8 14.2091 9.79086 16 12 16ZM11 1H13V4H11V1ZM11 20H13V23H11V20ZM3.51472 4.92893L4.92893 3.51472L7.05025 5.63604L5.63604 7.05025L3.51472 4.92893ZM16.9497 18.364L18.364 16.9497L20.4853 19.0711L19.0711 20.4853L16.9497 18.364ZM19.0711 3.51472L20.4853 4.92893L18.364 7.05025L16.9497 5.63604L19.0711 3.51472ZM5.63604 16.9497L7.05025 18.364L4.92893 20.4853L3.51472 19.0711L5.63604 16.9497ZM23 11V13H20V11H23ZM4 11V13H1V11H4Z"/>
56- </svg>
57- ` ;
58-
59- const darkIcon = `
60- <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" class="theme-icon-dark">
61- <path d="M10 7C10 10.866 13.134 14 17 14C18.9584 14 20.729 13.1957 21.9995 11.8995C22 11.933 22 11.9665 22 12C22 17.5228 17.5228 22 12 22C6.47715 22 2 17.5228 2 12C2 6.47715 6.47715 2 12 2C12.0335 2 12.067 2 12.1005 2.00049C10.8043 3.27105 10 5.04157 10 7ZM4 12C4 16.4183 7.58172 20 12 20C15.0583 20 17.7158 18.2839 19.062 15.7621C18.3945 15.9187 17.7035 16 17 16C12.0294 16 8 11.9706 8 7C8 6.29648 8.08133 5.60547 8.2379 4.938C5.71611 6.28423 4 8.9417 4 12Z"/>
62- </svg>
63- ` ;
64-
65- // Set icon based on current theme
66- const currentTheme = this . getCurrentTheme ( ) ;
67- toggleButton . innerHTML = currentTheme === this . darkThemeClass ? lightIcon : darkIcon ;
41+ // This method is kept for backward compatibility
42+ // but doesn't create a duplicate button
6843 }
6944
7045 /**
@@ -90,6 +65,7 @@ class ThemeManager {
9065 * Add event listener to theme toggle button
9166 */
9267 addToggleListener ( ) {
68+ // Listen for theme toggle clicks from any component
9369 document . addEventListener ( 'click' , ( event ) => {
9470 const toggleButton = event . target . closest ( `.${ this . themeToggleClass } ` ) ;
9571 if ( toggleButton ) {
@@ -123,26 +99,8 @@ class ThemeManager {
12399 this . setTheme ( newTheme ) ;
124100 localStorage . setItem ( this . storageKey , newTheme ) ;
125101
126- // Update toggle button icon
127- const toggleButton = document . querySelector ( `.${ this . themeToggleClass } ` ) ;
128- if ( toggleButton ) {
129- // Clear any existing content
130- toggleButton . innerHTML = '' ;
131-
132- const lightIcon = `
133- <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" class="theme-icon-light">
134- <path d="M12 18C8.68629 18 6 15.3137 6 12C6 8.68629 8.68629 6 12 6C15.3137 6 18 8.68629 18 12C18 15.3137 15.3137 18 12 18ZM12 16C14.2091 16 16 14.2091 16 12C16 9.79086 14.2091 8 12 8C9.79086 8 8 9.79086 8 12C8 14.2091 9.79086 16 12 16ZM11 1H13V4H11V1ZM11 20H13V23H11V20ZM3.51472 4.92893L4.92893 3.51472L7.05025 5.63604L5.63604 7.05025L3.51472 4.92893ZM16.9497 18.364L18.364 16.9497L20.4853 19.0711L19.0711 20.4853L16.9497 18.364ZM19.0711 3.51472L20.4853 4.92893L18.364 7.05025L16.9497 5.63604L19.0711 3.51472ZM5.63604 16.9497L7.05025 18.364L4.92893 20.4853L3.51472 19.0711L5.63604 16.9497ZM23 11V13H20V11H23ZM4 11V13H1V11H4Z"/>
135- </svg>
136- ` ;
137-
138- const darkIcon = `
139- <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" class="theme-icon-dark">
140- <path d="M10 7C10 10.866 13.134 14 17 14C18.9584 14 20.729 13.1957 21.9995 11.8995C22 11.933 22 11.9665 22 12C22 17.5228 17.5228 22 12 22C6.47715 22 2 17.5228 2 12C2 6.47715 6.47715 2 12 2C12.0335 2 12.067 2 12.1005 2.00049C10.8043 3.27105 10 5.04157 10 7ZM4 12C4 16.4183 7.58172 20 12 20C15.0583 20 17.7158 18.2839 19.062 15.7621C18.3945 15.9187 17.7035 16 17 16C12.0294 16 8 11.9706 8 7C8 6.29648 8.08133 5.60547 8.2379 4.938C5.71611 6.28423 4 8.9417 4 12Z"/>
141- </svg>
142- ` ;
143-
144- toggleButton . innerHTML = newTheme === this . darkThemeClass ? lightIcon : darkIcon ;
145- }
102+ // We don't need to update the toggle button icon here
103+ // as the header component will handle that via the themechange event
146104 }
147105
148106 /**
0 commit comments