Skip to content

Commit 43c29a4

Browse files
authored
Merge pull request #1487 from w3bdesign/develop
Improve design of quantity
2 parents 0dd6d48 + 630e541 commit 43c29a4

File tree

1 file changed

+12
-23
lines changed

1 file changed

+12
-23
lines changed

components/common/CommonInput.vue

Lines changed: 12 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,24 @@
11
<template>
2-
<div class="flex items-center space-x-2">
2+
<div
3+
class="flex items-center border border-gray-200 rounded-xl bg-white px-2 py-1 min-w-[120px] w-fit h-10 justify-center gap-1"
4+
>
35
<button
4-
class="px-2 py-1 bg-gray-200 rounded disabled:opacity-50"
6+
class="bg-transparent border-none text-gray-900 text-xl w-9 h-9 flex items-center justify-center rounded-lg transition-colors select-none disabled:text-gray-300 disabled:cursor-not-allowed active:bg-gray-100"
57
:disabled="loading || value <= min"
68
@click="updateValue(value - 1)"
79
aria-label="Decrease quantity"
8-
>
9-
-
10-
</button>
11-
<input
12-
type="number"
13-
:value="value"
14-
:min="min"
15-
:max="max"
16-
class="w-12 text-center border rounded"
17-
:disabled="loading"
18-
@input="onInput"
19-
/>
10+
type="button"
11+
>-</button>
12+
<div class="border-l border-gray-200 h-6 mx-1"></div>
13+
<span class="min-w-8 text-center font-medium text-lg text-gray-900 px-2 select-none">{{ value }}</span>
14+
<div class="border-l border-gray-200 h-6 mx-1"></div>
2015
<button
21-
class="px-2 py-1 bg-gray-200 rounded disabled:opacity-50"
16+
class="bg-transparent border-none text-gray-900 text-xl w-9 h-9 flex items-center justify-center rounded-lg transition-colors select-none disabled:text-gray-300 disabled:cursor-not-allowed active:bg-gray-100"
2217
:disabled="loading || (max !== null && value >= max)"
2318
@click="updateValue(value + 1)"
2419
aria-label="Increase quantity"
25-
>
26-
+
27-
</button>
20+
type="button"
21+
>+</button>
2822
</div>
2923
</template>
3024

@@ -60,9 +54,4 @@ function updateValue(newValue) {
6054
if (newValue < props.min) return;
6155
emit("update:modelValue", newValue);
6256
}
63-
64-
function onInput(e) {
65-
const newValue = Number(e.target.value);
66-
updateValue(newValue);
67-
}
6857
</script>

0 commit comments

Comments
 (0)