Skip to content

Commit

Permalink
Create products list
Browse files Browse the repository at this point in the history
  • Loading branch information
KevinVanDerSchans committed Apr 7, 2024
1 parent 9ef6486 commit 8e8e38e
Show file tree
Hide file tree
Showing 3 changed files with 83 additions and 1 deletion.
47 changes: 47 additions & 0 deletions src/components/Products/Products.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
.products {
width: 100%;
display: flex;
justify-content: center;
align-items: center;
}

.products ul {
display: grid;
grid-template-columns: repeat(
auto-fit,
minmax(
200px,
1fr
)
);
gap: 1rem;
}

.products li {
display: flex;
flex-direction: column;
gap: 1rem;
box-shadow: 0 0 10px 10px rgba(0, 0, 0, .1);
border-radius: 4px;
background: #111;
color: #fff;
padding: 1rem;
}

.products h3 {
margin: 0;
}

.products span {
font-size: 1rem;
opacity: .9;
}

.products img {
border-radius: 4px;
width: 100%;
aspect-ratio: 16/9;
display: block;
object-fit: cover;
background: #fff;
}
31 changes: 31 additions & 0 deletions src/components/Products/Products.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
/* eslint-disable react/prop-types */
import './Products.css'
import { AddToCartIcon } from '../Icons/Icons.jsx'

export function Products ({ products }) {
return (
<main className='products'>
<ul>
{products.map(product => (
<li key={product.id}>
<img
src={product.thumbnail}
alt={product.title}
/>

<div>
<strong>{product.title}</strong> - {product.price}
</div>

<div>
<button>
<AddToCartIcon />
</button>
</div>
</li>
))}
</ul>

</main>
)
}
6 changes: 5 additions & 1 deletion src/components/app/App.jsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
import { products } from '../../mocks/products.json'
import { Products } from '../Products/Products'
import './App.css'

function App() {

return (
<>
<div>
<span>Shopping cart</span>
<h1>Shopping cart</h1>
<Products products={products}/>

</div>
</>
)
Expand Down

0 comments on commit 8e8e38e

Please sign in to comment.