Skip to content

Commit

Permalink
fix: svg asset token conversion
Browse files Browse the repository at this point in the history
  • Loading branch information
segunadebayo committed Feb 23, 2024
1 parent 5184771 commit 6d8c884
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 5 deletions.
5 changes: 5 additions & 0 deletions .changeset/slimy-experts-brush.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@pandacss/token-dictionary': patch
---

Fix issue where svg asset tokens doesn't work as expected due to unbalanced quotes.
8 changes: 4 additions & 4 deletions packages/token-dictionary/__tests__/transform-asset.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,13 @@ describe('transform / assets', () => {
"prop": "checkbox",
},
"name": "assets.checkbox",
"originalValue": "url('data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 16 16'%3e%3cpath stroke='white' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M4 8h8'/%3e%3c/svg%3e)'",
"originalValue": "url('data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 16 16'%3e%3cpath stroke='white' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M4 8h8'/%3e%3c/svg%3e')",
"path": [
"assets",
"checkbox",
],
"type": "asset",
"value": "url('data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 16 16'%3e%3cpath stroke='white' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M4 8h8'/%3e%3c/svg%3e)'",
"value": "url('data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 16 16'%3e%3cpath stroke='white' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M4 8h8'/%3e%3c/svg%3e')",
},
]
`)
Expand Down Expand Up @@ -72,13 +72,13 @@ describe('transform / assets', () => {
"prop": "checkbox",
},
"name": "assets.checkbox",
"originalValue": "url('data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 16 16'%3e%3cpath stroke='white' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M4 8h8'/%3e%3c/svg%3e)'",
"originalValue": "url('data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 16 16'%3e%3cpath stroke='white' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M4 8h8'/%3e%3c/svg%3e')",
"path": [
"assets",
"checkbox",
],
"type": "asset",
"value": "url('data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 16 16'%3e%3cpath stroke='white' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M4 8h8'/%3e%3c/svg%3e)'",
"value": "url('data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 16 16'%3e%3cpath stroke='white' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M4 8h8'/%3e%3c/svg%3e')",
},
]
`)
Expand Down
2 changes: 1 addition & 1 deletion packages/token-dictionary/src/transform.ts
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ export const transformAssets: TokenTransformer = {
return match(raw)
.with(P.string, (value) => value)
.with({ type: 'url' }, ({ value }) => `url('${value}')`)
.with({ type: 'svg' }, ({ value }) => `url('${svgToDataUri(value)})'`)
.with({ type: 'svg' }, ({ value }) => `url('${svgToDataUri(value)}')`)
.exhaustive()
},
}
Expand Down

0 comments on commit 6d8c884

Please sign in to comment.