Change app theme color with theme toggle
This commit is contained in:
		
							parent
							
								
									be1270c10e
								
							
						
					
					
						commit
						f9aadaf492
					
				| 
						 | 
					@ -19,7 +19,7 @@
 | 
				
			||||||
		<meta name="msapplication-TileColor" content="#ead40b" />
 | 
							<meta name="msapplication-TileColor" content="#ead40b" />
 | 
				
			||||||
		<meta name="apple-mobile-web-app-title" content="Notes" />
 | 
							<meta name="apple-mobile-web-app-title" content="Notes" />
 | 
				
			||||||
		<meta name="application-name" content="Notes" />
 | 
							<meta name="application-name" content="Notes" />
 | 
				
			||||||
		<meta name="theme-color" content="#11191f" />
 | 
							<meta name="theme-color" content="#18232c" />
 | 
				
			||||||
		%sveltekit.head%
 | 
							%sveltekit.head%
 | 
				
			||||||
	</head>
 | 
						</head>
 | 
				
			||||||
	<body data-sveltekit-preload-data="hover">
 | 
						<body data-sveltekit-preload-data="hover">
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -9,9 +9,12 @@ export class ThemeStore implements Readable<Theme> {
 | 
				
			||||||
	);
 | 
						);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	constructor() {
 | 
						constructor() {
 | 
				
			||||||
 | 
							const themeMetaTag = document.querySelector('meta[name="theme-color"]');
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		this.theme.subscribe((newTheme) => {
 | 
							this.theme.subscribe((newTheme) => {
 | 
				
			||||||
			document.documentElement.dataset.theme = newTheme;
 | 
								document.documentElement.dataset.theme = newTheme;
 | 
				
			||||||
			localStorage.setItem('theme', newTheme);
 | 
								localStorage.setItem('theme', newTheme);
 | 
				
			||||||
 | 
								themeMetaTag?.setAttribute('content', newTheme === 'dark' ? '#18232c' : '#fbfbfc');
 | 
				
			||||||
		});
 | 
							});
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue