JS: Add a setOption handler that can toggle the bg/background option
This commit is contained in:
		
							parent
							
								
									de6342b05c
								
							
						
					
					
						commit
						efd5f8991d
					
				
					 1 changed files with 16 additions and 0 deletions
				
			
		
							
								
								
									
										16
									
								
								assets/js/commands.js
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										16
									
								
								assets/js/commands.js
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,16 @@ | |||
| document.addEventListener("DOMContentLoaded", () => { | ||||
|     const commandBar = document.querySelector("command-bar"); | ||||
| 
 | ||||
|     commandBar.addEventListener("setOption", event => { | ||||
|         console.log("SetOption", event); | ||||
|         switch (event.option) { | ||||
|             case "bg": | ||||
|             case "background": | ||||
|                 const value = event.newValue; | ||||
|                 if (value === "dark" || value === "light") { | ||||
|                     document.querySelector(":root").setAttribute("color-scheme", value); | ||||
|                 } | ||||
|                 break; | ||||
|         } | ||||
|     }); | ||||
| }); | ||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue