Replace png flags with use of Twemoji

Signed-off-by: Michael Telatynski <7t3chguy@gmail.com>
This commit is contained in:
Michael Telatynski
2020-05-11 22:04:18 +01:00
parent c2fea7d4d8
commit 3bb800bb81
251 changed files with 20 additions and 4 deletions

View File

@@ -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) {

View File

@@ -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",