@superyachttimes/flags
v1.0.1
Published
A library of SVG flags for SYT and YachtEye applications
Readme
@superyachttimes/flags
A library of SVG flags for SYT and YachtEye applications.
Installation
npm install @superyachttimes/flagsUsage
import { Flag } from '@superyachttimes/flags'
// Using country name
<Flag country="United States" />
// Using country code
<Flag country="US" />
// Using SYT iQ country ID
<Flag country={209} />
// Custom dimensions
<Flag country="United Kingdom" width={40} height={30} />Testing
The library includes comprehensive tests covering:
- Flag component rendering
- Country lookup methods (by name, code, and ID)
- Edge cases and error handling
- Performance benchmarks
- Type definitions
Running Tests
npm testTest Coverage
The tests cover:
- ✅ Flag component functionality
- ✅ Country mapping validation
- ✅ Utility functions
- ✅ Type definitions
- ✅ Integration scenarios
- ✅ Performance metrics
Supported Countries
The library supports 224 countries with the following identifiers:
| ID | Code | Country | |----|------|---------| | 1 | AF | Afghanistan | | 2 | AL | Albania | | 3 | DZ | Algeria | | 4 | AS | American Samoa | | 5 | AD | Andorra | | 6 | AO | Angola | | 7 | AI | Anguilla | | 8 | AG | Antigua and Barbuda | | 9 | AR | Argentina | | 10 | AM | Armenia | | 11 | AW | Aruba | | 12 | AU | Australia | | 13 | AT | Austria | | 14 | AZ | Azerbaijan | | 15 | BS | Bahamas | | 16 | BH | Bahrain | | 17 | BD | Bangladesh | | 18 | BB | Barbados | | 19 | BY | Belarus | | 20 | BE | Belgium | | 21 | BZ | Belize | | 22 | BJ | Benin | | 23 | BM | Bermuda | | 24 | BT | Bhutan | | 25 | BO | Bolivia | | 26 | BA | Bosnia and Herzegovina | | 27 | BW | Botswana | | 28 | BR | Brazil | | 30 | BG | Bulgaria | | 31 | BF | Burkina Faso | | 32 | BI | Burundi | | 33 | KH | Cambodia | | 34 | CM | Cameroon | | 35 | CA | Canada | | 36 | CV | Cape Verde | | 37 | KY | Cayman Islands | | 38 | CF | Central African Republic | | 39 | TD | Chad | | 40 | CL | Chile | | 41 | CN | China | | 42 | CO | Colombia | | 43 | KM | Comoros | | 228 | CD | Congo (Democratic Republic of the Congo) | | 44 | CG | Congo (Republic of the Congo) | | 45 | CK | Cook Islands | | 46 | CR | Costa Rica | | 47 | CI | Côte d'Ivoire | | 48 | HR | Croatia | | 49 | CU | Cuba | | 229 | CW | Curaçao | | 50 | CY | Cyprus | | 51 | CZ | Czech Republic | | 52 | DK | Denmark | | 53 | DJ | Djibouti | | 54 | DM | Dominica | | 55 | DO | Dominican Republic | | 56 | EC | Ecuador | | 57 | EG | Egypt | | 58 | SV | El Salvador | | 59 | GQ | Equatorial Guinea | | 60 | ER | Eritrea | | 61 | EE | Estonia | | 188 | SZ | Eswatini | | 62 | ET | Ethiopia | | 64 | FO | Faroe Islands | | 65 | FJ | Fiji | | 66 | FI | Finland | | 67 | FR | France | | 68 | GF | French Guiana | | 69 | PF | French Polynesia | | 70 | GA | Gabon | | 72 | GE | Georgia | | 73 | DE | Germany | | 74 | GH | Ghana | | 75 | GI | Gibraltar | | 76 | GR | Greece | | 77 | GL | Greenland | | 78 | GD | Grenada | | 79 | GP | Guadeloupe | | 80 | GU | Guam | | 81 | GT | Guatemala | | 82 | GN | Guinea | | 83 | GW | Guinea-Bissau | | 84 | GY | Guyana | | 85 | HT | Haiti | | 86 | VA | Holy See (Vatican City State) | | 87 | HN | Honduras | | 88 | HK | Hong Kong | | 89 | HU | Hungary | | 90 | IS | Iceland | | 91 | IN | India | | 92 | ID | Indonesia | | 93 | IR | Iran | | 94 | IQ | Iraq | | 95 | IE | Ireland | | 223 | IM | Isle of Man | | 225 | IL | Israel | | 96 | IT | Italy | | 97 | JM | Jamaica | | 98 | JP | Japan | | 99 | JO | Jordan | | 100 | KZ | Kazakhstan | | 101 | KE | Kenya | | 102 | KI | Kiribati | | 104 | KW | Kuwait | | 105 | KG | Kyrgyzstan | | 106 | LA | Lao People's Democratic Republic | | 107 | LV | Latvia | | 108 | LB | Lebanon | | 109 | LS | Lesotho | | 110 | LR | Liberia | | 111 | LY | Libya | | 112 | LI | Liechtenstein | | 113 | LT | Lithuania | | 114 | LU | Luxembourg | | 115 | MO | Macao | | 117 | MG | Madagascar | | 118 | MW | Malawi | | 119 | MY | Malaysia | | 120 | MV | Maldives | | 121 | ML | Mali | | 122 | MT | Malta | | 123 | MH | Marshall Islands | | 124 | MQ | Martinique | | 125 | MR | Mauritania | | 126 | MX | Mexico | | 127 | FM | Micronesia | | 128 | MD | Moldova | | 129 | MC | Monaco | | 130 | MN | Mongolia | | 219 | ME | Montenegro | | 131 | MS | Montserrat | | 132 | MA | Morocco | | 133 | MZ | Mozambique | | 134 | MM | Myanmar | | 135 | NA | Namibia | | 136 | NR | Nauru | | 137 | NP | Nepal | | 138 | NL | Netherlands | | 139 | AN | Netherlands Antilles | | 140 | NC | New Caledonia | | 141 | NZ | New Zealand | | 142 | NI | Nicaragua | | 143 | NE | Niger | | 144 | NG | Nigeria | | 145 | NU | Niue | | 146 | NF | Norfolk Island | | 116 | MK | North Macedonia | | 147 | MP | Northern Mariana Islands | | 148 | NO | Norway | | 149 | OM | Oman | | 150 | PK | Pakistan | | 151 | PW | Palau | | 152 | PA | Panama | | 153 | PG | Papua New Guinea | | 154 | PY | Paraguay | | 155 | PE | Peru | | 156 | PH | Philippines | | 158 | PL | Poland | | 159 | PT | Portugal | | 160 | PR | Puerto Rico | | 161 | QA | Qatar | | 162 | RE | Réunion | | 163 | RO | Romania | | 164 | RU | Russia | | 165 | RW | Rwanda | | 166 | SH | Saint Helena | | 167 | KN | Saint Kitts and Nevis | | 168 | LC | Saint Lucia | | 169 | PM | Saint Pierre and Miquelon | | 224 | VC | Saint Vincent and the Grenadines | | 171 | SM | San Marino | | 172 | ST | São Tomé and Príncipe | | 173 | SA | Saudi Arabia | | 174 | SN | Senegal | | 221 | RS | Serbia | | 175 | SC | Seychelles | | 176 | SL | Sierra Leone | | 177 | SG | Singapore | | 226 | SX | Sint Maarten | | 178 | SK | Slovakia | | 179 | SI | Slovenia | | 180 | SB | Solomon Islands | | 181 | SO | Somalia | | 182 | ZA | South Africa | | 103 | KR | South Korea (Republic of Korea) | | 183 | ES | Spain | | 184 | LK | Sri Lanka | | 185 | SD | Sudan | | 186 | SR | Suriname | | 187 | SJ | Svalbard and Jan Mayen | | 189 | SE | Sweden | | 190 | CH | Switzerland | | 191 | SY | Syrian Arab Republic | | 192 | TW | Taiwan | | 193 | TJ | Tajikistan | | 194 | TZ | Tanzania | | 195 | TH | Thailand | | 196 | TG | Togo | | 197 | TK | Tokelau | | 198 | TO | Tonga | | 199 | TT | Trinidad and Tobago | | 200 | TN | Tunisia | | 201 | TR | Turkey | | 202 | TM | Turkmenistan | | 203 | TC | Turks and Caicos Islands | | 204 | TV | Tuvalu | | 205 | UG | Uganda | | 220 | UA | Ukraine | | 206 | AE | United Arab Emirates | | 208 | GB | United Kingdom | | 209 | US | United States | | 210 | UY | Uruguay | | 211 | UZ | Uzbekistan | | 212 | VU | Vanuatu | | 213 | VE | Venezuela | | 214 | VN | Vietnam | | 230 | VG | Virgin Islands (UK) | | 215 | VI | Virgin Islands (US) | | 207 | WF | Wallis and Futuna | | 216 | EH | Western Sahara | | 217 | YE | Yemen | | 218 | ZM | Zambia | | 227 | ZW | Zimbabwe |
API Reference
Flag Component
<Flag
country: string | number // Country name, code, or ID
width?: number // Default: 20
height?: number // Default: 16
/>Utility Functions
getFlagComponentByCountryId(countryId: number)- Get flag component by country IDgetFlagComponentByCountryCode(countryCode: string)- Get flag component by country codeflagComponents- Object containing all flag componentsidToCountryMap- Mapping of country IDs to country namescodeToCountryMap- Mapping of country codes to country names
Development
# Install dependencies
npm install
# Run tests
npm test
# Build the library
npm run build
# Lint code
npm run lint