-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Expand file tree
/
Copy pathProductButtons.tsx
More file actions
31 lines (24 loc) · 847 Bytes
/
ProductButtons.tsx
File metadata and controls
31 lines (24 loc) · 847 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
import { useContext } from "react";
import { ProductContext } from "./ProductCard";
import styles from '../styles/styles.module.css'
export interface Props {
className?: string;
style?: React.CSSProperties
}
export const ProductButtons = ({ className, style }: Props) => {
const { increaseBy, counter } = useContext( ProductContext );
return (
<div
className={ `${ styles.buttonsContainer} ${ className }` }
style={ style }
>
<button
className={ styles.buttonMinus }
onClick={ () => increaseBy( -1 ) }> - </button>
<div className={ styles.countLabel }> { counter } </div>
<button
className={ styles.buttonAdd }
onClick={ () => increaseBy( +1 ) }> + </button>
</div>
);
}