reza merged Product

master
Reza_ashrafi 3 years ago
parent a3c5099b95
commit 080eb2cb27
  1. 1
      package.json
  2. 7
      src/components/Counter/black-dislike-icon.svg
  3. 7
      src/components/Counter/black-like-icon.svg
  4. 42
      src/components/Counter/index.js
  5. BIN
      src/components/Product/discount.png
  6. BIN
      src/components/Product/goldon.png
  7. 260
      src/components/Product/index.js
  8. 3
      src/components/Product/lightBlueDotIcon.svg
  9. 3
      src/components/Product/purpleDotIcon.svg
  10. 3
      src/components/Product/redDotIcon.svg
  11. 8
      src/components/Product/vuesax-linear-heart.svg
  12. BIN
      src/components/Product/watermelon.png
  13. 3
      src/components/Product/yellowDotIcon.svg
  14. 12
      src/redux/data.js
  15. 13
      yarn.lock

@ -18,6 +18,7 @@
"react-router-dom": "^6.2.1",
"react-scripts": "4.0.3",
"react-star-rating-component": "^1.4.1",
"react-tooltip": "^4.2.21",
"recharts": "^2.1.8",
"redux": "^4.1.2",
"redux-devtools-extension": "^2.13.9",

@ -0,0 +1,7 @@
<svg id="vuesax_linear_dislike" data-name="vuesax/linear/dislike" xmlns="http://www.w3.org/2000/svg" width="49.199" height="49.199" viewBox="0 0 49.199 49.199">
<g id="dislike" transform="translate(0 0)">
<path id="Vector" d="M28.984,6.15,22.629,1.23A6.308,6.308,0,0,0,18.734,0h-7.79A6.157,6.157,0,0,0,5.2,4.3L.285,19.27C-.74,22.14,1.1,24.6,4.18,24.6h8.2a2.068,2.068,0,0,1,2.05,2.46L13.4,33.619a4.044,4.044,0,0,0,2.665,4.51,4.093,4.093,0,0,0,4.51-1.435l8.4-12.5" transform="translate(4.881 5.432)" fill="none" stroke="#818181" stroke-width="1.5"/>
<path id="Vector-2" data-name="Vector" d="M10.25,3.895v20.09c0,2.87-1.23,3.895-4.1,3.895H4.1c-2.87,0-4.1-1.025-4.1-3.895V3.895C0,1.025,1.23,0,4.1,0H6.15C9.02,0,10.25,1.025,10.25,3.895Z" transform="translate(34.07 7.687)" fill="none" stroke="#818181" stroke-linecap="round" stroke-linejoin="round" stroke-width="1.5"/>
<path id="Vector-3" data-name="Vector" d="M0,0H49.2V49.2H0Z" fill="none" opacity="0"/>
</g>
</svg>

After

Width:  |  Height:  |  Size: 981 B

@ -0,0 +1,7 @@
<svg id="vuesax_linear_like" data-name="vuesax/linear/like" xmlns="http://www.w3.org/2000/svg" width="49.199" height="49.199" viewBox="0 0 49.199 49.199">
<g id="like" transform="translate(0 0)">
<path id="Vector" d="M0,32.189l6.355,4.92a6.308,6.308,0,0,0,3.895,1.23h7.79a6.157,6.157,0,0,0,5.74-4.3L28.7,19.069c1.025-2.87-.82-5.33-3.895-5.33H16.6a2.068,2.068,0,0,1-2.05-2.46l1.025-6.56A4.044,4.044,0,0,0,12.915.209,4.093,4.093,0,0,0,8.4,1.644L0,14.149" transform="translate(15.334 5.428)" fill="#fff" stroke="#818181" stroke-width="1.5"/>
<path id="Vector-2" data-name="Vector" d="M0,23.985V3.895C0,1.025,1.23,0,4.1,0H6.15c2.87,0,4.1,1.025,4.1,3.895v20.09c0,2.87-1.23,3.895-4.1,3.895H4.1C1.23,27.88,0,26.855,0,23.985Z" transform="translate(4.879 13.632)" fill="#fff" stroke="#818181" stroke-linecap="round" stroke-linejoin="round" stroke-width="1.5"/>
<path id="Vector-3" data-name="Vector" d="M0,0H49.2V49.2H0Z" fill="#fff" opacity="0"/>
</g>
</svg>

After

Width:  |  Height:  |  Size: 967 B

