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

Unable to use a dynamic value for layers-text #136

Open
abueloshika opened this issue Jan 21, 2020 · 0 comments
Open

Unable to use a dynamic value for layers-text #136

abueloshika opened this issue Jan 21, 2020 · 0 comments

Comments

@abueloshika
Copy link

When using the <FaIcon> component with an element that has a fa-layers-text class, I'm unable to use a dynamic value for the text.

When trying to use the layers-text feature with the add I originally had a problem applying a data-fa-transform to it. @jrjohnson kindly gave me the following code to make it work:

//new-icon.js

import Component from '@ember/component';
import {
  dom,
} from '@fortawesome/fontawesome-svg-core';
import {
  next
} from '@ember/runloop';

export default class NewIcon extends Component {
  scanDom(element) {
    next(() => {
      dom.i2svg({
        node: element
      });
    });
  }
}

//new-icon.hbs

<span class="fa-layers fa-lg mr-1" {{did-insert (fn this.scanDom)}}>
  <FaIcon @icon="circle" @size="2x" />
  <span class="fa-layers-text text-white" data-fa-transform="grow-8">
    text
  </span>
</span>

This worked great, however if I use a passed value in place of text like {{@text}}, the SVG does not update to reflect the new value.

I did try to achieve it with a {{did-insert}} modifier like this:

//new-icon.hbs
<span
  class="fa-layers fa-lg mr-1"
  {{did-insert (fn this.scanDom)}}
  {{did-insert (fn this.scanDom) @score}}
>
  <FaIcon @icon="circle" @size="2x" />
  <span class="fa-layers-text text-white" data-fa-transform="grow-8">
    {{@score}}
  </span>
</span>

Even though I can confirm that the {{@score}} value has in fact updated in the component, it still doesn't update the SVG with the correct value. I'd expect the text in the SVG to update alongside the passed in value.

Let me know if you need any more information or have any other tips for me to try.

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

1 participant