From a45ccf327f321c751d59e77b281c0df480630e83 Mon Sep 17 00:00:00 2001 From: SwingTheVine Date: Fri, 25 Jul 2025 02:01:41 -0400 Subject: [PATCH] Code optimization on file upload styling --- src/overlay.css | 8 +++++--- src/overlay.js | 8 +++----- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/overlay.css b/src/overlay.css index 3984ce5..c2dd81b 100644 --- a/src/overlay.css +++ b/src/overlay.css @@ -73,12 +73,12 @@ div#bm-overlay { /* Question Mark button */ .bm-help { border: white 1px solid; - border-radius: 1em; height: 1.25em; width: 1.25em; margin-top: 2px; text-align: center; line-height: 1.25em; + padding: 0 !important; /* Overrides the padding in "#bm-overlay button" */ } /* Pin button */ @@ -113,10 +113,12 @@ div#bm-overlay { gap: 1ch; } -/* The template file upload container */ +/* The template file upload button */ div:has(> #bm-input-file) > button { width: 100%; - text-align: left; + white-space: nowrap; + overflow: hidden; + text-overflow: ellipsis; } /* Output status area */ diff --git a/src/overlay.js b/src/overlay.js index 0bc997c..d6695bd 100644 --- a/src/overlay.js +++ b/src/overlay.js @@ -132,7 +132,7 @@ export class Overlay { containerAutomation.appendChild(containerAutomationCoords); // Adds coord container to automation container - containerAutomation.appendChild(this.createInputFile('bm-input-file', 20)); // Adds the file upload element to the automation container + containerAutomation.appendChild(this.createInputFile('bm-input-file')); // Adds the file upload element to the automation container const containerAutomationButtons = document.createElement('div'); // Button array for bot containerAutomationButtons.id = 'bm-contain-buttons'; @@ -262,11 +262,10 @@ export class Overlay { /** Creates a custom file upload input. * Only the button is displayed, but interacting with it will simulate the file input * @param {string} inputId - The file input element ID - * @param {number} [maxChars] - (Optional) The maximum number of characters in the displayed file name. Zero by default * @returns {HTMLDivElement} HTML Div Element with Button and Input children * @since 0.36.1 */ - createInputFile(inputId, maxChars=0) { + createInputFile(inputId) { const container = document.createElement('div'); const input = document.createElement('input'); @@ -283,8 +282,7 @@ export class Overlay { // Changes the button text content (and trims the file name) input.addEventListener('change', () => { if (input.files.length > 0) { - const name = input.files[0].name; - button.textContent = !!maxChars ? `${name.slice(0, maxChars)}${name.length > maxChars ? `…` : ``}` : input.files[0].name; + button.textContent = input.files[0].name; } else { button.textContent = 'Upload File'; }