@ -1,11 +1,39 @@
import React from 'react'
import React, { useState } from "react";
import blackDisLikeIcon from "./black-dislike-icon.svg";
import blackLikeIcon from "./black-like-icon.svg";
const Counter = ({ incrementIcon, decrementIcon, flex }) => {
const [count, setCount] = useState(0);
function Counter({}) {
return (
<div>
<div className={`flex ${flex} items-center`}>
<img
src={incrementIcon}
alt=""
className="w-8 cursor-pointer pointer transition delay-150 duration-300 ease-in-out transform hover:-translate-y-2"
onClick={() => setCount(count + 1)}
/>
<span
className={`text-sm sm:text-base md:text-2xl font-bold text-color ${flex === 'flex-col' ? 'my-2' : 'mx-2'}`}
style={count > 0 ? { color: "green" } : { color: "red" }}
>
{count}
</span>
<img
src={decrementIcon}
alt=""
className="w-8 cursor-pointer transition delay-150 duration-300 ease-in-out transform hover:translate-y-2"
onClick={() => setCount(count - 1)}
/>
</div>
)
}
);
};
export default Counter;
export default Counter
Counter.defaultProps = {
incrementIcon: blackLikeIcon,
decrementIcon: blackDisLikeIcon,
flex: "flex-col",
};

Binary file not shown.

After

Width:  |  Height:  |  Size: 868 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 86 KiB

