Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Emoji displaying #7

Open
khitrukhina opened this issue Oct 13, 2022 · 9 comments
Open

Emoji displaying #7

khitrukhina opened this issue Oct 13, 2022 · 9 comments

Comments

@khitrukhina
Copy link

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
Copy link
Owner

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

@khitrukhina
Copy link
Author

It's angular material )

@necessarylion
Copy link
Owner

necessarylion commented Oct 13, 2022

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
Copy link
Author

Maybe you have met some unexpected behaviour with emojis?)

@khitrukhina
Copy link
Author

khitrukhina commented Oct 17, 2022

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
Copy link
Owner

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

@khitrukhina
Copy link
Author

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

@khitrukhina
Copy link
Author

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
Copy link
Owner

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
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants