You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

293 lines
11 KiB

import React from "react";
import "./ProductDesign.scss";
3 years ago
import StarRating from "../starRating/StarRating";
3 years ago
import ReactTooltip from "react-tooltip";
import book from "../../assets/images/goldon.png";
3 years ago
import watermelon from "../../assets/images/watermelon.png";
3 years ago
import heart from "../../assets/icons/vuesax-linear-heart.svg";
import discountImg from "../../assets/icons/discount.png";
3 years ago
import YellowDotIcon from "../../assets/icons/yellowDotIcon.svg";
import RedDotIcon from "../../assets/icons/redDotIcon.svg";
import PurpleDotIcon from "../../assets/icons/purpleDotIcon.svg";
import LightBlueDotIcon from "../../assets/icons/lightBlueDotIcon.svg";
const ProductDesign = ({
colors,
likeBtn,
discount,
discountPricePercent,
discountPrice,
productContent,
star,
productTags,
priceDirection,
productTitleAlignment,
3 years ago
priceHolder,
productHolderBorder,
productHolderBorderColor,
productTitleColor,
3 years ago
productExcerptTextColor,
3 years ago
productCat,
3 years ago
productCatTextColor,
3 years ago
rangeHolder,
verticalImg,
horizontalImg,
3 years ago
rangeWidth,
}) => {
return (
<section className="w-11/12 mx-auto p-4 bg-white rounded-md shadow-md my-8">
{/* title holder */}
<div className="flex items-center justify-between mb-6">
<h2 className="text-lg text-$productTitle">آیتم محصولات</h2>
<button className="bg-indigo-500 text-white rounded shadow-lg p-2">
مشاهده تمام محصولات
</button>
</div>
3 years ago
<div>
<p className="leading-10">
نام این کامپوننت
<span className="bg-blue-400 text-white rounded shadow-sm px-2 py-1 mx-2">
productDesign
</span>
3 years ago
است و داخل این کامپوننت شما میتوانید با
3 years ago
<span className="bg-blue-400 text-white rounded shadow-sm px-2 py-1 mx-2">
3 years ago
true - false
3 years ago
</span>
کردن
<span className="bg-blue-400 text-white rounded shadow-sm px-2 py-1 mx-2">
Props
</span>
3 years ago
ها به صورت داینامیک دیزاین های مختلفی را مشاهده کنید شما همچنین
میتوانید با تغییر دادن مقدار <span>PriceDirection</span> به یکی از این
ها:
3 years ago
<br />
3 years ago
<span className="bg-blue-400 text-white rounded shadow-sm px-2 py-1 mx-2">
flex-row/flex-row-reverse/flex-column/flex-column-reverse
</span>
3 years ago
دیزاین های متفاوتی را برای قسمت قیمت و اضافه کردن به سبد خرید هر محصول
ببینید.
3 years ago
</p>
<p className="mt-4 leading-7 ">
برای نمایش ستاره ها من از یک کامپوننت استفاده کردم ====
<span className="bg-blue-400 text-white rounded shadow-sm px-2 py-1 mx-2">
Star Rating
</span>
</p>
</div>
3 years ago
{/* product UI Design */}
3 years ago
<div className="flex flex-wrap sm:flex-nowrap justify-around">
3 years ago
<div className="w-full flex flex-wrap items-center justify-around my-10 px-4">
3 years ago
<div
3 years ago
className={`w-full sm:w-60 md:w-72 mx-1 rounded-lg shadow-sm p-2 my-3 ${productHolderBorder} ${productHolderBorderColor}`}
3 years ago
>
3 years ago
{/* product image */}
<div className="w-full relative">
3 years ago
{/* icons on image */}
3 years ago
<div className="absolute left-2 top-2">
{discountPricePercent && (
3 years ago
<div className="bg-discountPriceBg rounded-md px-2 py-2 mt-2">
3 years ago
<p className="text-discountPriceTitle font-bold text-xs">
23<span>%</span>
</p>
</div>
)}
{likeBtn && (
3 years ago
<div className="bg-likeBtnBg rounded-md py-1 flex justify-center mt-2">
3 years ago
<img src={heart} alt="" className="w-5" />
</div>
)}
{discount && (
3 years ago
<div className="rounded-md mt-2">
3 years ago
<img src={discountImg} alt="" className="w-full" />
</div>
)}
</div>
3 years ago
{/* img */}
3 years ago
<div className="flex-shrink-0">
3 years ago
{verticalImg && (
<img src={book} alt="" className="w-full rounded-lg" />
)}
{horizontalImg && (
<img src={watermelon} alt="" className="w-full rounded-lg" />
)}
3 years ago
</div>
{/* select Color */}
{colors && (
3 years ago
<div className="flex items-center absolute right-2 bottom-2">
3 years ago
<img
src={YellowDotIcon}
alt=""
data-tip="زرد"
3 years ago
className="w-3 h-3 ml-1 cursor-pointer"
3 years ago
/>
<ReactTooltip place="top" type="dark" effect="float" />
<img
src={RedDotIcon}
alt=""
data-tip="قرمز"
3 years ago
className="w-3 h-3 ml-1 cursor-pointer"
3 years ago
/>
<ReactTooltip place="top" type="dark" effect="float" />
<img
src={PurpleDotIcon}
alt=""
data-tip="بنفش"
3 years ago
className="w-3 h-3 ml-1 cursor-pointer"
3 years ago
/>
<ReactTooltip place="top" type="dark" effect="float" />
<img
src={LightBlueDotIcon}
alt=""
data-tip="آبی"
3 years ago
className="w-3 h-3 ml-1 cursor-pointer"
3 years ago
/>
<ReactTooltip place="top" type="dark" effect="float" />
3 years ago
</div>
)}
</div>
3 years ago
{/* product content */}
3 years ago
<div className="px-2">
<div className="mt-4">
<h2
3 years ago
className={`leading-4 text-base ${productTitleColor} ${productTitleAlignment}`}
3 years ago
>
نسخه چاپی علموم تجربه هفتم
</h2>
{productContent && (
3 years ago
<p
className={`text-justify mt-2 text-sm leading-6 ${productExcerptTextColor}`}
>
3 years ago
این کتاب شامل گلدان و گیاه و خاک می باشد و همچنین آپشن های
خوب دیگری نیز دارد.
</p>
)}
{productCat && (
3 years ago
<span className={`text-xs font-light ${productCatTextColor}`}>
3 years ago
پایه سوم
</span>
)}
3 years ago
</div>
3 years ago
{/* star */}
3 years ago
{star && (
<div className="flex items-center mt-2">
<StarRating />
<span className="text-xs text-productContent font-bold mr-2">
39
</span>
</div>
)}
3 years ago
{/* price */}
3 years ago
{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>
3 years ago
{/* price with line on it */}
3 years ago
{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 */}
<button
3 years ago
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 ${
3 years ago
priceDirection.indexOf("col") !== -1 ? "w-full" : ""
3 years ago
}`}
>
3 years ago
اضافه کردن به سبد خرید
</button>
3 years ago
</div>
3 years ago
)}
{productTags && (
<div className="mt-2 flex flex-wrap">
<button className="rounded bg-productTagBg text-productTag m-1 px-4 py-1 text-xs">
ارسال رایگان
</button>
<button className="rounded bg-productTagBg text-productTag m-1 px-4 py-1 text-xs">
برچسب های دیگر
</button>
<button className="rounded bg-productTagBg text-productTag m-1 px-4 py-1 text-xs">
دسته بندی به صورت کادو
</button>
</div>
)}
{rangeHolder && (
<div className="bg-rangeBgColor h-3 w-full rounded mt-2">
3 years ago
<div
className={`bg-rangeFillBgColor h-3 rounded ${rangeWidth}`}
></div>
3 years ago
</div>
)}
3 years ago
</div>
</div>
</div>
</div>
</section>
);
};
export default ProductDesign;
3 years ago
// text colors i used for product title:
// text-darkCrimsonTextColor
// text-productTitle
3 years ago
// text color i used for product excerpt:
// text-productContent
// text color i used for product cat:
// text-darkCrimsonTextColor
ProductDesign.defaultProps = {
3 years ago
// icons on product image
3 years ago
colors: true,
likeBtn: true,
discount: true,
discountPricePercent: true,
3 years ago
// product price
3 years ago
discountPrice: true,
3 years ago
priceHolder: true,
3 years ago
productContent: true,
star: true,
productTags: true,
3 years ago
productCat: true,
3 years ago
rangeHolder: true,
3 years ago
// دو مدل عکس طراحی کردم که یکی عرض بیشتری دارد یکی ارتفاع
3 years ago
verticalImg: true,
horizontalImg: false,
3 years ago
3 years ago
productTitleColor: "text-productTitle",
3 years ago
3 years ago
productExcerptTextColor: "text-productContent",
productCatTextColor: "text-darkCrimsonTextColor",
3 years ago
// برای درصد دادن به عرض رنج
rangeWidth: "w-44",
//دی ای وی که محصول داخلش است میتونیم بهش بوردر بدیم
3 years ago
productHolderBorder: "border",
3 years ago
productHolderBorderColor: "border-grayBorderColor",
3 years ago
3 years ago
productTitleAlignment: "text-justify",
//میتونیم تعیین کنیم که قیمت و دکمه اضاف به سبد خرید کنار یکدیگر باشند یا زیر هم
3 years ago
priceDirection: "flex-row",
};