Skip to content

Commit

Permalink
Add missing symbol part to SSR
Browse files Browse the repository at this point in the history
  • Loading branch information
barvian committed Jan 6, 2025
1 parent e92bb54 commit 34ea785
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 1 deletion.
8 changes: 8 additions & 0 deletions .changeset/tiny-schools-press.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
'number-flow': patch
'@number-flow/react': patch
'@number-flow/svelte': patch
'@number-flow/vue': patch
---

Add missing symbol part to SSR
2 changes: 1 addition & 1 deletion packages/number-flow/src/ssr.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ const styles = css`
`

const renderPart = (part: KeyedNumberPart) =>
`<span class="${part.type === 'integer' || part.type === 'fraction' ? 'digit' : 'symbol'}" part="${part.type === 'integer' || part.type === 'fraction' ? `digit ${part.type}-digit` : part.type}">${part.value}</span>`
`<span class="${part.type === 'integer' || part.type === 'fraction' ? 'digit' : 'symbol'}" part="${part.type === 'integer' || part.type === 'fraction' ? `digit ${part.type}-digit` : `symbol ${part.type}`}">${part.value}</span>`

const renderSection = (section: KeyedNumberPart[], part: string) =>
`<span part="${part}">${section.reduce((str, p) => str + renderPart(p), '')}</span>`
Expand Down
1 change: 1 addition & 0 deletions test-suites/wrapper/render.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ test('renders correctly', async ({ page }) => {
// Check for parts
await expect(flow.locator('[part~=left]')).toBeAttached()
await expect(flow.locator('[part~=currency]')).toBeAttached()
await expect(flow.locator('[part~=symbol]')).toHaveCount(4)
await expect(flow.locator('[part~=number]')).toBeAttached()
await expect(flow.locator('[part~=integer]')).toBeAttached()
await expect(flow.locator('[part~=fraction]')).toBeAttached()
Expand Down

0 comments on commit 34ea785

Please sign in to comment.