refactor: decompose CSS, unify dark mode, extract shared modules
Structural cleanup based on thermo-nuclear code quality review: - Extract shared color-picker.css and color-popover.css from badges.css (611→85 lines) - Extract shared lib/presets.js for preset CRUD used by popup and popover - Unify dark mode to single applyDarkModeClass on <html>, removing 4 scattered functions - Fix stale closure in startPostObserver, data-driven reload key check - Remove dead exports, getHelpers wrapper, duplicated colorToHex - Replace DOM expando properties with state array in popup.js Net: -318 lines of duplication, no file over 401 lines. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -19,14 +19,6 @@
|
||||
}
|
||||
}
|
||||
|
||||
function applyDarkMode(settings) {
|
||||
if (window.RedditTweaks.isDarkMode(settings)) {
|
||||
document.documentElement.classList.add("rt-dark");
|
||||
} else {
|
||||
document.documentElement.classList.remove("rt-dark");
|
||||
}
|
||||
}
|
||||
|
||||
function applyBackground(settings) {
|
||||
if (settings.cardBackground === "shadcn") {
|
||||
document.documentElement.classList.add("rt-card-bg-shadcn");
|
||||
@@ -68,7 +60,6 @@
|
||||
|
||||
function apply(settings) {
|
||||
document.documentElement.classList.add("rt-card-enabled");
|
||||
applyDarkMode(settings);
|
||||
applyBackground(settings);
|
||||
applyDensity(settings);
|
||||
applyGap(settings);
|
||||
@@ -77,7 +68,6 @@
|
||||
}
|
||||
|
||||
function updateSettings(settings) {
|
||||
applyDarkMode(settings);
|
||||
applyBackground(settings);
|
||||
applyDensity(settings);
|
||||
applyGap(settings);
|
||||
|
||||
Reference in New Issue
Block a user