Skip to content

Commit 53fd40f

Browse files
committed
2-DR2-AT.10
1 parent f463f42 commit 53fd40f

File tree

2 files changed

+76
-27
lines changed
  • 2-desenvolvimento-front-end/DR2-fundamentos-de-react/DR2-AT-ecommerce-dummy-crud/src/pages/product-list

2 files changed

+76
-27
lines changed

2-desenvolvimento-front-end/DR2-fundamentos-de-react/DR2-AT-ecommerce-dummy-crud/src/pages/product-list/index.jsx

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
import { useState, useEffect } from 'react';
2-
import { Link } from 'react-router-dom';
2+
import { Link, useNavigate } from 'react-router-dom';
33
import axios from 'axios';
44
import style from './style.module.css';
55

66
export default function ProductList() {
77
const [produtos, setProdutos] = useState([]);
88
const [carregando, setCarregando] = useState(true);
9+
const navigate = useNavigate();
910

1011
useEffect(() => {
1112
const buscaProdutos = async () => {
@@ -30,10 +31,18 @@ export default function ProductList() {
3031
{ produtos.map((produto) => (
3132
<div key={produto.id} className={style.produto}>
3233
<img src={produto.thumbnail} alt={produto.title} className={style.thumbnail} />
33-
<h3>
34-
<Link to={`/produtos/${produto.id}`}>{produto.title}</Link>
35-
</h3>
36-
<p className={style.preco}>Preço: R$ {produto.price.toString().replace(".", ",")}</p>
34+
<div className={style.conteudo}>
35+
<h3>
36+
<Link to={`/produtos/${produto.id}`}>{produto.title}</Link>
37+
</h3>
38+
<p className={style.preco}>Preço: R$ {produto.price.toString().replace(".", ",")}</p>
39+
</div>
40+
<button
41+
className={style.botaoEditar}
42+
onClick={() => navigate(`/novo/${produto.id}`)}
43+
>
44+
Editar
45+
</button>
3746
</div>
3847
))
3948
}
Lines changed: 62 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
.lista {
2-
display: grid;
3-
grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
4-
gap: 20px;
2+
display: flex;
3+
flex-direction: column;
4+
gap: 16px;
55
padding: 20px;
6+
max-width: 1200px;
7+
margin: 0 auto;
68
}
79

810
.produto {
@@ -12,37 +14,75 @@
1214
padding: 16px;
1315
transition: transform 0.2s, box-shadow 0.2s;
1416
display: flex;
15-
flex-direction: column;
16-
gap: 8px;
17+
flex-direction: row;
18+
gap: 16px;
19+
align-items: center;
20+
}
21+
22+
.produto:hover {
23+
transform: translateY(-2px);
24+
box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
1725
}
1826

1927
.thumbnail {
20-
width: 100%;
21-
height: 200px;
28+
width: 120px;
29+
height: 120px;
2230
object-fit: cover;
2331
border-radius: 4px;
24-
margin-bottom: 12px;
32+
flex-shrink: 0;
2533
}
2634

27-
.produto {
28-
h3 {
29-
font-size: 1.2rem;
30-
color: #333;
31-
}
35+
.conteudo {
36+
flex: 1;
37+
display: flex;
38+
flex-direction: column;
39+
gap: 8px;
40+
}
3241

33-
p {
34-
font-size: 1rem;
35-
}
42+
.produto h3 {
43+
font-size: 1.2rem;
44+
color: #333;
45+
margin: 0;
46+
}
47+
48+
.produto h3 a {
49+
color: #333;
50+
text-decoration: none;
51+
transition: color 0.2s;
52+
}
53+
54+
.produto h3 a:hover {
55+
color: #2c5f2d;
56+
}
57+
58+
.produto p {
59+
font-size: 1rem;
60+
margin: 0;
61+
}
62+
63+
.preco {
64+
font-weight: bold;
65+
font-size: 1rem;
66+
color: #2c5f2d;
67+
}
68+
69+
.botaoEditar {
70+
background-color: #2c5f2d;
71+
color: white;
72+
border: none;
73+
border-radius: 4px;
74+
padding: 10px 20px;
75+
font-size: 1rem;
76+
cursor: pointer;
77+
transition: background-color 0.2s;
78+
flex-shrink: 0;
79+
}
3680

37-
.preco {
38-
font-weight: bold;
39-
font-size: 0.9rem;
40-
margin-top: auto;
41-
}
81+
.botaoEditar:hover {
82+
background-color: #1f4520;
4283
}
4384

4485
.carregando {
45-
grid-column: 1 / -1;
4686
text-align: center;
4787
padding: 20px;
4888
}

0 commit comments

Comments
 (0)