Skip to content

Commit a876e1f

Browse files
committed
Refine popup settings and SamacSys previews
1 parent afd7a7f commit a876e1f

4 files changed

Lines changed: 40 additions & 7 deletions

File tree

src/popup.css

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,11 @@ h1 {
8585
object-fit: contain;
8686
}
8787

88+
.preview-image.samacsys-preview-image {
89+
filter: grayscale(1) saturate(0) brightness(0.58) contrast(12);
90+
mix-blend-mode: multiply;
91+
}
92+
8893
.preview-image.hidden {
8994
display: none;
9095
}
@@ -156,12 +161,6 @@ h1 {
156161
flex-direction: column;
157162
gap: 8px;
158163
padding-top: 6px;
159-
border-top: 1px solid #e2e8f0;
160-
font-size: 12px;
161-
}
162-
163-
.settings-header {
164-
font-weight: 600;
165164
font-size: 12px;
166165
}
167166

@@ -270,6 +269,10 @@ h1 {
270269
text-align: center;
271270
}
272271

272+
.status:empty {
273+
display: none;
274+
}
275+
273276
/* Error state for status messages. */
274277
.status.error {
275278
color: #b42318;

src/popup.html

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,6 @@ <h1>Easy EDA Downloader</h1>
5353
</label>
5454
</div>
5555
<section class="settings" aria-label="Settings">
56-
<div class="settings-header">Settings</div>
5756
<button id="settingsButton" type="button" class="secondary settings-button">
5857
Open settings
5958
</button>

src/popup.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import {
1717
} from "./core/part_context.js";
1818

1919
const DEFAULT_SOURCE_PART_LABEL = "Part";
20+
const SAMACSYS_PREVIEW_IMAGE_CLASS = "samacsys-preview-image";
2021
const chromeApi = globalThis.chrome;
2122
const popupWindow = globalThis.window;
2223
const popupDocument = globalThis.document;
@@ -75,6 +76,18 @@ function updateDownloadEnabled() {
7576
!currentPartContext?.provider || isBlockedProvider() || !hasSelection();
7677
}
7778

79+
function setPreviewProviderStyle(partContext) {
80+
const isSamacsysPreview = isSamacsysProviderShared(partContext?.provider);
81+
symbolPreviewEl.classList.toggle(
82+
SAMACSYS_PREVIEW_IMAGE_CLASS,
83+
isSamacsysPreview
84+
);
85+
footprintPreviewEl.classList.toggle(
86+
SAMACSYS_PREVIEW_IMAGE_CLASS,
87+
isSamacsysPreview
88+
);
89+
}
90+
7891
function setPreviewLoading(fallbackEl, imgEl) {
7992
fallbackEl.textContent = "Loading...";
8093
fallbackEl.classList.remove("hidden");
@@ -135,6 +148,7 @@ function setIdentifierDisplay(sourcePartLabel, sourcePartNumber, manufacturerPar
135148
function setUnavailableDisplay(statusMessage) {
136149
currentPartContext = null;
137150
currentSourceTabId = null;
151+
setPreviewProviderStyle(null);
138152
sourcePartLabelEl.textContent = DEFAULT_SOURCE_PART_LABEL;
139153
manufacturerPartNumberEl.textContent = "Unavailable";
140154
partNumberEl.textContent = "Unavailable";
@@ -211,6 +225,7 @@ function openSettingsPage() {
211225
// Update UI state based on whether a supported provider was found.
212226
function setPartContext(partContext) {
213227
currentPartContext = partContext?.provider ? partContext : null;
228+
setPreviewProviderStyle(currentPartContext);
214229

215230
if (!currentPartContext) {
216231
setIdentifierDisplay(DEFAULT_SOURCE_PART_LABEL, null, null);

tests/test_popup.test.js

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -228,6 +228,14 @@ describe("popup", () => {
228228
expect(hooks.elements.downloadButton.disabled).toBe(false);
229229
expect(hooks.elements.symbolPreviewEl.src).toContain("data:image/svg+xml");
230230
expect(hooks.elements.footprintPreviewEl.src).toContain("data:image/svg+xml");
231+
expect(
232+
hooks.elements.symbolPreviewEl.classList.contains("samacsys-preview-image")
233+
).toBe(false);
234+
expect(
235+
hooks.elements.footprintPreviewEl.classList.contains(
236+
"samacsys-preview-image"
237+
)
238+
).toBe(false);
231239

232240
hooks.elements.downloadSymbolEl.checked = false;
233241
hooks.elements.downloadFootprintEl.checked = false;
@@ -276,6 +284,14 @@ describe("popup", () => {
276284
);
277285
expect(hooks.elements.symbolPreviewEl.src).toContain("data:image/png;base64");
278286
expect(hooks.elements.footprintPreviewEl.src).toContain("data:image/png;base64");
287+
expect(
288+
hooks.elements.symbolPreviewEl.classList.contains("samacsys-preview-image")
289+
).toBe(true);
290+
expect(
291+
hooks.elements.footprintPreviewEl.classList.contains(
292+
"samacsys-preview-image"
293+
)
294+
).toBe(true);
279295

280296
hooks.elements.downloadDatasheetEl.checked = false;
281297
hooks.elements.downloadButton.click();

0 commit comments

Comments
 (0)