,
+ 'onChange' | 'min' | 'max' | 'step'
+ > {
+ type?: 'default' | 'small'
+ onChange?: (value: number) => void
+ initValue?: number
+ min?: number
+ max?: number
+ step?: number
}
-const QuanittyInput = (props: QuanittyInputProps) => {
- const [value, setvalue] = useState(0)
- return (
-
- setvalue(+e.target.value)} className={s.quanittyInput}/>
-
- )
+const QuanittyInput = ({
+ type = 'default',
+ onChange,
+ initValue = 0,
+ min,
+ max,
+ step = 1,
+ ...props
+}: QuanittyInputProps) => {
+ const [value, setValue] = useState(0)
+
+ useEffect(() => {
+ onChange && onChange(value)
+ }, [value])
+
+ useEffect(() => {
+ initValue && setValue(initValue)
+ }, [initValue])
+
+ const onPlusClick = () => {
+ if (max && value + step > max) {
+ setValue(max)
+ } else {
+ setValue(value + step)
+ }
+ }
+
+ const onMinusClick = () => {
+ if (min && value - step < min) {
+ setValue(min)
+ } else {
+ setValue(value - step)
+ }
+ }
+
+ const onValueChange = (e: ChangeEvent) => {
+ let value = Number(e.target.value) || 0
+ if (min && value < min) {
+ setValue(min)
+ } else if (max && value > max) {
+ setValue(max)
+ } else {
+ setValue(value)
+ }
+ }
+
+ return (
+
+ )
}
export default QuanittyInput
diff --git a/src/components/icons/Minus.tsx b/src/components/icons/Minus.tsx
new file mode 100644
index 000000000..7c3b97d30
--- /dev/null
+++ b/src/components/icons/Minus.tsx
@@ -0,0 +1,18 @@
+const ArrowRight = ({ ...props }) => {
+ return (
+
+ )
+}
+
+export default ArrowRight
diff --git a/src/components/icons/Plus.tsx b/src/components/icons/Plus.tsx
new file mode 100644
index 000000000..c8b2fcca3
--- /dev/null
+++ b/src/components/icons/Plus.tsx
@@ -0,0 +1,18 @@
+const ArrowLeft = ({ ...props }) => {
+ return (
+
+ )
+}
+
+export default ArrowLeft
diff --git a/tailwind.config.js b/tailwind.config.js
index b8f18475a..afbeb8bad 100644
--- a/tailwind.config.js
+++ b/tailwind.config.js
@@ -117,7 +117,7 @@ module.exports = {
},
caroucel:{
"arrow-height":"64px"
- }
+ },
},
},
plugins: [require('postcss-import'), require('tailwindcss'), require('autoprefixer')]