necessarylion / country-list-with-dial-code-and-flag

Country Flag with Dial Number Code
46 stars 18 forks source link

Emoji displaying #7

Open khitrukhina opened 2 years ago

khitrukhina commented 2 years ago

I see, that you've already answered on issues like that, but it IS here. They are partially displayed. And when they are not, the text is displayed. Like on the attached screenshot. I am using Angular. imgpsh_fullsize_anim

necessarylion commented 2 years ago

Which plugin or library did you used for select box? May be the plugin issue?

khitrukhina commented 2 years ago

It's angular material )

necessarylion commented 2 years ago

Could you show your code here? It work fine for me.

 <mat-form-field appearance="fill">
    <mat-label>Country Codes</mat-label>
    <mat-select>
      <mat-option *ngFor="let list of countryLists" [value]="list.dial_code">
        {{list.flag}} {{list.dial_code}}
      </mat-option>
    </mat-select>
  </mat-form-field>
  import { Component } from '@angular/core';
//@ts-ignore
import CountryList from 'country-list-with-dial-code-and-flag'

@Component({
    selector: 'app-root',
    templateUrl: './app.component.html',
    styleUrls: ['./app.component.css']
})
export class AppComponent {
    title = 'my-app-angular';
    countryLists = CountryList.getList();
}
Screen Shot 2022-10-14 at 12 01 30 AM
khitrukhina commented 2 years ago

Maybe you have met some unexpected behaviour with emojis?)

khitrukhina commented 2 years ago

It's Windows problem. Everyone who has linix/mac - sees emoji. Windows - no.

https://answers.microsoft.com/en-us/windows/forum/all/flag-emoji/85b163bc-786a-4918-9042-763ccf4b6c05?page=4

necessarylion commented 2 years ago

There are svg and png format available here in this repo. May be you can download and use in your code.

khitrukhina commented 2 years ago

Have used this polyfill https://www.npmjs.com/package/country-flag-emoji-polyfill

khitrukhina commented 2 years ago

Removed pollyfill as its working only with cdn. Resolved like this: angular.json { "glob": "**/*", "input": "./node_modules/country-list-with-dial-code-and-flag/assets/png", "output": "assets/flags" }

component: ` readonly countriesList = countryList.getList().map(country => { const pathName = country.code.toLowerCase(); if (pathName === 'an') { return country; }

country.path = `./assets/flags/${pathName}.png`;
return country;

});`

necessarylion commented 1 year ago

New version 4.0 now support svg. https://www.npmjs.com/package/country-list-with-dial-code-and-flag/v/4.0.0

import CountryFlagSvg from 'country-list-with-dial-code-and-flag/dist/flag-svg'

const myanmar = CountryList.findOneByCountryCode('mm')
if(myanmar) {
    const flagSvg = CountryFlagSvg[myanmar.code] // .js
    const flagSvg = CountryFlagSvg[myanmar.code as never] // .ts
    console.log(flagSvg) // it return svg string
}