Skip to content
This repository has been archived by the owner on May 8, 2023. It is now read-only.

[Nativescript-Vue] nativescript-fonticon v2 - update guide #15

Open
Erwol opened this issue Sep 25, 2018 · 14 comments
Open

[Nativescript-Vue] nativescript-fonticon v2 - update guide #15

Erwol opened this issue Sep 25, 2018 · 14 comments

Comments

@Erwol
Copy link

Erwol commented Sep 25, 2018

Hi, I cannot make this plugin works when using its version 2. I'm trying to follow [https://nativescript-vue.org/blog/using-fonticons/](this tutorial: https://nativescript-vue.org/blog/using-fonticons/) with no success. Any thoughts?

@brunnich
Copy link

brunnich commented Oct 2, 2018

Hi,
You just need to put font file in app/fonts (folder already created normally) instead of app/assets/fonts.
That's how I made it work :)

@matrunchyk
Copy link
Contributor

matrunchyk commented Oct 6, 2018

  1. Put your FontAwesome.ttf into app/fonts
  2. Create app/assets/font-awesome.css file with a content like the following one:
.fa {
  font-family : FontAwesome;
}

.fa-remove:before,
.fa-close:before,
.fa-times:before {
  content: "\f00d";
}

.fa-glass:before {
  content: "\f000";
}

.fa-music:before {
  content: "\f001";
}
  1. Install the package (if not installed yet): npm install nativescript-fonticon --save
  2. Change your main.js file to contain the following:
import { TNSFontIcon, fonticon } from 'nativescript-fonticon';

TNSFontIcon.debug = true;
TNSFontIcon.paths = {
  'fa': './assets/font-awesome.css',
};

// Simple variant:
// TNSFontIcon.loadCss();

// Or verbose variant:
TNSFontIcon.loadCss().then(() => {
  console.log('FontAwesome font collection loaded successfully.');
}).catch((e) => {
  console.log('Error loading FontAwesome font collection!', e.getMessage());
});

Vue.filter('fonticon', fonticon);
  1. Use it like this:
    <Label class="fa" :text="'fa-music' | fonticon"></Label>

@thearabbit
Copy link

excuse me, could you example for TabViewItem

@thukuwanjiku
Copy link

@matrunchyk Mine isn't working. I've tried it countless times, it doesn't work

I have both the css and .ttf files in the right directories
image

I have the package installed
image

My main.js is setup
image

But this fontawesome icon in this template
image

does not render
image

Please help.

@matrunchyk
Copy link
Contributor

matrunchyk commented Nov 16, 2018

@thukuwanjiku @thearabbit Did you try to name the files exactly the same as in the steps I have provided? Some browsers require the name of the font file to be exactly the same as font-family name.

@thearabbit
Copy link

This is my structure

image

// app.scss
.fa {
  font-family: FontAwesome, fontawesome-webfont;
}

// main.js
// FontAwesome
import { TNSFontIcon, fonticon } from "nativescript-fonticon";

TNSFontIcon.debug = true;
TNSFontIcon.paths = {
  fa: "./assets/styles/font-awesome.css"
};
TNSFontIcon.loadCss();
Vue.filter("fonticon", fonticon);

@thukuwanjiku
Copy link

@matrunchyk I sure did, again and again, it just won't work. Perhaps if you spare a minute and build a blank app with the icons working you could share with me and have me build on top of it. I'd appreciate.

@vincentderidder
Copy link

I cannot get it to work either. Did someone figure out how to make it work with nativescript-vue?

@matrunchyk
Copy link
Contributor

It works for me in my current project. I'll share an example with you tomorrow and will update Docs as well.

@vincentderidder
Copy link

That would be helpfull, looking forward to it!

@kstan79
Copy link

kstan79 commented Dec 13, 2018

it doesn't work to me too.

@kstan79
Copy link

kstan79 commented Dec 14, 2018

i'm remove and rebuild entire project, it work again. Hope this help

@khalidkaram
Copy link

khalidkaram commented Dec 27, 2018

I had the same issue, the problem was my webpack config.
This part was missing:

new CopyWebpackPlugin([
                { from: "fonts/**" },
                { from: "**/*.+(jpg|png)" },
                { from: "assets/**/*" },
            ], { ignore: [`${relative(appPath, appResourcesFullPath)}/**`] }),

I hope this hep!

@jbosse
Copy link

jbosse commented Jan 2, 2019

@matrunchyk thanks for the /assets tip. It seems that the underlying Nativescript file-system component cannot read files in the app root.

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

No branches or pull requests

9 participants