Enhance theme handling and color selection for logos; add utility functions for theme-based color retrieval and improve debug logging across components.

This commit is contained in:
sha
2025-04-29 18:02:07 +03:00
parent 28e72b7af0
commit e5482c549e
8 changed files with 131 additions and 48 deletions
+7 -7
View File
@@ -3,6 +3,7 @@
export let path;
export let color;
export let colorConfig = { target: 'path', attribute: 'fill' };
export let alt;
let svgHtml = '';
@@ -54,18 +55,17 @@
// Legacy: force a single attribute
el.setAttribute(colorConfig.attribute, color);
} else {
// Only set fill if no stroke attribute exists, and vice versa
const hasFill = el.hasAttribute('fill');
const hasStroke = el.hasAttribute('stroke');
if (hasFill && !hasStroke && el.getAttribute('fill') !== 'none') {
// Always override fill and stroke unless they are 'none'
if (el.hasAttribute('fill') && el.getAttribute('fill') !== 'none') {
el.setAttribute('fill', color);
} else if (hasStroke && !hasFill && el.getAttribute('stroke') !== 'none') {
}
if (el.hasAttribute('stroke') && el.getAttribute('stroke') !== 'none') {
el.setAttribute('stroke', color);
} else if (!hasFill && !hasStroke) {
}
if (!el.hasAttribute('fill') && !el.hasAttribute('stroke')) {
// If neither, prefer fill
el.setAttribute('fill', color);
}
// If both fill and stroke exist, do not override either
}
});
svgHtml = doc.documentElement.outerHTML;