@ -0,0 +1,260 @@
import React, { useState } from "react";
import StarRating from "../StarRating";
import Tag from "../Tag";
import ReactTooltip from "react-tooltip";
import book from "./goldon.png";
import watermelon from "./watermelon.png";
import heart from "./vuesax-linear-heart.svg";
import discountImg from "./discount.png";
import YellowDotIcon from "./yellowDotIcon.svg";
import RedDotIcon from "./redDotIcon.svg";
import PurpleDotIcon from "./purpleDotIcon.svg";
import LightBlueDotIcon from "./lightBlueDotIcon.svg";
const ProductDesign = ({
colors,
likeBtn,
discount,
discountPricePercent,
discountPrice,
productContent,
star,
productTags,
priceDirection,
productTitleAlignment,
priceHolder,
productHolderBorder,
productHolderBorderColor,
productTitleColor,
productExcerptTextColor,
productCat,
productCatTextColor,
rangeHolder,
verticalImg,
horizontalImg,
rangeWidth,
addToCartHolder,
}) => {
const [isHovering, setIsHovering] = useState(false);
return (
<div className="flex flex-wrap sm:flex-nowrap justify-around">
<div className="w-full flex flex-wrap items-center justify-around my-10 px-4">
<div
className={`w-full sm:w-60 md:w-72 mx-1 rounded-lg shadow-sm p-2 my-3 ${productHolderBorder} ${productHolderBorderColor}`}
>
{/* product image */}
<div className="w-full relative">
{/* icons on image */}
<div className="absolute left-2 top-2">
{discountPricePercent && (
<div className="bg-discountPriceBg rounded-md px-2">
<p className="text-discountPriceTitle font-bold text-xs">
23<span>%</span>
</p>
</div>
)}
{likeBtn && (
<div className="bg-likeBtnBg rounded-md flex justify-center my-2">
<img src={heart} alt="" className="w-5" />
</div>
)}
{discount && (
<div className="rounded-md">
<img src={discountImg} alt="" className="w-full" />
</div>
)}
</div>
{/* img */}
<div className="flex-shrink-0">
{verticalImg && (
<img
src={book}
alt=""
className="w-full rounded-lg cursor-pointer"
onMouseEnter={() => setIsHovering(true)}
onMouseLeave={() => setIsHovering(false)}
/>
)}
{horizontalImg && (
<img src={watermelon} alt="" className="w-full rounded-lg" />
)}
</div>
{/* select Color */}
{colors && (
<div className="flex items-center absolute right-2 bottom-2">
<img
src={YellowDotIcon}
alt=""
data-tip="زرد"
className="w-3 h-3 ml-1 cursor-pointer"
/>
<ReactTooltip place="top" type="dark" effect="float" />
<img
src={RedDotIcon}
alt=""
data-tip="قرمز"
className="w-3 h-3 ml-1 cursor-pointer"
/>
<ReactTooltip place="top" type="dark" effect="float" />
<img
src={PurpleDotIcon}
alt=""
data-tip="بنفش"
className="w-3 h-3 ml-1 cursor-pointer"
/>
<ReactTooltip place="top" type="dark" effect="float" />
<img
src={LightBlueDotIcon}
alt=""
data-tip="آبی"
className="w-3 h-3 ml-1 cursor-pointer"
/>
<ReactTooltip place="top" type="dark" effect="float" />
</div>
)}
<div
className={`bg-blueBgColor text-white rounded p-2 text-xs absolute left-1/2 bottom-7 transform -translate-x-1/2 -translate-y-1/2 ${
isHovering ? "" : "hidden"
}`}
>
<button>افزودن به سبد خرید</button>
</div>
</div>
{/* product content */}
<div className="px-2">
<div className="mt-4">
<h2
className={`leading-4 text-sm ${productTitleColor} ${productTitleAlignment}`}
>
نسخه چاپی علموم تجربه هفتم
</h2>
{productContent && (
<p
className={`text-justify mt-2 text-xs leading-6 ${productExcerptTextColor}`}
>
این کتاب شامل گلدان و گیاه و خاک می باشد و همچنین آپشن های خوب
دیگری نیز دارد.
</p>
)}
{productCat && (
<span className={`text-xs font-light ${productCatTextColor}`}>
پایه سوم
</span>
)}
</div>
{/* star */}
{star && (
<div className="flex items-center mt-2">
<StarRating />
<span className="text-xs text-productContent font-bold mr-2">
39
</span>
</div>
)}
{/* price */}
{priceHolder && (
<div
className={`flex items-center justify-between ${priceDirection}`}
>
<div className="mt-2">
<div
className={`${
priceDirection.indexOf("col") !== -1 ? "inline" : "flex"
}`}
>
<span className="text-xs text-borderColor ml-2">قیمت</span>
{/* price with line on it */}
{discountPrice && (
<p className="line-through text-xs text-borderColor mr-2">
145<span>تومان</span>
</p>
)}
</div>
<p className="text-sm text-productPrice font-semibold inline">
145.000<span>تومان</span>
</p>
</div>
{/* add to cart */}
{addToCartHolder && (
<button
className={`rounded-2xl px-2 py-3 border text-xs text-productPrice mt-2 hover:bg-darkCrimsonBgColor hover:text-white active:bg-rangeFillBgColor transition duration-500 hover:-translate-y-2 ${
priceDirection.indexOf("col") !== -1 ? "w-full" : ""
}`}
>
اضافه کردن به سبد خرید
</button>
)}
</div>
)}
{productTags && (
<div className="mt-2 flex flex-wrap">
{
productTags.map((item, index) => <Tag title={item} key={index} />)
}
</div>
)}
{rangeHolder && (
<div className="bg-rangeBgColor h-3 w-full rounded mt-2">
<div
className={`bg-rangeFillBgColor h-3 rounded ${rangeWidth}`}
></div>
</div>
)}
</div>
</div>
</div>
</div>
);
};
export default ProductDesign;
// text colors i used for product title:
// text-darkCrimsonTextColor
// text-productTitle
// text color i used for product excerpt:
// text-productContent
// text color i used for product cat:
// text-darkCrimsonTextColor
ProductDesign.defaultProps = {
// icons on product image
colors: true,
likeBtn: true,
discount: true,
discountPricePercent: true,
// product price
discountPrice: true,
priceHolder: true,
productContent: true,
star: true,
productTags: ["ارسال رایگان", "برچسب های دیگر", "دسته بندی به صورت کادو"],
productCat: true,
rangeHolder: true,
// دو مدل عکس طراحی کردم که یکی عرض بیشتری دارد یکی ارتفاع
verticalImg: true,
horizontalImg: false,
addToCartHolder: true,
productTitleColor: "text-productTitle",
productExcerptTextColor: "text-productContent",
productCatTextColor: "text-darkCrimsonTextColor",
// برای درصد دادن به عرض رنج
rangeWidth: "w-44",
//دی ای وی که محصول داخلش است میتونیم بهش بوردر بدیم
productHolderBorder: "border",
productHolderBorderColor: "border-grayBorderColor",
productTitleAlignment: "text-justify",
//میتونیم تعیین کنیم که قیمت و دکمه اضاف به سبد خرید کنار یکدیگر باشند یا زیر هم
priceDirection: "flex-row",
};

@ -0,0 +1,3 @@
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 16 16">
<circle id="Ellipse_18" data-name="Ellipse 18" cx="8" cy="8" r="8" fill="#89ecff"/>
</svg>

