Skip to content

Auto Theme Support: Match LeetCode’s Light/Dark Mode Automatically #64

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

Merged
merged 6 commits into from
Apr 6, 2025
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
fix: small display showing medium size on install
  • Loading branch information
zubyj committed Apr 5, 2025
commit febd9c5b2c1c016c459138570716cf3723f5428b
7 changes: 6 additions & 1 deletion src/popup/popup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -283,8 +283,9 @@ function initializeScaleFactor(): void {
chrome.storage.local.get('fontSize', function (data) {
if (data.fontSize) {
let scaleFactor: number;
const fontSize = data.fontSize.toString();

switch (data.fontSize) {
switch (fontSize) {
case '12':
scaleFactor = 0.9;
break;
Expand All @@ -297,6 +298,10 @@ function initializeScaleFactor(): void {
}

document.documentElement.style.setProperty('--scale-factor', scaleFactor.toString());
} else {
// Default to small if not set
document.documentElement.style.setProperty('--scale-factor', '0.9');
chrome.storage.local.set({ fontSize: 12 });
}
});
}
Expand Down
11 changes: 8 additions & 3 deletions src/popup/settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,14 +46,19 @@ document.addEventListener('DOMContentLoaded', () => {
const fontSizeSelect = document.getElementById('font-size-select') as HTMLSelectElement;
chrome.storage.local.get('fontSize', function (data) {
if (data.fontSize) {
fontSizeSelect.value = data.fontSize;
updateScaleFactor(data.fontSize);
fontSizeSelect.value = data.fontSize.toString();
updateScaleFactor(data.fontSize.toString());
} else {
// Default to small if not set
fontSizeSelect.value = '12';
updateScaleFactor('12');
chrome.storage.local.set({ fontSize: 12 });
}
});

fontSizeSelect.onchange = function (event: Event) {
const selectedFontSize = (event.target as HTMLInputElement).value;
chrome.storage.local.set({ fontSize: selectedFontSize });
chrome.storage.local.set({ fontSize: parseInt(selectedFontSize) });
updateScaleFactor(selectedFontSize);
};

Expand Down