Replace png flags with use of Twemoji
Signed-off-by: Michael Telatynski <7t3chguy@gmail.com>
This commit is contained in:
@@ -19,7 +19,7 @@ import PropTypes from 'prop-types';
|
||||
|
||||
import * as sdk from '../../../index';
|
||||
|
||||
import { COUNTRIES } from '../../../phonenumber';
|
||||
import {COUNTRIES, getEmojiFlag} from '../../../phonenumber';
|
||||
import SdkConfig from "../../../SdkConfig";
|
||||
import { _t } from "../../../languageHandler";
|
||||
|
||||
@@ -80,7 +80,7 @@ export default class CountryDropdown extends React.Component {
|
||||
}
|
||||
|
||||
_flagImgForIso2(iso2) {
|
||||
return <img src={require(`../../../../res/img/flags/${iso2}.png`)} />;
|
||||
return <div className="mx_Dropdown_option_emoji">{ getEmojiFlag(iso2) }</div>;
|
||||
}
|
||||
|
||||
_getShortOption(iso2) {
|
||||
|
||||
@@ -25,10 +25,20 @@ const PHONE_NUMBER_REGEXP = /^[0-9 -.]+$/;
|
||||
* a national-format number.
|
||||
* @return True if the number could be a valid phone number, otherwise false.
|
||||
*/
|
||||
export function looksValid(phoneNumber) {
|
||||
export function looksValid(phoneNumber: string) {
|
||||
return PHONE_NUMBER_REGEXP.test(phoneNumber);
|
||||
}
|
||||
|
||||
// Regional Indicator Symbol Letter A
|
||||
const UNICODE_BASE = 127462 - 'A'.charCodeAt(0);
|
||||
// Country code should be exactly 2 uppercase characters
|
||||
const COUNTRY_CODE_REGEX = /^[A-Z]{2}$/;
|
||||
|
||||
export const getEmojiFlag = (countryCode: string) => {
|
||||
if (!COUNTRY_CODE_REGEX.test(countryCode)) return '';
|
||||
return String.fromCodePoint(...countryCode.split('').map(l => UNICODE_BASE + l.charCodeAt(0)));
|
||||
};
|
||||
|
||||
export const COUNTRIES = [
|
||||
{
|
||||
"iso2": "GB",
|
||||
Reference in New Issue
Block a user