|
116 | 116 | <divclass="modal-content"> |
117 | 117 | <h4>Theme</h4> |
118 | 118 |
|
| 119 | + <inputclass="config-option"type="radio"name="theme"value="auto"id="settings-theme-auto"> |
| 120 | + <labelfor="settings-theme-auto">Auto</label> |
| 121 | + <pclass="form-help"><strong>Default theme</strong>. It switches between Light and Dark automatically to match the operating system theme.</p> |
| 122 | + |
119 | 123 | <inputclass="config-option"type="radio"name="theme"value="light"id="settings-theme-light"> |
120 | 124 | <labelfor="settings-theme-light">Light</label> |
121 | | - <pclass="form-help">Default theme. Improvesreadability.</p> |
| 125 | + <pclass="form-help">Provides greatestreadability, but requires a well-lit environment.</p> |
122 | 126 |
|
123 | 127 | <inputclass="config-option"type="radio"name="theme"value="dark"id="settings-theme-dark"> |
124 | 128 | <labelfor="settings-theme-dark">Dark</label> |
125 | | - <pclass="form-help">Reduces eye fatigue. Ideal for low lightconditions.</p> |
| 129 | + <pclass="form-help">Reduces eye fatigue. Ideal for low lightenvironments.</p> |
126 | 130 |
|
127 | 131 | <h4>Page Width</h4> |
128 | 132 |
|
129 | | - <inputclass="config-option"type="radio"name="width"value="light"id="settings-width-normal"> |
| 133 | + <inputclass="config-option"type="radio"name="width"value="normal"id="settings-width-normal"> |
130 | 134 | <labelfor="settings-width-normal">Normal</label> |
131 | 135 | <pclass="form-help">Fixed page width. Improves readability.</p> |
132 | 136 |
|
133 | | - <inputclass="config-option"type="radio"name="width"value="dark"id="settings-width-full"> |
| 137 | + <inputclass="config-option"type="radio"name="width"value="full"id="settings-width-full"> |
134 | 138 | <labelfor="settings-width-full">Full-page</label> |
135 | 139 | <pclass="form-help">Dynamic page width. As wide as the browser window.</p> |
136 | 140 | </div> |
|
139 | 143 |
|
140 | 144 | <script> |
141 | 145 | (function() { |
142 | | -let configOptions=document.querySelectorAll('.config-option'); |
143 | | -let oppositeValues={'light':'dark','dark':'light','normal':'full','full':'normal' }; |
| 146 | +constconfigOptions=document.querySelectorAll('.config-option'); |
| 147 | +constallSettingValues=['theme-auto','theme-ligh','theme-dark','width-normal','width-full']; |
144 | 148 | [...configOptions].forEach(option=> { |
145 | 149 | option.addEventListener('click',function (event) { |
146 | | -let optionParts=option.id.split('-'); |
147 | | -let optionName= optionParts[1]; |
148 | | -let optionValue= optionParts[2]; |
149 | | -
|
150 | | -document.body.classList.remove(optionName+'-'+ oppositeValues[optionValue]); |
151 | | -document.body.classList.add(optionName+'-'+ optionValue); |
152 | | -localStorage.setItem('symfony/profiler/'+ optionName, optionName+'-'+ optionValue); |
| 150 | +constoptionName=option.name; |
| 151 | +constoptionValue=option.value; |
| 152 | +constsettingName='symfony/profiler/'+ optionName; |
| 153 | +constsettingValue= optionName+'-'+ optionValue; |
| 154 | +
|
| 155 | +localStorage.setItem(settingName, settingValue); |
| 156 | +
|
| 157 | +document.body.classList.forEach((cssClass)=> { |
| 158 | +if (cssClass.startsWith(optionName)) { |
| 159 | +document.body.classList.remove(cssClass); |
| 160 | + } |
| 161 | + }); |
| 162 | +
|
| 163 | +if ('theme-auto'=== settingValue) { |
| 164 | +document.body.classList.add((matchMedia('(prefers-color-scheme: dark)').matches?'theme-dark':'theme-light')); |
| 165 | + }else { |
| 166 | +document.body.classList.add(settingValue); |
| 167 | + } |
153 | 168 | }); |
154 | 169 | }); |
155 | 170 |
|
156 | | -let openModalButton=document.getElementById('open-settings'); |
157 | | -let modalWindow=document.getElementById('profiler-settings'); |
158 | | -let closeModalButton=document.getElementsByClassName('close-modal')[0]; |
159 | | -let modalWrapper=document.getElementsByClassName('modal-wrap')[0] |
| 171 | +constopenModalButton=document.getElementById('open-settings'); |
| 172 | +constmodalWindow=document.getElementById('profiler-settings'); |
| 173 | +constcloseModalButton=document.getElementsByClassName('close-modal')[0]; |
| 174 | +constmodalWrapper=document.getElementsByClassName('modal-wrap')[0] |
160 | 175 |
|
161 | 176 | openModalButton.addEventListener('click',function(event) { |
162 | | -document.getElementById('settings-'+ (localStorage.getItem('symfony/profiler/theme')||'theme-light')).checked='checked'; |
| 177 | +document.getElementById('settings-'+ (localStorage.getItem('symfony/profiler/theme')||'theme-auto')).checked='checked'; |
163 | 178 | document.getElementById('settings-'+ (localStorage.getItem('symfony/profiler/width')||'width-normal')).checked='checked'; |
164 | 179 |
|
165 | 180 | modalWindow.classList.toggle('visible'); |
|