Skip to content

Commit

Permalink
fix: properties with value '0' not being set (#355)
Browse files Browse the repository at this point in the history
* fix: properties with value '0' not being set

* chore: changesets
  • Loading branch information
dalechyn authored Jun 10, 2024
1 parent e1d5597 commit 7d75e97
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
5 changes: 5 additions & 0 deletions .changeset/cyan-cups-sing.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"frog": patch
---

Fixed a bug where properties on UI elements having `0` value were not being set, such as `left="0"` and etc.
4 changes: 2 additions & 2 deletions src/ui/Box.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -331,7 +331,7 @@ function resolveToken<vars extends Record<string, unknown>>(
):
| { value: vars[keyof vars]; type: 'token' }
| { value: string; type: 'custom' } {
if (!value) return { type: 'token', value: fallback } as any
if (value === undefined) return { type: 'token', value: fallback } as any
if (typeof value === 'object')
return { type: 'custom', value: value.custom } as any
return { type: 'token', value: vars?.[value] } as any
Expand Down Expand Up @@ -361,7 +361,7 @@ export function resolveUnitToken(
const unit = resolveToken(units, normalizedValue, fallback)
if (normalizedValue === '100%' || unit.value === '100%') return '100%'
if (unit.type === 'custom') return unit.value
if (!unit.value) return undefined
if (unit.value === undefined) return undefined
const resolved =
(typeof value === 'string' && value.startsWith('-') ? -1 : +1) *
unit.value *
Expand Down

0 comments on commit 7d75e97

Please sign in to comment.