ACTIVITY : AMAZON CARDS

 A GROUP OF ITEMS IS DISPLAYED, WHICH INCLUDES TITLE,DESCRIPTION AND PRICE(OLD AND NEW)

HERE FOR DISPLAYING THE PRICE AND DESCRIPTION WE USE ARRAYS.

SO THAT FOR EACH PARTICULAR ITEM THEIR CORRESPONDING PRICE AND DESCRIPTION CAN BE DISPLAYED USING THEIR INDEX.

TO  DISPLAY DESCRIPTION , WE USE 2D ARRAYS. AS IT INCLUDES MULTIPLE CONTENTS.

PRICE IS TAKEN AS A SEPERATE COMPONENT AS IT CONTAINS TWO FIELDS.(OLD AND NEW)



PRICE.JSX

export default function Price({oldPrice,newPrice}){
    let oldStyles ={textDecorationLine:"line-through"}
    let newStyles={ fontWeight :"bold"}
    let styles={
        backgroundColor:"#e0c367",
        height:"30px",
        borderBottomLeftRadius:"15px",
        borderBottomRightRadius:"15px",
        color:"black"

    }
    return (
        <div style={styles}>
       <span style={oldStyles}>{oldPrice}</span>
       &nbsp; &nbsp; &nbsp;
       <span style={newStyles}>{newPrice}</span>
</div>
    )
}

PRODUCT.JSX

import "./Product.css";
import Price from "./price";
function Product({ title, idx }) {
  let oldPrices = ["12,495", "11,900", "1,599", "599"];
  let newPrices = ["8,999", "9,199", "899", "278"];
  let description = [
    ["8,000 DPI", "5 programmable buttons"],
    ["intuitive surface", "designed for iPad Pro"],
    ["designed for iPad Pro", "inituitive surface"],
    ["wireless", "optical orientation"],
  ];

  return (
    <div className="Product">
      <h5>{title}</h5>
      <p>{description[idx][0]}</p>
      <p>{description[idx][1]}</p>

      <Price oldPrice={oldPrices[idx]} newPrice={newPrices[idx]} />
    </div>
  );
}
export default Product;



PRODUCTTAB.JSX

import Product from "./Product";

function ProductTab() {
  let styles = {
    display: "flex",
    flexWrap: "wrap",
    justifyContent: "center",
    alignItems: "center",
  };
  return (
    <div style={styles}>
      <Product title="Logictech Mx Master" idx={0} />
      <Product title="Apple Pencil (2nd Gen)" idx={1} />
      <Product title="Zebronics Zeb-transformer" idx={2} />
      <Product title="Petronics Toad 23" idx={3} />
    </div>
  );
}
export default ProductTab;

APP.JSX

import ProductTab from "./ProductTab.jsx";
function App() {
  return (
    <>
      <ProductTab />
     
    </>
  );
}

export default App;

PRODUCT.CSS

.Product{
    border: 2px solid white !important;
    border-radius: 15px;
    margin-top: 15px;
    /* padding: 0 10px 0 10px; */
    margin-left: 35px;
    width: 200px;
    height: 174px;
}

Comments

Popular posts from this blog

DEPENDENCIES IN useEffect()

ACTIVITY1

CONDITIONALS