We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 8c3bb17 commit 384eedcCopy full SHA for 384eedc
src/plugin/composables/helpers.ts
@@ -0,0 +1,19 @@
1
+import { UseConvertToUnit } from '@/types';
2
+
3
4
+/**
5
+* Converts a string to a number with a unit.
6
+*/
7
+export const useConvertToUnit: UseConvertToUnit = (options) => {
8
+ const { str, unit = 'px' } = options;
9
10
+ if (str == null || str === '') {
11
+ return undefined;
12
+ }
13
14
+ if (!+str) {
15
+ return String(str);
16
17
18
+ return `${Number(str)}${unit}`;
19
+};
0 commit comments