-
Notifications
You must be signed in to change notification settings - Fork 95
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
#383 [Cite any related issue(s) this pull request addresses. If none, simply state "None”] write issue no. here ## Description [Please include a brief description of the changes or features added] ## Type of PR - [ x] Feature enhancement check in issue by entering [X] in boxes ## Screenshots / Videos (if applicable) ![Screenshot 2025-01-08 160404](https://github.com/user-attachments/assets/24f43481-b796-4f4e-9de3-9ba712c3ef06) [Attach any relevant screenshots or videos demonstrating the changes] ## Checklist - [ x] I have performed a self-review of my code. - [ x] I have read and followed the Contribution Guidelines. - [ x] I have tested the changes thoroughly before submitting this pull request. - [ x] I have provided relevant issue numbers, screenshots, and videos after making the changes. - [ x] I have commented my code, particularly in hard-to-understand areas. - [ x] I have followed the code style guidelines of this project. - [ x] I have checked for any existing open issues that my pull request may address. - [ x] I have ensured that my changes do not break any existing functionality. - [ x] Each contributor is allowed to create a maximum of 4 issues per day. This helps us manage and address issues efficiently. - [ x] I have read the resources for guidance listed below. - [ x] I have followed security best practices in my code changes. check in issue by entering [X] in boxes ## Additional Context [Include any additional information or context that might be helpful for reviewers.] ## Contribution Guidelines Thank you for considering contributing to our project! To ensure smooth collaboration and effective contribution management, please adhere to the following guidelines: ### Issue Creation 1. **Limit on Issues:** - Each contributor is allowed to create a maximum of **4 issues per day**. This helps us manage and address issues efficiently. ### Contribution Levels 2. **Basic Contributions:** - This project is primarily focused on documentation. Most of the setup has been completed, so contributors will generally need to work on basic code tasks, such as writing tests. - For these tasks, issues will be assigned the **Easy** label. 3. **Acknowledging Hard Work:** - If a contributor puts in significant effort on a task, the issue will be upgraded to **Medium**. This is our way of recognizing and appreciating extra effort. 4. **Feature Additions and Component Work:** - Contributors working on new features or components using JSX/TSX will be assigned a level based on the complexity and quality of their work. - The more complex and valuable the contribution, the higher the level assigned. ### Level Definitions - **Easy:** - Tasks are straightforward, such as fixing minor bugs, writing tests, or making simple documentation updates. - **Medium:** - Tasks require more effort, such as addressing complex bugs, improving existing features, or making substantial documentation improvements. - **Hard:** - Tasks are highly complex and involve significant new feature development, major refactoring, or extensive contributions to the project’s core components. We look forward to your contributions and appreciate your effort in helping us improve the project!
- Loading branch information
Showing
6 changed files
with
355 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
const BASE_URL = | ||
"https://cdn.jsdelivr.net/gh/fawazahmed0/currency-api@1/latest/currencies"; | ||
|
||
const dropdowns = document.querySelectorAll(".dropdown select"); | ||
const btn = document.querySelector("form button"); | ||
const fromCurr = document.querySelector(".from select"); | ||
const toCurr = document.querySelector(".to select"); | ||
const msg = document.querySelector(".msg"); | ||
|
||
for (let select of dropdowns) { | ||
for (currCode in countryList) { | ||
let newOption = document.createElement("option"); | ||
newOption.innerText = currCode; | ||
newOption.value = currCode; | ||
if (select.name === "from" && currCode === "USD") { | ||
newOption.selected = "selected"; | ||
} else if (select.name === "to" && currCode === "INR") { | ||
newOption.selected = "selected"; | ||
} | ||
select.append(newOption); | ||
} | ||
|
||
select.addEventListener("change", (evt) => { | ||
updateFlag(evt.target); | ||
}); | ||
} | ||
|
||
const updateExchangeRate = async () => { | ||
let amount = document.querySelector(".amount input"); | ||
let amtVal = amount.value; | ||
if (amtVal === "" || amtVal < 1) { | ||
amtVal = 1; | ||
amount.value = "1"; | ||
} | ||
const URL = `${BASE_URL}/${fromCurr.value.toLowerCase()}/${toCurr.value.toLowerCase()}.json`; | ||
let response = await fetch(URL); | ||
let data = await response.json(); | ||
let rate = data[toCurr.value.toLowerCase()]; | ||
|
||
let finalAmount = amtVal * rate; | ||
msg.innerText = `${amtVal} ${fromCurr.value} = ${finalAmount} ${toCurr.value}`; | ||
}; | ||
|
||
const updateFlag = (element) => { | ||
let currCode = element.value; | ||
let countryCode = countryList[currCode]; | ||
let newSrc = `https://flagsapi.com/${countryCode}/flat/64.png`; | ||
let img = element.parentElement.querySelector("img"); | ||
img.src = newSrc; | ||
}; | ||
|
||
btn.addEventListener("click", (evt) => { | ||
evt.preventDefault(); | ||
updateExchangeRate(); | ||
}); | ||
|
||
window.addEventListener("load", () => { | ||
updateExchangeRate(); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,161 @@ | ||
const countryList = { | ||
AED: "AE", | ||
AFN: "AF", | ||
XCD: "AG", | ||
ALL: "AL", | ||
AMD: "AM", | ||
ANG: "AN", | ||
AOA: "AO", | ||
AQD: "AQ", | ||
ARS: "AR", | ||
AUD: "AU", | ||
AZN: "AZ", | ||
BAM: "BA", | ||
BBD: "BB", | ||
BDT: "BD", | ||
XOF: "BE", | ||
BGN: "BG", | ||
BHD: "BH", | ||
BIF: "BI", | ||
BMD: "BM", | ||
BND: "BN", | ||
BOB: "BO", | ||
BRL: "BR", | ||
BSD: "BS", | ||
NOK: "BV", | ||
BWP: "BW", | ||
BYR: "BY", | ||
BZD: "BZ", | ||
CAD: "CA", | ||
CDF: "CD", | ||
XAF: "CF", | ||
CHF: "CH", | ||
CLP: "CL", | ||
CNY: "CN", | ||
COP: "CO", | ||
CRC: "CR", | ||
CUP: "CU", | ||
CVE: "CV", | ||
CYP: "CY", | ||
CZK: "CZ", | ||
DJF: "DJ", | ||
DKK: "DK", | ||
DOP: "DO", | ||
DZD: "DZ", | ||
ECS: "EC", | ||
EEK: "EE", | ||
EGP: "EG", | ||
ETB: "ET", | ||
EUR: "FR", | ||
FJD: "FJ", | ||
FKP: "FK", | ||
GBP: "GB", | ||
GEL: "GE", | ||
GGP: "GG", | ||
GHS: "GH", | ||
GIP: "GI", | ||
GMD: "GM", | ||
GNF: "GN", | ||
GTQ: "GT", | ||
GYD: "GY", | ||
HKD: "HK", | ||
HNL: "HN", | ||
HRK: "HR", | ||
HTG: "HT", | ||
HUF: "HU", | ||
IDR: "ID", | ||
ILS: "IL", | ||
INR: "IN", | ||
IQD: "IQ", | ||
IRR: "IR", | ||
ISK: "IS", | ||
JMD: "JM", | ||
JOD: "JO", | ||
JPY: "JP", | ||
KES: "KE", | ||
KGS: "KG", | ||
KHR: "KH", | ||
KMF: "KM", | ||
KPW: "KP", | ||
KRW: "KR", | ||
KWD: "KW", | ||
KYD: "KY", | ||
KZT: "KZ", | ||
LAK: "LA", | ||
LBP: "LB", | ||
LKR: "LK", | ||
LRD: "LR", | ||
LSL: "LS", | ||
LTL: "LT", | ||
LVL: "LV", | ||
LYD: "LY", | ||
MAD: "MA", | ||
MDL: "MD", | ||
MGA: "MG", | ||
MKD: "MK", | ||
MMK: "MM", | ||
MNT: "MN", | ||
MOP: "MO", | ||
MRO: "MR", | ||
MTL: "MT", | ||
MUR: "MU", | ||
MVR: "MV", | ||
MWK: "MW", | ||
MXN: "MX", | ||
MYR: "MY", | ||
MZN: "MZ", | ||
NAD: "NA", | ||
XPF: "NC", | ||
NGN: "NG", | ||
NIO: "NI", | ||
NPR: "NP", | ||
NZD: "NZ", | ||
OMR: "OM", | ||
PAB: "PA", | ||
PEN: "PE", | ||
PGK: "PG", | ||
PHP: "PH", | ||
PKR: "PK", | ||
PLN: "PL", | ||
PYG: "PY", | ||
QAR: "QA", | ||
RON: "RO", | ||
RSD: "RS", | ||
RUB: "RU", | ||
RWF: "RW", | ||
SAR: "SA", | ||
SBD: "SB", | ||
SCR: "SC", | ||
SDG: "SD", | ||
SEK: "SE", | ||
SGD: "SG", | ||
SKK: "SK", | ||
SLL: "SL", | ||
SOS: "SO", | ||
SRD: "SR", | ||
STD: "ST", | ||
SVC: "SV", | ||
SYP: "SY", | ||
SZL: "SZ", | ||
THB: "TH", | ||
TJS: "TJ", | ||
TMT: "TM", | ||
TND: "TN", | ||
TOP: "TO", | ||
TRY: "TR", | ||
TTD: "TT", | ||
TWD: "TW", | ||
TZS: "TZ", | ||
UAH: "UA", | ||
UGX: "UG", | ||
USD: "US", | ||
UYU: "UY", | ||
UZS: "UZ", | ||
VEF: "VE", | ||
VND: "VN", | ||
VUV: "VU", | ||
YER: "YE", | ||
ZAR: "ZA", | ||
ZMK: "ZM", | ||
ZWD: "ZW", | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8" /> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0" /> | ||
<title>Currency Converter</title> | ||
<link href="style.css" rel="stylesheet" /> | ||
<link | ||
rel="stylesheet" | ||
href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.5.1/css/all.min.css" | ||
integrity="sha512-DTOQO9RWCH3ppGqcWaEA1BIZOC6xxalwEsw9c2QQeAIftl+Vegovlnee1c9QX4TctnWMn13TZye+giMm8e2LwA==" | ||
crossorigin="anonymous" | ||
referrerpolicy="no-referrer" | ||
/> | ||
|
||
</head> | ||
<body> | ||
<div class="container"> | ||
<h2>Currency Converter</h2> | ||
<form> | ||
<div class="amount"> | ||
<p>Enter Amount</p> | ||
<input value="1" type="text" /> | ||
</div> | ||
<div class="dropdown"> | ||
<div class="from"> | ||
<p>From</p> | ||
<div class="select-container"> | ||
<img src="https://flagsapi.com/US/flat/64.png" /> | ||
<select name="from"></select> | ||
</div> | ||
</div> | ||
<i class="fa-solid fa-arrow-right-arrow-left"></i> | ||
<div class="to"> | ||
<p>To</p> | ||
<div class="select-container"> | ||
<img src="https://flagsapi.com/IN/flat/64.png" /> | ||
<select name="to"></select> | ||
</div> | ||
</div> | ||
</div> | ||
<div class="msg">1USD = 80INR</div> | ||
<button>Get Exchange Rate</button> | ||
</form> | ||
</div> | ||
<script src="data.js"></script> | ||
<script src="app.js"></script> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
* { | ||
margin: 0; | ||
padding: 0; | ||
} | ||
|
||
body { | ||
display: flex; | ||
justify-content: center; | ||
align-items: center; | ||
min-height: 100vh; | ||
background-color: #f4e4ba; | ||
} | ||
|
||
.container { | ||
background-color: #fff; | ||
padding: 2rem; | ||
border-radius: 1rem; | ||
min-height: 45vh; | ||
width: 40vh; | ||
} | ||
|
||
form { | ||
margin: 2rem 0 1rem 0; | ||
} | ||
|
||
form select, | ||
button, | ||
input { | ||
width: 100%; | ||
border: none; | ||
outline: none; | ||
border-radius: 0.75rem; | ||
} | ||
|
||
form input { | ||
border: 1px solid lightgray; | ||
font-size: 1rem; | ||
height: 3rem; | ||
padding-left: 0.5rem; | ||
} | ||
|
||
.dropdown { | ||
display: flex; | ||
justify-content: space-between; | ||
align-items: center; | ||
margin-top: 2rem; | ||
} | ||
|
||
.dropdown i { | ||
font-size: 1.5rem; | ||
margin-top: 1rem; | ||
} | ||
|
||
.select-container img { | ||
max-width: 2rem; | ||
} | ||
|
||
.select-container { | ||
display: flex; | ||
justify-content: center; | ||
align-items: center; | ||
width: 6rem; | ||
border-radius: 0.5rem; | ||
border: 1px solid lightgray; | ||
} | ||
|
||
.select-container select { | ||
font-size: 1rem; | ||
width: auto; | ||
} | ||
|
||
.msg { | ||
margin: 2rem 0 2rem 0; | ||
} | ||
|
||
form button { | ||
height: 3rem; | ||
background-color: #af4d98; | ||
color: #fff; | ||
font-size: 1.15rem; | ||
cursor: pointer; | ||
} |