master
mahdi 3 years ago
parent 818345078c
commit 1d62ae7371
  1. 20
      src/App.js
  2. 38
      src/components/counterDesign/CounterDesign.js

@ -14,17 +14,17 @@ import BlogDesign6 from "./components/Blogs/design6/BlogDesign6";
function App() { function App() {
return ( return (
<div className="App"> <div className="App">
<ProductDesign /> {/* <ProductDesign /> */}
<BookDesign /> {/* <BookDesign /> */}
<ButtonDesign /> {/* <ButtonDesign /> */}
<ProductTags /> {/* <ProductTags /> */}
<CounterDesign /> <CounterDesign />
<BlogDesign1 /> {/* <BlogDesign1 /> */}
<BlogDesign2 /> {/* <BlogDesign2 /> */}
<BlogDesign3 /> {/* <BlogDesign3 /> */}
<BlogDesign4 /> {/* <BlogDesign4 /> */}
<BlogDesign5 /> {/* <BlogDesign5 /> */}
<BlogDesign6 /> {/* <BlogDesign6 /> */}
</div> </div>
); );
} }

@ -1,4 +1,4 @@
import React from "react"; import React, { useState } from "react";
import "./CounterDesign.scss"; import "./CounterDesign.scss";
import blackDisLikeIcon from "../../assets/icons/black-dislike-icon.svg"; import blackDisLikeIcon from "../../assets/icons/black-dislike-icon.svg";
@ -16,6 +16,8 @@ const CounterDesign = ({
counterDecreaseBtn, counterDecreaseBtn,
likeBtn, likeBtn,
}) => { }) => {
const [count, setCount] = useState(0);
return ( return (
<section className="w-11/12 mx-auto p-4 bg-white rounded-md shadow-md my-8"> <section className="w-11/12 mx-auto p-4 bg-white rounded-md shadow-md my-8">
<div className="flex items-center justify-between mb-6"> <div className="flex items-center justify-between mb-6">
@ -35,20 +37,40 @@ const CounterDesign = ({
<div className="flex flex-col items-center justify-center"> <div className="flex flex-col items-center justify-center">
{likeBtn && ( {likeBtn && (
<div className="flex items-center"> <div className="flex items-center">
<img src={blackLikeIcon} alt="" className="w-8 mb-4" /> <img
<img src={blackDisLikeIcon} alt="" className="w-8 mb-4" /> src={blackLikeIcon}
alt=""
className="w-8 mb-4"
onClick={() => setCount(count + 1)}
/>
<img
src={blackDisLikeIcon}
alt=""
className="w-8 mb-4"
onClick={() => setCount(count - 1)}
/>
</div> </div>
)} )}
{counterIncreaseBtn && ( {counterIncreaseBtn && (
<img src={incrementCounterIcon} alt="" className="w-8 mb-4" /> <img
src={incrementCounterIcon}
alt=""
className="w-8 mb-4"
onClick={() => setCount(count + 1)}
/>
)} )}
<p <p
className={` text-sm sm:text-base md:text-2xl font-bold ${counterColor} `} className={` text-sm sm:text-base md:text-2xl font-bold ${counterColor} `}
> >
561 {count}{" "}
</p> </p>
{counterDecreaseBtn && ( {counterDecreaseBtn && (
<img src={decrementCounterIcon} alt="" className="w-8 mt-4" /> <img
src={decrementCounterIcon}
alt=""
className="w-8 mt-4"
onClick={() => setCount(count - 1)}
/>
)} )}
</div> </div>
</section> </section>
@ -65,6 +87,6 @@ CounterDesign.defaultProps = {
counterColor: "text-darkRedTextColor", counterColor: "text-darkRedTextColor",
// for icons // for icons
likeBtn: true, likeBtn: true,
counterIncreaseBtn: false, counterIncreaseBtn: true,
counterDecreaseBtn: false, counterDecreaseBtn: true,
}; };

Loading…
Cancel
Save