File tree Expand file tree Collapse file tree 4 files changed +58
-8
lines changed
2-desenvolvimento-front-end/DR2-fundamentos-de-react/DR2-TP2.00-biblioteca-crud/src Expand file tree Collapse file tree 4 files changed +58
-8
lines changed Original file line number Diff line number Diff line change @@ -10,6 +10,42 @@ body {
1010 font-family : system-ui, -apple-system, sans-serif;
1111}
1212
13+ .mensagem {
14+ position : fixed;
15+ bottom : 24px ;
16+ left : 50% ;
17+ transform : translateX (-50% );
18+ padding : 16px 24px ;
19+ border-radius : 6px ;
20+ max-width : 600px ;
21+ text-align : center;
22+ font-weight : 500 ;
23+ animation : slideUp 0.3s ease;
24+ z-index : 1000 ;
25+ box-shadow : 0 4px 12px rgba (0 , 0 , 0 , 0.3 );
26+ }
27+
28+ .mensagem-success {
29+ background-color : # 4a9c32 ;
30+ color : white;
31+ }
32+
33+ .mensagem-info {
34+ background-color : # 3a7ad6 ;
35+ color : white;
36+ }
37+
38+ @keyframes slideUp {
39+ from {
40+ opacity : 0 ;
41+ transform : translate (-50% , 20px );
42+ }
43+ to {
44+ opacity : 1 ;
45+ transform : translate (-50% , 0 );
46+ }
47+ }
48+
1349main {
1450 padding-block : 32px ;
1551
Original file line number Diff line number Diff line change @@ -12,13 +12,21 @@ function App() {
1212 ] ) ;
1313
1414 const [ livroEditando , setLivroEditando ] = useState ( null ) ;
15+ const [ mensagem , setMensagem ] = useState ( null ) ;
16+
17+ const mostrarMensagem = ( texto , tipo = 'success' ) => {
18+ setMensagem ( { texto, tipo } ) ;
19+ setTimeout ( ( ) => setMensagem ( null ) , 3000 ) ;
20+ } ;
1521
1622 const adicionarLivro = ( novoLivro ) => {
1723 setLivros ( [ ...livros , novoLivro ] ) ;
24+ mostrarMensagem ( 'Livro adicionado com sucesso' ) ;
1825 } ;
1926
2027 const removerLivro = ( index ) => {
2128 setLivros ( livros . filter ( ( _ , i ) => i !== index ) ) ;
29+ mostrarMensagem ( 'Livro removido' , 'info' ) ;
2230 } ;
2331
2432 const editarLivro = ( index ) => {
@@ -30,11 +38,17 @@ function App() {
3038 i === livroEditando . index ? livroAtualizado : livro
3139 ) ) ;
3240 setLivroEditando ( null ) ;
41+ mostrarMensagem ( 'Livro atualizado' ) ;
3342 } ;
3443
3544 return (
3645 < >
3746 < Header />
47+ { mensagem && (
48+ < div className = { `mensagem mensagem-${ mensagem . tipo } ` } >
49+ { mensagem . texto }
50+ </ div >
51+ ) }
3852 < main >
3953 < BookForm
4054 onAddBook = { adicionarLivro }
Original file line number Diff line number Diff line change 1818 }
1919
2020 button {
21- background-color : # 5a7a4a ;
21+ background-color : # 4a9c32 ;
2222 color : # f8f4f0 ;
2323 border : none;
2424 padding : 12px 24px ;
2929 flex : 1 ;
3030
3131 & : hover {
32- background-color : # 6b8f5a ;
32+ background-color : # 5bb844 ;
3333 }
3434 }
3535
3636 .btn-cancelar {
37- background-color : # 6b6b6b ;
37+ background-color : # 888888 ;
3838
3939 & : hover {
40- background-color : # 7a7a7a ;
40+ background-color : # 9a9a9a ;
4141 }
4242 }
4343}
Original file line number Diff line number Diff line change @@ -54,7 +54,7 @@ table {
5454}
5555
5656.btn-excluir {
57- background-color : # a84848 ;
57+ background-color : # d63838 ;
5858 color : # f8f4f0 ;
5959 border : none;
6060 padding : 8px 16px ;
@@ -64,12 +64,12 @@ table {
6464 font-weight : 500 ;
6565
6666 & : hover {
67- background-color : # c05555 ;
67+ background-color : # e84545 ;
6868 }
6969}
7070
7171.btn-editar {
72- background-color : # 4a6aa8 ;
72+ background-color : # 3a7ad6 ;
7373 color : # f8f4f0 ;
7474 border : none;
7575 padding : 8px 16px ;
@@ -80,6 +80,6 @@ table {
8080 margin-right : 8px ;
8181
8282 & : hover {
83- background-color : # 5580c0 ;
83+ background-color : # 4a8ee8 ;
8484 }
8585}
You can’t perform that action at this time.
0 commit comments