Repository navigation
Expand file tree
/
Copy pathcotacao.html
More file actions
175 lines (152 loc) · 5.27 KB
/
Copy pathcotacao.html
File metadata and controls
175 lines (152 loc) · 5.27 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
<!DOCTYPE html>
<html lang="pt-BR">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Cotação do Dólar | Tempo Real</title>
<meta name="description" content="Acompanhe a cotação do dólar em tempo real.">
<link href="https://fonts.googleapis.com/css2?family=Outfit:wght@300;500;700&display=swap" rel="stylesheet">
<style>
:root {
--bg: #09090b;
--surface: #18181b;
--primary: #10b981; /* Emerald */
--text-main: #f4f4f5;
--text-muted: #a1a1aa;
}
body {
font-family: 'Outfit', sans-serif;
background-color: var(--bg);
color: var(--text-main);
margin: 0;
min-height: 100vh;
display: flex;
justify-content: center;
align-items: center;
background-image: radial-gradient(circle at top, rgba(16, 185, 129, 0.15), transparent 40%);
}
.dashboard {
background: rgba(24, 24, 27, 0.6);
backdrop-filter: blur(16px);
border: 1px solid rgba(255, 255, 255, 0.05);
border-radius: 24px;
padding: 3rem;
text-align: center;
box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
width: 90%;
max-width: 400px;
position: relative;
overflow: hidden;
}
.dashboard::before {
content: '';
position: absolute;
top: 0; left: 0; right: 0; height: 4px;
background: linear-gradient(90deg, #34d399, #059669);
}
h1 {
font-size: 1.25rem;
font-weight: 500;
color: var(--text-muted);
margin-bottom: 0.5rem;
text-transform: uppercase;
letter-spacing: 2px;
}
.currency-pair {
font-size: 0.9rem;
color: var(--primary);
font-weight: 700;
background: rgba(16, 185, 129, 0.1);
padding: 4px 12px;
border-radius: 999px;
display: inline-block;
margin-bottom: 2rem;
}
#cotacao-display {
font-size: 3.5rem;
font-weight: 700;
margin-bottom: 0.5rem;
text-shadow: 0 0 20px rgba(16, 185, 129, 0.4);
transition: transform 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
min-height: 80px;
display: flex;
align-items: center;
justify-content: center;
}
.updating {
transform: scale(1.05);
color: #34d399;
}
.info-card {
background: rgba(0,0,0,0.2);
border-radius: 12px;
padding: 1rem;
margin-top: 2rem;
}
.info-card p {
margin: 0.25rem 0;
font-size: 0.85rem;
color: var(--text-muted);
}
#ultima-atualizacao {
color: var(--text-main);
font-weight: 500;
}
.loader {
display: inline-block;
width: 2rem;
height: 2rem;
border: 3px solid rgba(255,255,255,0.1);
border-radius: 50%;
border-top-color: var(--primary);
animation: spin 1s ease-in-out infinite;
}
@keyframes spin {
to { transform: rotate(360deg); }
}
</style>
</head>
<body>
<main class="dashboard">
<h1>Cotação do Dólar</h1>
<div class="currency-pair">USD / BRL</div>
<div id="cotacao-display">
<div class="loader"></div>
</div>
<div class="info-card">
<p>Valor comercial de <strong>venda</strong></p>
<p>Atualizado às: <span id="ultima-atualizacao">...</span></p>
<p style="font-size: 0.75rem; margin-top: 10px; opacity: 0.7;">Próxima atualização em 60s</p>
</div>
</main>
<script>
const API_URL = 'https://economia.awesomeapi.com.br/json/last/USD-BRL';
const display = document.getElementById('cotacao-display');
const updatedDisplay = document.getElementById('ultima-atualizacao');
async function atualizarCotacao() {
try {
const response = await fetch(API_URL);
const data = await response.json();
const valorVenda = parseFloat(data.USDBRL.bid);
const cotacaoFormatada = valorVenda.toLocaleString('pt-BR', {
style: 'currency',
currency: 'BRL'
});
display.classList.add('updating');
display.innerText = cotacaoFormatada;
setTimeout(() => {
display.classList.remove('updating');
}, 300);
updatedDisplay.innerText = new Date().toLocaleTimeString('pt-BR');
} catch (error) {
console.error('Erro:', error);
display.innerText = 'Erro';
display.style.fontSize = '2rem';
display.style.color = '#ef4444';
}
}
atualizarCotacao();
setInterval(atualizarCotacao, 60000);
</script>
</body>
</html>