From 5c7a2164efb5ee847fef9545d07e9f76f3f16bc0 Mon Sep 17 00:00:00 2001 From: James Clifford Spratt Date: Sun, 28 Jun 2026 11:51:17 +0100 Subject: [PATCH] Replace inline display styles with .macros-u-hidden class; setCssProps for tooltip --- src/managers/ProcessorManager.ts | 2 +- src/ui/modals/ManualFoodEntryModal.ts | 10 +++++----- src/utils/TooltipManager.ts | 2 +- styles.css | 2 ++ 4 files changed, 9 insertions(+), 7 deletions(-) diff --git a/src/managers/ProcessorManager.ts b/src/managers/ProcessorManager.ts index 523dcef..f57e5d1 100644 --- a/src/managers/ProcessorManager.ts +++ b/src/managers/ProcessorManager.ts @@ -20,7 +20,7 @@ export function registerProcessors(plugin: MacrosPlugin): void { // instead of falling back to showing their raw source. plugin.registerMarkdownCodeBlockProcessor('macrosmicro', (_source, el) => { el.empty(); - el.style.display = 'none'; + el.addClass('macros-u-hidden'); }); plugin.logger.debug('All processors registered'); diff --git a/src/ui/modals/ManualFoodEntryModal.ts b/src/ui/modals/ManualFoodEntryModal.ts index e351949..fed9831 100644 --- a/src/ui/modals/ManualFoodEntryModal.ts +++ b/src/ui/modals/ManualFoodEntryModal.ts @@ -254,7 +254,7 @@ export class ManualFoodEntryModal extends Modal { // Only show status section if we have added items if (this.addedItems.length > 0) { - this.statusContainer.style.display = 'block'; + this.statusContainer.removeClass('macros-u-hidden'); const addedHeader = this.statusContainer.createDiv({ cls: 'added-items-header' }); addedHeader.createEl('h3', { @@ -265,7 +265,7 @@ export class ManualFoodEntryModal extends Modal { this.addedItemsList = this.statusContainer.createDiv({ cls: 'added-items-list' }); this.updateAddedItemsDisplay(); } else { - this.statusContainer.style.display = 'none'; + this.statusContainer.addClass('macros-u-hidden'); } } @@ -303,10 +303,10 @@ export class ManualFoodEntryModal extends Modal { // Show/hide status section based on items if (this.addedItems.length > 0) { - this.statusContainer.style.display = 'block'; + this.statusContainer.removeClass('macros-u-hidden'); this.updateAddedItemsDisplay(); } else { - this.statusContainer.style.display = 'none'; + this.statusContainer.addClass('macros-u-hidden'); } } @@ -326,7 +326,7 @@ export class ManualFoodEntryModal extends Modal { }); const body = section.createDiv({ cls: 'micronutrient-entry-body' }); - body.style.display = 'none'; + body.addClass('macros-u-hidden'); let expanded = false; const toggle = () => { diff --git a/src/utils/TooltipManager.ts b/src/utils/TooltipManager.ts index 9c83375..49bfe5f 100644 --- a/src/utils/TooltipManager.ts +++ b/src/utils/TooltipManager.ts @@ -16,7 +16,7 @@ function ensureTooltipEl(): HTMLDivElement { if (!tooltipEl) { tooltipEl = activeDocument.createElement('div'); tooltipEl.className = 'macro-tooltip macro-tooltip-hidden'; - tooltipEl.setAttribute('style', '--x: -9999px; --y: -9999px;'); + tooltipEl.setCssProps({ '--x': '-9999px', '--y': '-9999px' }); activeDocument.body.appendChild(tooltipEl); } return tooltipEl; diff --git a/styles.css b/styles.css index 2a17f05..8bad198 100644 --- a/styles.css +++ b/styles.css @@ -9292,3 +9292,5 @@ body:not(.theme-obsidian) .api-credentials-success { font-size: 0.75rem; color: var(--text-faint); } + +.macros-u-hidden { display: none !important; }