Skip to content

Commit

Permalink
feat(shared): numToPx
Browse files Browse the repository at this point in the history
  • Loading branch information
mengxinssfd committed Jun 18, 2023
1 parent 35e4586 commit c75a151
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
1 change: 1 addition & 0 deletions packages/shared/src/utils/index.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
export * from './getComponentClass';
export * from './nextTick';
export * from './numToPx';
10 changes: 10 additions & 0 deletions packages/shared/src/utils/numToPx.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
export function numToPx<T>(
value: number | string | undefined,
defValue: T,
): string | T {
return value === undefined
? defValue
: typeof value === 'number'
? `${value}px`
: value;
}

0 comments on commit c75a151

Please sign in to comment.