Spaces:
Running
Running
xcoolcoinx
commited on
Commit
·
bae80b1
1
Parent(s):
cb7772b
Add 3 files
Browse files- app.js +24 -0
- index.html +29 -19
- style.css +56 -18
app.js
ADDED
@@ -0,0 +1,24 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import Alpine from "alpinejs";
|
2 |
+
Alpine.start();
|
3 |
+
const app = new Vue({
|
4 |
+
el: "#app",
|
5 |
+
data: {
|
6 |
+
amount: null,
|
7 |
+
from: null,
|
8 |
+
to: null,
|
9 |
+
},
|
10 |
+
methods: {
|
11 |
+
submit() {
|
12 |
+
const fromCurrency = this.from;
|
13 |
+
const toCurrency = this.to;
|
14 |
+
if(fromCurrency && toCurrency){
|
15 |
+
return(html`<h1>The amount of ${amount} in ${fromCurrency} is ${conversion(amount, fromCurrency, toCurrency)} in ${toCurrency}!</h1>`);
|
16 |
+
} else {
|
17 |
+
return(html`<h1>Please select a currency!</h1>`);
|
18 |
+
}
|
19 |
+
},
|
20 |
+
conversion(amount, fromCurrency, toCurrency){
|
21 |
+
// Conversion logic
|
22 |
+
}
|
23 |
+
},
|
24 |
+
});
|
index.html
CHANGED
@@ -1,19 +1,29 @@
|
|
1 |
-
|
2 |
-
<
|
3 |
-
|
4 |
-
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
</
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<html><head><link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/full.css" rel="stylesheet" type="text/css" /><script defer src="https://cdn.jsdelivr.net/npm/[email protected]/dist/cdn.min.js"></script><script src="https://cdn.tailwindcss.com?plugins=forms,typography,aspect-ratio"></script><script defer src="https://cdnjs.cloudflare.com/ajax/libs/three.js/0.156.1/three.min.js"></script><script type="module" src="main.js"></script><title>Currency Converter</title></head>
|
2 |
+
<body class="bg-cyan-500">
|
3 |
+
<div id="app" class="container max-w-sm mx-auto mt-8">
|
4 |
+
<h1>Currency Converter</h1>
|
5 |
+
<h2>Convert amounts between currencies</h2>
|
6 |
+
<form action="#" method="post" class="bg-white shadow-md rounded px-8 pt-6 pb-8 mb-4">
|
7 |
+
<label class="block text-gray-700 text-sm font-bold mb-2" for="amount">Amount</label>
|
8 |
+
<input type="number" id="amount" class="block w-full border border-gray-300 bg-gray-50 rounded px-3 py-2 text-gray-700 h-10 focus:outline-none focus:border- brand-orange focus:ring-2 focus:ring-brand-orange focus:ring-opacity-50" name="amount" required min="0" step="0.01" value="">
|
9 |
+
<label class="block text-gray-700 text-sm font-bold mt-4 mb-2" for="from">From</label>
|
10 |
+
<select id="from" class="block w-full border border-gray-300 bg-gray-50 rounded px-3 py-2 text-gray-700 h-10 focus:outline-none focus:border-brand-orange focus:ring-2 focus:ring-brand-orange focus:ring-opacity-50" name="from">
|
11 |
+
<option value="USD">United States Dollar (USD)</option>
|
12 |
+
<option value="EUR">Euro (EUR)</option>
|
13 |
+
<option value="GBP">British Pound (GBP)</option>
|
14 |
+
<option value="JPY">Japanese Yen (JPY)</option>
|
15 |
+
<option value="CNY">Chinese Yuan (CNY)</option>
|
16 |
+
</select>
|
17 |
+
<label class="block text-gray-700 text-sm font-bold mt-4 mb-2" for="to">To</label>
|
18 |
+
<select id="to" class="block w-full border border-gray-300 bg-gray-50 rounded px-3 py-2 text-gray-700 h-10 focus:outline-none focus:border-brand-orange focus:ring-2 focus:ring-brand-orange focus:ring-opacity-50" name="to">
|
19 |
+
<option value="USD">United States Dollar (USD)</option>
|
20 |
+
<option value="EUR">Euro (EUR)</option>
|
21 |
+
<option value="GBP">British Pound (GBP)</option>
|
22 |
+
<option value="JPY">Japanese Yen (JPY)</option>
|
23 |
+
<option value="CNY">Chinese Yuan (CNY)</option>
|
24 |
+
</select>
|
25 |
+
<button type="submit" class="btn btn-brand-orange mt-4">Convert</button>
|
26 |
+
</form>
|
27 |
+
</div>
|
28 |
+
</body>
|
29 |
+
</html>
|
style.css
CHANGED
@@ -1,28 +1,66 @@
|
|
|
|
|
|
|
|
|
|
1 |
body {
|
2 |
-
|
3 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
4 |
}
|
5 |
|
6 |
-
|
7 |
-
|
8 |
-
|
|
|
|
|
9 |
}
|
10 |
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
margin-top: 5px;
|
16 |
}
|
17 |
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
border-radius: 16px;
|
24 |
}
|
25 |
|
26 |
-
|
27 |
-
|
|
|
28 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
* {
|
2 |
+
box-sizing: border-box;
|
3 |
+
}
|
4 |
+
|
5 |
body {
|
6 |
+
margin: 0;
|
7 |
+
font-family: Arial, sans-serif;
|
8 |
+
}
|
9 |
+
|
10 |
+
.container {
|
11 |
+
max-width: 75rem;
|
12 |
+
margin: 10rem auto;
|
13 |
+
padding: 2rem;
|
14 |
+
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
|
15 |
+
border-radius: 5px;
|
16 |
+
}
|
17 |
+
|
18 |
+
h1, h2 {
|
19 |
+
text-align: center;
|
20 |
}
|
21 |
|
22 |
+
form {
|
23 |
+
display: grid;
|
24 |
+
grid-template-columns: auto;
|
25 |
+
grid-gap: 1rem;
|
26 |
+
align-items: center;
|
27 |
}
|
28 |
|
29 |
+
label {
|
30 |
+
font-weight: bold;
|
31 |
+
text-align: left;
|
32 |
+
margin-right: 1rem;
|
|
|
33 |
}
|
34 |
|
35 |
+
input, select {
|
36 |
+
padding: 0.5rem;
|
37 |
+
border: 2px solid #ccc;
|
38 |
+
border-radius: 5px;
|
39 |
+
width: 15rem;
|
|
|
40 |
}
|
41 |
|
42 |
+
input:focus, select:focus {
|
43 |
+
border-color: #666;
|
44 |
+
outline: none;
|
45 |
}
|
46 |
+
|
47 |
+
button {
|
48 |
+
background-color: #007bff;
|
49 |
+
color: #fff;
|
50 |
+
border: none;
|
51 |
+
padding: 0.6rem 1.2rem;
|
52 |
+
font-size: 1.05rem;
|
53 |
+
cursor: pointer;
|
54 |
+
border-radius: 5px;
|
55 |
+
margin-top: 1.5rem;
|
56 |
+
}
|
57 |
+
|
58 |
+
button:disabled {
|
59 |
+
background-color: #666;
|
60 |
+
}
|
61 |
+
|
62 |
+
@media (min-width: 768px) {
|
63 |
+
form {
|
64 |
+
grid-template-columns: 1fr 1fr 1fr;
|
65 |
+
}
|
66 |
+
}
|