Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 26 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion projects/demo/src/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@

<!-- Flash Prevention - Prevents FOUC in all browsers -->
<script>
(function(){'use strict';try{var t=localStorage.getItem('theme')||'system',e=t==='system'?window.matchMedia('(prefers-color-scheme: dark)').matches?'dark':'light':t==='light'||t==='dark'?t:'light',n=document.documentElement;if(n){n.classList.remove('light','dark'),e==='dark'?(n.classList.add('dark'),n.setAttribute('data-theme','dark')):(n.classList.remove('dark'),n.removeAttribute('data-theme')),n.style.colorScheme=e}}catch(e){try{var n=document.documentElement;n&&(n.classList.remove('light','dark'),n.removeAttribute('data-theme'),n.style.colorScheme='light')}catch(e){}}})();
(function(){"use strict";try{var t=localStorage.getItem("theme")||"system",e=t==="system"?window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light":t==="light"||t==="dark"?t:"light",n=document.documentElement;n&&(n.classList.remove("light","dark"),e==="dark"?(n.classList.add("dark"),n.setAttribute("data-theme","dark")):(n.classList.add("light"),n.setAttribute("data-theme","light")),n.style.colorScheme=e)}catch(t){try{var n=document.documentElement;n&&(n.classList.remove("light","dark"),n.classList.add("light"),n.setAttribute("data-theme","light"),n.style.colorScheme="light")}catch(t){}}})();
</script>
</head>

Expand Down
2 changes: 1 addition & 1 deletion projects/theme/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ body {
Add this **inline** script to your `index.html` `<head>`:
```html
<script>
(function(){'use strict';try{var t=localStorage.getItem('theme')||'system',e=t==='system'?window.matchMedia('(prefers-color-scheme: dark)').matches?'dark':'light':t==='light'||t==='dark'?t:'light',n=document.documentElement;if(n){n.classList.remove('light','dark'),e==='dark'?(n.classList.add('dark'),n.setAttribute('data-theme','dark')):(n.classList.remove('dark'),n.removeAttribute('data-theme')),n.style.colorScheme=e}}catch(e){try{var n=document.documentElement;n&&(n.classList.remove('light','dark'),n.removeAttribute('data-theme'),n.style.colorScheme='light')}catch(e){}}})();
(function(){"use strict";try{var t=localStorage.getItem("theme")||"system",e=t==="system"?window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light":t==="light"||t==="dark"?t:"light",n=document.documentElement;n&&(n.classList.remove("light","dark"),e==="dark"?(n.classList.add("dark"),n.setAttribute("data-theme","dark")):(n.classList.add("light"),n.setAttribute("data-theme","light")),n.style.colorScheme=e)}catch(t){try{var n=document.documentElement;n&&(n.classList.remove("light","dark"),n.classList.add("light"),n.setAttribute("data-theme","light"),n.style.colorScheme="light")}catch(t){}}})();
</script>
```
**Why inline?** Angular does not provide a way to inject scripts into the HTML `<head>` at build time. For true FOUC prevention, the script must run immediately as the HTML is parsed—before any content is rendered. External scripts or Angular providers/services run too late to prevent a flash. This is why the script must be copied directly into your `index.html` head.
Expand Down
2 changes: 1 addition & 1 deletion projects/theme/src/lib/theme.dom.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ export class ThemeDomManager implements DomManager {
if (theme === 'dark') {
element.setAttribute('data-theme', 'dark');
} else {
element.removeAttribute('data-theme');
element.setAttribute('data-theme', 'light');
}
} catch (error) {
console.warn('Failed to apply attribute theme:', error);
Expand Down