Skip to content

Commit

Permalink
feat: Add new auto theme and set as default
Browse files Browse the repository at this point in the history
  • Loading branch information
maxmilton committed Jun 28, 2024
1 parent 13294d6 commit 8c646e7
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 1 deletion.
11 changes: 11 additions & 0 deletions src/css/themes/auto.xcss
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
/**
* Automatic Light/Dark Theme
*/

// stylelint-disable-next-line import-notation
@import './light.xcss';

@media (prefers-color-scheme: dark) {
// stylelint-disable-next-line import-notation, no-invalid-position-at-import-rule
@import './dark.xcss';
}
1 change: 1 addition & 0 deletions src/settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ const meta = compile(`
<div class=row>
<label>Theme</label>
<select @theme>
<option value=auto>Automatic (light/dark)</option>
<option value=light>Light</option>
<option value=dark>Dark</option>
<option value=black>Black</option>
Expand Down
9 changes: 8 additions & 1 deletion src/sw.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,13 @@ chrome.runtime.onInstalled.addListener(async () => {
}

void chrome.storage.local.set({
t: (await themes)[(await settings).tn ?? 'dark'],
t: (await themes)[(await settings).tn ?? 'auto'],
});

// TODO: Open settings page on install?
// if (details.reason === ('install' as chrome.runtime.OnInstalledReason.INSTALL)) {
// void chrome.tabs.create({
// url: chrome.runtime.getURL('settings.html'),
// });
// }
});

0 comments on commit 8c646e7

Please sign in to comment.