1
1
<script lang="ts" setup>
2
+ import { Distance } from ' @aklinker1/cutlist' ;
3
+
2
4
const optimize = useOptimizeForSetting ();
3
5
const bladeWidth = useBladeWidthSetting ();
4
6
const distanceUnit = useDistanceUnit ();
5
7
const showPartNumbers = useShowPartNumbers ();
8
+ const extraSpace = useExtraSpaceSetting ();
9
+
10
+ // Convert values when units change
11
+ watch (distanceUnit , (newUnit , oldUnit ) => {
12
+ if (! newUnit || ! oldUnit ) return ;
13
+
14
+ console .log (newUnit , oldUnit );
15
+ const convertValue = (value : Ref <string | number >) => {
16
+ const dist = new Distance (value .value + oldUnit );
17
+ value .value = dist [newUnit ];
18
+ };
19
+ convertValue (bladeWidth );
20
+ convertValue (extraSpace );
21
+ });
6
22
</script >
7
23
8
24
<template >
@@ -11,10 +27,14 @@ const showPartNumbers = useShowPartNumbers();
11
27
<USelect v-model =" distanceUnit" :options =" ['in', 'm', 'mm']" />
12
28
</UFormGroup >
13
29
14
- <UFormGroup label =" Blade width (in): " >
30
+ <UFormGroup : label =" ` Blade width (${distanceUnit}):` " >
15
31
<UInput v-model =" bladeWidth" type =" number" />
16
32
</UFormGroup >
17
33
34
+ <UFormGroup :label =" `Extra space (${distanceUnit}):`" >
35
+ <UInput v-model =" extraSpace" type =" number" />
36
+ </UFormGroup >
37
+
18
38
<UFormGroup label =" Optimize for:" >
19
39
<USelect v-model =" optimize" :options =" ['Cuts', 'Space']" />
20
40
</UFormGroup >
0 commit comments