Skip to content

Commit 55e6725

Browse files
committed
fix: update theme handling and improve CSS styles for preview component
1 parent 683fe97 commit 55e6725

4 files changed

Lines changed: 48 additions & 10 deletions

File tree

.changeset/sparkly-tools-trade.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"superfill.ai": patch
3+
---
4+
5+
fix: update theme handling and improve CSS styles for preview component

src/assets/globals.css

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,7 @@
211211
}
212212

213213
@layer base {
214-
* {
214+
*:not(:host) {
215215
@apply border-border outline-ring/50;
216216
}
217217

src/entrypoints/content/components/preview-manager.tsx

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import type {
2222
PreviewSidebarPayload,
2323
} from "@/types/autofill";
2424
import type { FilledField, FormMapping, MemoryEntry } from "@/types/memory";
25+
import { Theme } from "@/types/theme";
2526
import { AutofillContainer } from "./autofill-container";
2627

2728
const logger = createLogger("preview-manager");
@@ -456,12 +457,6 @@ export class PreviewSidebarManager {
456457

457458
const mountPoint = document.createElement("div");
458459
mountPoint.id = "superfill-autofill-preview-root";
459-
mountPoint.style.cssText = `
460-
width: 100%;
461-
height: 100%;
462-
display: flex;
463-
flex-direction: column;
464-
`;
465460
uiContainer.append(mountPoint);
466461

467462
const root = createRoot(mountPoint);
@@ -471,7 +466,17 @@ export class PreviewSidebarManager {
471466
(async () => {
472467
const uiSettings = await storage.uiSettings.getValue();
473468

474-
uiContainer.classList.add(uiSettings.theme);
469+
host.classList.remove("light", "dark");
470+
if (uiSettings.theme === Theme.LIGHT) {
471+
host.classList.add("light");
472+
} else if (uiSettings.theme === Theme.DARK) {
473+
host.classList.add("dark");
474+
} else {
475+
const isDarkMode =
476+
document.documentElement.classList.contains("dark") ||
477+
window.matchMedia("(prefers-color-scheme: dark)").matches;
478+
host.classList.add(isDarkMode ? "dark" : "light");
479+
}
475480
})();
476481

477482
return root;

src/entrypoints/content/content.css

Lines changed: 30 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
@import "~/assets/globals.css";
33

44
:host {
5+
all: initial !important;
56
position: fixed !important;
67
top: 0 !important;
78
right: 0 !important;
@@ -12,7 +13,11 @@
1213
z-index: 2147483646 !important;
1314
pointer-events: none !important;
1415
overflow: visible !important;
15-
font-family: var(--font-sans, "Outfit", sans-serif);
16+
font-family: var(--font-sans, "Outfit", sans-serif) !important;
17+
font-size: 16px !important;
18+
line-height: 1.5 !important;
19+
color: initial !important;
20+
box-sizing: border-box !important;
1621
}
1722

1823
:host([data-ui-type="preview"]) {
@@ -49,18 +54,41 @@
4954
pointer-events: none !important;
5055
}
5156

57+
:host > div {
58+
box-sizing: border-box !important;
59+
width: 100% !important;
60+
height: 100% !important;
61+
margin: 0 !important;
62+
padding: 0 !important;
63+
display: block !important;
64+
overflow: hidden !important;
65+
}
66+
5267
html,
5368
body {
5469
position: static !important;
5570
top: auto !important;
5671
left: auto !important;
5772
right: auto !important;
5873
bottom: auto !important;
74+
box-sizing: border-box !important;
5975
width: 100% !important;
6076
height: 100% !important;
6177
margin: 0 !important;
6278
padding: 0 !important;
63-
overflow: visible !important;
79+
overflow: hidden !important;
80+
}
81+
82+
#superfill-autofill-preview-root {
83+
box-sizing: border-box !important;
84+
width: 100% !important;
85+
height: 100% !important;
86+
min-height: 0 !important;
87+
display: flex !important;
88+
flex-direction: column !important;
89+
overflow-y: auto !important;
90+
overflow-x: hidden !important;
91+
position: relative !important;
6492
}
6593

6694
/* From Uiverse.io by andrew-manzyk */

0 commit comments

Comments
 (0)