Update getFlag function to accept size parameter
This commit is contained in:
@@ -34,8 +34,14 @@ export function countryCodeToName(countryCode: string) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export function getFlag(country: string) {
|
/**
|
||||||
return `https://flagcdn.com/h24/${country}.png`;
|
* Generates the URL for a flag image based on the specified size and country code.
|
||||||
|
* @param size - The desired height of the flag image. Avaliable sizes: 20, 24, 40, 60, 80, 120, 240.
|
||||||
|
* @param country - The 2 digit country code representing the desired flag.
|
||||||
|
* @returns The URL of the flag image.
|
||||||
|
*/
|
||||||
|
export function getFlag(size:number,country: string) {
|
||||||
|
return `https://flagcdn.com/h${size}/${country}.png`;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function generateRandomString() {
|
export function generateRandomString() {
|
||||||
|
|||||||
@@ -18,7 +18,7 @@
|
|||||||
on:click={() => nav(item.country_code)}
|
on:click={() => nav(item.country_code)}
|
||||||
>{item.name}
|
>{item.name}
|
||||||
<img
|
<img
|
||||||
src={getFlag(item.country_code)}
|
src={getFlag(24, item.country_code)}
|
||||||
class="inline-block -mt-1 mr-1"
|
class="inline-block -mt-1 mr-1"
|
||||||
alt="Flag"
|
alt="Flag"
|
||||||
/></button
|
/></button
|
||||||
|
|||||||
@@ -8,7 +8,7 @@
|
|||||||
<h1 class="text-center text-4xl font-bold">
|
<h1 class="text-center text-4xl font-bold">
|
||||||
Regions in {countryCodeToName(data.countrycode)}
|
Regions in {countryCodeToName(data.countrycode)}
|
||||||
<img
|
<img
|
||||||
src={getFlag(data.countrycode)}
|
src={getFlag(40, data.countrycode)}
|
||||||
class="inline-block -mt-1 mr-1"
|
class="inline-block -mt-1 mr-1"
|
||||||
alt="Flag"
|
alt="Flag"
|
||||||
/>
|
/>
|
||||||
|
|||||||
Reference in New Issue
Block a user