Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

create, style product component & mapping products data #58

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion src/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,10 +84,12 @@ const products = [
];

const App = () => {

return (
<div>
<h1 className="title">BD Store</h1>
<Products />
<Products products={products} />

</div>
);
};
Expand Down
13 changes: 7 additions & 6 deletions src/components/Product.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
/* eslint-disable react/prop-types */
import React from 'react';

const Product = () => {
const Product = (props) => {
const {image,title,price,rating,description} = props.product;
return (
<article className="product">
<img src="" alt="" />
<img src={image} alt={title} />
<div className="product__details">
<h4 className="product__title">product title</h4>
<p>Price: $ product price</p>
<p>Rating: product rating rate/5</p>
<p className="product__desc">Description: product.description</p>
<h4 className="product__title">{title}</h4>
<p className='product__price'>Price: ${price}</p>
<p className='product__rating'>Rating: {rating['rate']}/5</p>
<p className="product__desc">Description: {description}</p>
<button className="product__btn btn">Add to cart</button>
</div>
</article>
Expand Down
15 changes: 15 additions & 0 deletions src/components/Products.js
Original file line number Diff line number Diff line change
@@ -1 +1,16 @@
/* eslint-disable react/prop-types */
import React from 'react';
import Product from './Product';

const Products = (props) => {
const {products} = props;
const product = products.map(product =>
<Product key={product.id} product={product} />)
return (
<section className='products'>
{product}
</section>
);
};

export default Products;