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

Cannot use ng-container *ngFor inside a fa-layer #283

Closed
pauldaustin opened this issue Dec 10, 2020 · 0 comments · Fixed by #284
Closed

Cannot use ng-container *ngFor inside a fa-layer #283

pauldaustin opened this issue Dec 10, 2020 · 0 comments · Fixed by #284

Comments

@pauldaustin
Copy link

What I would like to do is have be able to define icons with layers, text etc using objects in the typescript code. I can then pass these to a custom component that uses fa-layers to render them. This way I don't have to create a component for each layered icon or duplicate code across the app.

To achieve this I was going to loop through the layers in a ng-container and then use an ngSwitch to render a fa-icon, fa-counter etc.

Unfortunately the ng-container is ignored and no content is returned.

<fa-layers>
  <ng-container *ngFor="let layer of layers">
    <fa-icon [icon]="layer.icon" [style]="layer.styles" [transform]="layer.transform" [mask]="layer.mask">
    </fa-icon>
  </ng-container>
</fa-layers>

A simple loop on a fa-icon works but that won't allow full layering with the different options.

<fa-layers>
  <fa-icon *ngFor="let layer of layers" [icon]="layer.icon" [style]="layer.styles" [transform]="layer.transform"
    [mask]="layer.mask">
  </fa-icon>
</fa-layers>

This is is an example of my current icon definitions without the typing. Which would be of the form type: 'icon' (default) etc.

[
    { icon: 'file', styles: { color: 'var(--documentRevision)' } },
    {
      icon: 'history',
      styles: { color: 'white' },
      transform: 'shrink-6, down-2',
    }
  ]
devoto13 added a commit to devoto13/angular-fontawesome that referenced this issue Dec 10, 2020
Silently dropping unsupported elements seems to create more pain then it generates benefit: it is confusing and does not support all use cases (for example fa-icon inside ng-container). It is better to relax it and assume that users only provide supported elements.

Fixes FortAwesome#283
devoto13 added a commit that referenced this issue Dec 11, 2020
Silently dropping unsupported elements seems to create more pain then it generates benefit: it is confusing and does not support all use cases (for example fa-icon inside ng-container). It is better to relax it and assume that users only provide supported elements.

Fixes #283
devoto13 added a commit to devoto13/angular-fontawesome that referenced this issue Dec 11, 2020
Previously we would silently drop elements without stackItemSize, which was confusing to users.

With this change we also stop making assumptions about the passed elements to prevent issues like FortAwesome#283, but in fa-stack.

Fixes FortAwesome#177
devoto13 added a commit that referenced this issue Dec 11, 2020
Previously we would silently drop elements without stackItemSize, which was confusing to users.

With this change we also stop making assumptions about the passed elements to prevent issues like #283, but in fa-stack.

Fixes #177
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.

1 participant