After

Width:  |  Height:  |  Size: 177 B

@ -0,0 +1,3 @@
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 16 16">
<circle id="Ellipse_17" data-name="Ellipse 17" cx="8" cy="8" r="8" fill="#924eeb"/>
</svg>

After

Width:  |  Height:  |  Size: 177 B

@ -0,0 +1,3 @@
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 16 16">
<circle id="Ellipse_19" data-name="Ellipse 19" cx="8" cy="8" r="8" fill="#fc5353"/>
</svg>

After

Width:  |  Height:  |  Size: 177 B

@ -0,0 +1,8 @@
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24">
<g id="vuesax_linear_heart" data-name="vuesax/linear/heart" transform="translate(-236 -188)">
<g id="heart">
<path id="Vector" d="M10.62,17.71a2.181,2.181,0,0,1-1.24,0C6.48,16.72,0,12.59,0,5.59A5.574,5.574,0,0,1,5.56,0,5.515,5.515,0,0,1,10,2.24,5.547,5.547,0,0,1,20,5.59C20,12.59,13.52,16.72,10.62,17.71Z" transform="translate(238 191.1)" fill="none" stroke="#e11010" stroke-linecap="round" stroke-linejoin="round" stroke-width="1.5"/>
<path id="Vector-2" data-name="Vector" d="M0,0H24V24H0Z" transform="translate(236 188)" fill="none" opacity="0"/>
</g>
</g>
</svg>

After

Width:  |  Height:  |  Size: 675 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 34 KiB

@ -0,0 +1,3 @@
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 16 16">
<circle id="Ellipse_20" data-name="Ellipse 20" cx="8" cy="8" r="8" fill="#fcf653"/>
</svg>

After

Width:  |  Height:  |  Size: 177 B

@ -19,6 +19,7 @@ import StarRating from '../components/StarRating';
import Chart from "../components/Recharts";
import CircularProgressbar from "../components/CircularProgressbar";
import Stepper from "../components/Stepper";
import Product from "../components/Product";
const components = [
{
@ -445,6 +446,17 @@ const components = [
code : null,
}
},
{
name : "Product",
props : [
],
content : {
name : "Product",
component : <Product />,
code : null,
}
},
];
export default components;

@ -9854,6 +9854,14 @@ react-syntax-highlighter@^12.2.1:
prismjs "^1.8.4"
refractor "^2.4.1"
react-tooltip@^4.2.21:
version "4.2.21"
resolved "https://registry.yarnpkg.com/react-tooltip/-/react-tooltip-4.2.21.tgz#840123ed86cf33d50ddde8ec8813b2960bfded7f"
integrity sha512-zSLprMymBDowknr0KVDiJ05IjZn9mQhhg4PRsqln0OZtURAJ1snt1xi5daZfagsh6vfsziZrc9pErPTDY1ACig==
dependencies:
prop-types "^15.7.2"
uuid "^7.0.3"
react-transition-group@2.9.0:
version "2.9.0"
resolved "https://registry.yarnpkg.com/react-transition-group/-/react-transition-group-2.9.0.tgz#df9cdb025796211151a436c69a8f3b97b5b07c8d"
@ -11769,6 +11777,11 @@ uuid@^3.3.2:
resolved "https://registry.yarnpkg.com/uuid/-/uuid-3.4.0.tgz#b23e4358afa8a202fe7a100af1f5f883f02007ee"
integrity sha512-HjSDRw6gZE5JMggctHBcjVak08+KEVhSIiDzFnT9S9aegmp85S/bReBVTb4QTFaRNptJ9kuYaNhnbNEOkbKb/A==
uuid@^7.0.3:
version "7.0.3"
resolved "https://registry.yarnpkg.com/uuid/-/uuid-7.0.3.tgz#c5c9f2c8cf25dc0a372c4df1441c41f5bd0c680b"
integrity sha512-DPSke0pXhTZgoF/d+WSt2QaKMCFSfx7QegxEWT+JOuHF5aWrKEn0G+ztjuJg/gG8/ItK+rbPCD/yNv8yyih6Cg==
uuid@^8.3.0, uuid@^8.3.2:
version "8.3.2"
resolved "https://registry.yarnpkg.com/uuid/-/uuid-8.3.2.tgz#80d5b5ced271bb9af6c445f21a1a04c606cefbe2"

Loading…
Cancel
Save