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

Ligature based icons (i.e. Material icons) are not supported #2554

Closed
1 task done
ItaiYosephi opened this issue Oct 15, 2020 · 1 comment · Fixed by #2951
Closed
1 task done

Ligature based icons (i.e. Material icons) are not supported #2554

ItaiYosephi opened this issue Oct 15, 2020 · 1 comment · Fixed by #2951

Comments

@ItaiYosephi
Copy link

ItaiYosephi commented Oct 15, 2020

Issue type

I'm submitting a ... (check one with "x")

  • bug report

Issue description

Current behavior:
When registering ligature font pack, nb-icon doesn't render the icon. the icon name needs to be rendered inside the HTML tag, not added as class.

Expected behavior:
Icon should be renderd.

Steps to reproduce:
register material icons font pack and try to render an icon
I was able fix it by using a custom NbIconlibraries :

@Injectable({ providedIn: 'root' })
export class CustomNbIconLibraries extends NbIconLibraries {
  protected createFontIcon(name: string, content: NbIcon | string, params: NbFontIconPackParams): NbFontIcon {
    if (content instanceof NbFontIcon) {
      return content;
    }
    return new NbFontIcon(name, params.ligature ? name : content, params);
  }

}

app-module.ts:

@NgModule({
  declarations: [AppComponent],
  imports: [
...
  ],
  providers: [{ provide: NbIconLibraries, useExisting: CustomNbIconLibraries }],
  bootstrap: [AppComponent]
})
export class AppModule {
  constructor(private iconLibraries: NbIconLibraries) {
    this.registerMaterialIcons();
  }

  private registerMaterialIcons() {
    this.iconLibraries.registerFontPack("material-icons", {
      packClass: "material-icons",
      ligature: true
    });
    this.iconLibraries.setDefaultPack("material-icons");
  }
}

Related code:

StackBlitz StackBlitz Seed Project

@xPedrol
Copy link

xPedrol commented Nov 14, 2021

I'm with the same problem

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

Successfully merging a pull request may close this issue.

2 participants