Skip to content

Commit

Permalink
Fix mysteriously broken type
Browse files Browse the repository at this point in the history
  • Loading branch information
sarayourfriend committed Jun 28, 2021
1 parent b966e09 commit 9b967ef
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion packages/components/src/ui/utils/space.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/**
* A real number or something parsable as a number
*/
export type SpaceInput = number | `${ number }`;
export type SpaceInput = number | string;

const GRID_BASE = '4px';

Expand All @@ -10,5 +10,11 @@ export function space( value?: SpaceInput ): string | undefined {
return undefined;
}

const asInt = typeof value === 'number' ? value : parseInt( value, 10 );

if ( Number.isNaN( asInt ) ) {
return value.toString();
}

return `calc(${ GRID_BASE } * ${ value })`;
}

0 comments on commit 9b967ef

Please sign in to comment.