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

Completed assignment-1 #54

Open
wants to merge 1 commit 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
@@ -1,4 +1,6 @@
/* eslint-disable prettier/prettier */
import React from 'react';
import './index.css';

import Products from './components/Products';

Expand Down Expand Up @@ -87,7 +89,7 @@ const App = () => {
return (
<div>
<h1 className="title">BD Store</h1>
<Products />
<Products products={products} />
</div>
);
};
Expand Down
18 changes: 10 additions & 8 deletions src/components/Product.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
/* eslint-disable prettier/prettier */
/* eslint-disable react/prop-types */
import React from 'react';

const Product = () => {
import '../index.css';
const Product = (props) => {
const { title, price, description, image, rating } = props.product;
return (
<article className="product">
<img src="" alt="" />
<article className="product">
<img src={image} alt="" />
<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}</p>
<button className="product__btn btn">Add to cart</button>
</div>
</article>
Expand Down
16 changes: 16 additions & 0 deletions src/components/Products.js
Original file line number Diff line number Diff line change
@@ -1 +1,17 @@
/* eslint-disable prettier/prettier */
/* eslint-disable react/prop-types */
import React from 'react';
import '../index.css';
import Product from './Product';

const Products = (props) => {
return (
<div className="products">
{props.products.map((product, index) => (
<Product key={index} product={product} />
))}
</div>
);
};

export default Products;
2 changes: 2 additions & 0 deletions src/index.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
/* eslint-disable prettier/prettier */
import React from 'react';
import ReactDOM from 'react-dom/client';
import App from './App';

import './index.css';

// @ts-ignore
const root = ReactDOM.createRoot(document.getElementById('root'));

root.render(<App />);