diff --git a/packages/ui/utils/src/index.ts b/packages/ui/utils/src/index.ts index 4a699ab..00190cd 100644 --- a/packages/ui/utils/src/index.ts +++ b/packages/ui/utils/src/index.ts @@ -5,3 +5,4 @@ export * from './request'; export * from './merge-fns'; export * from './merge-props'; export * from './merge-styles'; +export * from './toPx'; diff --git a/packages/ui/utils/src/toPx.ts b/packages/ui/utils/src/toPx.ts new file mode 100644 index 0000000..2536c95 --- /dev/null +++ b/packages/ui/utils/src/toPx.ts @@ -0,0 +1,11 @@ +export function toPx(value: number | string | undefined) { + if (typeof value === 'undefined') { + return; + } + + if (typeof value === 'number') { + return value + 'px'; + } + + return value; +}