Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tried implementing automatic dark mode theme #59

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
6 changes: 5 additions & 1 deletion src/utils/theme.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
export function initializeTheme(): void {
chrome.storage.local.get(['isDarkTheme'], (result) => {
const theme = result.isDarkTheme ? 'dark' : 'light';
const current_Time=new Date().getHours();
const isDarkTheme=current_Time>=16 || current_Time<6;//i want the extension to change theme automatically to stay consistent with me laptop
//avg sunsets across India seems to be about 4PM since its dec.
//i dont know much about Typescript sorry if i am polluting the code base in anyway (apologies init)
document.documentElement.setAttribute('data-theme', theme);
updateThemeUI(theme); // Make sure this function adjusts the UI correctly
});
@@ -29,4 +33,4 @@ function updateThemeUI(theme: string) {
themeIcon.textContent = '🌙';
themeText.textContent = 'Dark Mode';
}
}
}