Skip to content

Commit

Permalink
fix bug in currentColor replacement for icons forced as background (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
JensDll authored Nov 15, 2022
1 parent 49e213e commit b4f3e76
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
4 changes: 2 additions & 2 deletions packages/shared/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,8 @@ export function parseIconName(iconName: string) {
return { normalizedIconName, iconMode }
}

export function iconToDataUrl(icon: LoadedIcon) {
const svg = `<svg viewBox="${icon.left} ${icon.top} ${icon.width} ${icon.height}">${icon.body}</svg>`
export function iconToDataUrl(icon: LoadedIcon, body = icon.body) {
const svg = `<svg viewBox="${icon.left} ${icon.top} ${icon.width} ${icon.height}">${body}</svg>`
return `url("data:image/svg+xml,${encodeSvg(svg)}")`
}

Expand Down
7 changes: 4 additions & 3 deletions packages/tailwindcss-plugin-icons/src/css.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,11 @@ export function getIconCssAsColorFunction(
cssDefaults: CSSRuleObjectWithScale
): ColorFunction {
return color => {
icon.body = icon.body.replace(/currentColor/g, color)

return {
[URL_VAR_NAME]: iconToDataUrl(icon),
[URL_VAR_NAME]: iconToDataUrl(
icon,
icon.body.replace(/currentColor/g, color)
),
background: `var(${URL_VAR_NAME}) no-repeat`,
backgroundSize: '100% 100%',
...getIconDimensions(icon, cssDefaults[SCALE]),
Expand Down

0 comments on commit b4f3e76

Please sign in to comment.