Skip to content

Commit

Permalink
Fix pxToBaseSize method returning a comma instead for decimals on loc…
Browse files Browse the repository at this point in the history
…al environment (fr_BE)
  • Loading branch information
drskullster committed Dec 2, 2024
1 parent d48f5e5 commit f01aeee
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
4 changes: 2 additions & 2 deletions scripts/transform.ts
Original file line number Diff line number Diff line change
Expand Up @@ -138,8 +138,8 @@ function addTokenToObject(
return obj;
}

function pxToBaseSize(value: number, decimals = 3) {
return (value / BASE_FONT_SIZE).toLocaleString(undefined, {
export function pxToBaseSize(value: number, decimals = 3) {
return (value / BASE_FONT_SIZE).toLocaleString('en', {
maximumFractionDigits: decimals,
});
}
Expand Down
4 changes: 3 additions & 1 deletion tests/transform.spec.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { expect, test } from 'vitest';
import { flattenDefaultTokens } from '../scripts/transform';
import { flattenDefaultTokens, pxToBaseSize } from '../scripts/transform';
import { TransformedToken } from 'style-dictionary';

const sampleTokens: TransformedToken[] = [
Expand Down Expand Up @@ -63,4 +63,6 @@ test('Flatten default tokens', () => {
value: 'number',
},
});

expect(pxToBaseSize(40)).toEqual('2.857');
});

0 comments on commit f01aeee

Please sign in to comment.