File tree Expand file tree Collapse file tree 4 files changed +88
-32
lines changed
2-desenvolvimento-front-end/DR2-fundamentos-de-react/DR2-TP3.00-produtos-crud/src/components Expand file tree Collapse file tree 4 files changed +88
-32
lines changed Original file line number Diff line number Diff line change 1- import Product from '../product' ;
21import './styles.css' ;
32
43export default function ProductList ( { products, handleEdit, handleDelete } ) {
54 return (
6- < div className = "product-list" >
7- { products . map ( ( product , index ) => (
8- < Product key = { index } { ...product } index = { index } handleDelete = { handleDelete } handleEdit = { handleEdit } />
9- ) ) }
10- </ div >
5+ < table className = "product-list" >
6+ < thead >
7+ < tr >
8+ < th > Nome</ th >
9+ < th > Categoria</ th >
10+ < th > Preço</ th >
11+ < th > </ th >
12+ </ tr >
13+ </ thead >
14+ < tbody >
15+ { products . map ( ( product , index ) => (
16+ < tr key = { index } >
17+ < td > { product . name } </ td >
18+ < td > { product . category } </ td >
19+ < td > R$ { product . price && ! isNaN ( product . price ) ? Number ( product . price ) . toFixed ( 2 ) : product . price } </ td >
20+ < td >
21+ < button onClick = { ( ) => handleEdit ( index ) } style = { { marginRight : '8px' } } > Editar</ button >
22+ < button onClick = { ( ) => handleDelete ( index ) } > Excluir</ button >
23+ </ td >
24+ </ tr >
25+ ) ) }
26+ </ tbody >
27+ </ table >
1128 )
1229}
Original file line number Diff line number Diff line change 11.product-list {
2- max-width : 800px ;
3- margin : 0 auto;
4- padding : 20px ;
5- }
2+ width : 100% ;
3+ background-color : white;
4+ border-radius : 12px ;
5+ box-shadow : 0 2px 8px rgba (0 , 0 , 0 , 0.1 );
6+ border-collapse : separate;
7+ border-spacing : 0 ;
8+ overflow : hidden;
9+ }
10+
11+ .product-list thead {
12+ background-color : # f5f5f5 ;
13+ }
14+
15+ .product-list th {
16+ padding : 1rem ;
17+ text-align : left;
18+ font-weight : 600 ;
19+ color : # 333 ;
20+ border-bottom : 2px solid # e0e0e0 ;
21+ }
22+
23+ .product-list tbody tr {
24+ border-bottom : 1px solid # e0e0e0 ;
25+ transition : background-color 0.2s ;
26+ }
27+
28+ .product-list tbody tr : hover {
29+ background-color : # f9f9f9 ;
30+ }
31+
32+ .product-list tbody tr : last-child {
33+ border-bottom : none;
34+ }
35+
36+ .product-list td {
37+ padding : 1rem ;
38+ color : # 333 ;
39+ }
40+
41+ .product-list td : last-child {
42+ white-space : nowrap;
43+ }
44+
45+ .product-list button {
46+ padding : 0.5rem 1rem ;
47+ border : none;
48+ border-radius : 6px ;
49+ cursor : pointer;
50+ font-size : 14px ;
51+ transition : opacity 0.2s ;
52+ }
53+
54+ .product-list button : hover {
55+ opacity : 0.8 ;
56+ }
57+
58+ .product-list button : first-child {
59+ background-color : # 4CAF50 ;
60+ color : white;
61+ }
62+
63+ .product-list button : last-child {
64+ background-color : # f44336 ;
65+ color : white;
66+ }
Load Diff This file was deleted.
Load Diff This file was deleted.
You can’t perform that action at this time.
0 commit comments