From a93d1dfb6ca79d24412c8c4abaf6484d2be1ba78 Mon Sep 17 00:00:00 2001 From: aidenlx Date: Wed, 9 Mar 2022 16:53:37 +0800 Subject: [PATCH] feat(icon-packs): fix font awesome icons not following context color --- src/icon-packs/file-icon.ts | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/icon-packs/file-icon.ts b/src/icon-packs/file-icon.ts index fe20dff..a6685f0 100644 --- a/src/icon-packs/file-icon.ts +++ b/src/icon-packs/file-icon.ts @@ -60,8 +60,9 @@ export class FileIconData implements FileIconDataType { return (async () => { const svgEl = await this.plugin.fileIconCache.getIcon(this.path); if (svgEl) { - el.append(svgEl); svgEl.addClass("isc-svg-icon"); + this.fixFontAwesome(svgEl); + el.append(svgEl); } else { console.error("failed to get icon data for", this.path); } @@ -73,4 +74,12 @@ export class FileIconData implements FileIconDataType { return el; } } + + fixFontAwesome(svg: SVGElement): void { + if (!faPacks.includes(this.pack)) return; + for (const pathEl of svg.getElementsByTagName("path")) { + pathEl.setAttr("fill", "currentColor"); + } + } } +const faPacks = ["fab", "far", "fas"];