2.0.3 • Published 3 years ago

flag-cc v2.0.3

Weekly downloads
1
License
ISC
Repository
github
Last release
3 years ago

flag-cc

is a simple web component that display the flag of the corresponding currency or country code. Use the currency attribute to display the currency flag or use code to display the country flag.

If the flag is not found, it will displays either the currency or the code that was specified by the user.

screenshot

Installation and demo

This library depends on the famous LitElement library. To see the demo locally in action please:

git clone https://github.com/yveslange/flag-cc.git
cd flag-cc && npm install
npm start

Now you can navigate to http://localhost:8000

You can build the source by running npm run build. The built distribution will be located into ./build/. Additionally, you can serve the built

How to use

In your index.html:

  <head>
    <script src="./node_modules/@webcomponents/webcomponentsjs/webcomponents-loader.js"></script>
    <script type="module" src="./node_modules/flag-cc/index.js"></script>

Then you should be able to use \<flag-cc> tag anywhere.

<flag-cc currency="CHF"></flag-cc>
<flag-cc currency="CNY"></flag-cc>
<flag-cc currency="CNH"></flag-cc>
<flag-cc currency="ABC"></flag-cc>
<flag-cc code="Unknown"></flag-cc>
<flag-cc code="FR"></flag-cc>

Technical

The flags will be searched in ./node_modules/flag-cc/flags/. If you want to change the path please refer to the property imagesPath.

Properties

PropertyAttributeTypeDefaultDescription
codecodeThe country code (eg: CH, FR, ...)
countrycountryThe corresponding country name
currencycurrencyThe currency code (eg: EUR, CNY, CHF, ...)
flagTypeflag-typestringThe type of the flag ('country' or 'currency')
imagesPathimages-pathstring"./node_modules/flag-cc/flags/"Configures where the images folder is located
isUnknownis-unknownbooleanIs true if the country or currency code is unknown. This is set byflag-cc if the flag was not found.

Methods

MethodTypeDescription
getCountryFlag(code?: string): StringRetreive the country flag using the codecode: The country code.
getCurrencyFlag(currency: string): StringRetreive the currency flag using the currency name.currency: The currency name to use (eg: CHF, EUR, ...).
2.0.3

3 years ago

2.0.2

3 years ago

2.0.1

4 years ago

2.0.0

4 years ago

1.0.1

5 years ago

1.0.0

5 years ago

0.0.14

5 years ago

0.0.12

6 years ago

0.0.11

6 years ago

0.0.10

6 years ago

0.0.9

6 years ago

0.0.8

6 years ago

0.0.7

6 years ago

0.0.6

6 years ago

0.0.5

6 years ago

0.0.3

6 years ago

0.0.2

6 years ago

0.0.1

6 years ago