Coder Social home page Coder Social logo

adamwojda / react-emoji-country-code-selector Goto Github PK

View Code? Open in Web Editor NEW

This project forked from dscafati/react-emoji-country-code-selector

0.0 0.0 0.0 168 KB

Pure html phone country code selector showing country flags as emojis, built as a React component

License: MIT License

JavaScript 88.05% TypeScript 11.95%

react-emoji-country-code-selector's Introduction

Build Status

React + Emoji Phone Country Code Selector

๐Ÿ‡ฆ๐Ÿ‡ท ๐Ÿ‡บ๐Ÿ‡ธ ๐Ÿ‡ฉ๐Ÿ‡ช ๐Ÿ‡ฏ๐Ÿ‡ต ๐Ÿ‡ฐ๐Ÿ‡ท ๐Ÿ‡จ๐Ÿ‡ณ ๐Ÿ‡ฎ๐Ÿ‡ณ ๐Ÿ‡ซ๐Ÿ‡ท ๐Ÿ‡ช๐Ÿ‡ธ ๐Ÿ‡ฎ๐Ÿ‡น ๐Ÿ‡ท๐Ÿ‡บ

This is a React component that generates a pure html <select> element populated with a list of countries and their respective country codes.

In practice, there are countries with more than one code, and codes in more than one country (N:N).

Example

Screenshot

Usage

Download and declare the dependency with the command

npm i react-emoji-country-code-selector

or

yarn add react-emoji-country-code-selector

In your code, import the component like this:

import {HtmlEmojiCountryCodeSelector} from "react-emoji-country-code-selector";

Or if your project doesn't support ES6

const HtmlEmojiCountryCodeSelector = require("react-emoji-country-code-selector").HtmlEmojiCountryCodeSelector;

Then, use it as follows. Notice that this component accepts all the same properties of a regular <select> element. The 2 added properties are all optional

// Example 1
<HtmlEmojiCountryCodeSelector/>;

// Example 2
<HtmlEmojiCountryCodeSelector
    defaultValue={"+1"}
    generateValue={(data) => data.code}
    generateLabel={(data) => `${data.ISO} ${data.flag} ${data.code}`}
>
    <option>Select your country code</option>
</HtmlEmojiCountryCodeSelector>;
    
// Example 3
<HtmlEmojiCountryCodeSelector
    defaultValue={"US"}
    generateValue={(data) => data.ISO}
>
</HtmlEmojiCountryCodeSelector>;

Note: The dataset can also be imported individually

import {dataset} from "react-emoji-country-code-selector";

or

const dataset = require("react-emoji-country-code-selector").dataset;

Collaboration

Feel free to fork the repository, modify it, and push back code to this repo.

I'll be happy to review any type of pull request!

react-emoji-country-code-selector's People

Contributors

dscafati avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.