From c38a3b68150c6a6ee4601764eb291561fc26d13d Mon Sep 17 00:00:00 2001 From: Wonsuk Choi Date: Wed, 17 Jul 2024 20:27:20 +0900 Subject: [PATCH] =?UTF-8?q?feat(ui/utils):=20toPx=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/ui/utils/src/index.ts | 1 + packages/ui/utils/src/toPx.ts | 11 +++++++++++ 2 files changed, 12 insertions(+) create mode 100644 packages/ui/utils/src/toPx.ts 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; +}