Closed SGissubel closed 6 years ago
Hi @SGissubel, Thank you for the provided code samples. Currently, while using IconFonts inside the ActionBar, you should use Label. For example:
<ActionBar title="Title" class="action-bar">
<ActionItem >
<Label text="" class="icon" ></Label>
</ActionItem>
<ActionItem ios.position="right">
<Label text="" class="icon" ></Label>
</ActionItem>
</ActionBar>
I tested this case with the free version of Font Awesome. Bear in mind that for properly setting up the position of the Labels, you should set them inside the ActionItems. For your convenience, I am attaching sample project, which can be used for debugging. Archive.zip
@SGissubel you can also use fonticon
pipe on those Label
's just as well there too.
Thanks folks! I used both solutions and worked like a CHARM!
But while I am here...
Any idea why the following wouldn't work?
<Button class="fa" width="20%" [text]="'fa-map-marked-alt' | fonticon"></Button>
It is apparently JUST that particular font icon. Most other things I try work:
But if I put in another icon...
<Button class="fa" width="20%" [text]="'fa-map-pin' | fonticon"></Button>
I also tried:
fa-map-marker-alt
But I get the same question-mark box.
Check the CSS and make sure that icon class is actually in the styles. Sometimes depending on version the docs may reference an icon which may have not been in the version of css at the time you downloaded. Just search the .css for that classname.
I have had A few weird similar issue like the previous.
For example - I also just get nothing at all for this:
<Label flexGrow="1" class="fa icon-utensil" [text]="'fa-utensils' | fonticon"></Label>
Which doesn't show up at all...
But I also checked the css for fa-utensils
and it also does exist.
What’s in your icon-utensil class there?
Currently nothing. I attempted to set color: black;
but it did nothing.
You might post whole template or at least the bottom tabbar setup. Sometimes things like that could be the position is not where you might expect especially when using flex layout rules.
Flex was one of many I tried. haha.
This is actually a child component.
Parent:
<GridLayout rows="150, 200, *">
<StackLayout row="0">
<profile-head
[profileUser]="user">
</profile-head>
</StackLayout>
<StackLayout row="1">
<profile-nav row="1">
</profile-nav>
</StackLayout>
<Label row="2"></Label>
</GridLayout>
Child: including some of the different attempts commented out
<!-- <GridLayout columns="*, *, *, *" class="profile-head" > -->
<GridLayout col="0" orientation="horizontal" horizontalAlignment="center">
<Label class="fa" [text]="'fa-list-ul' | fonticon"></Label> -->
</GridLayout>
<GridLayout col="1" orientation="horizontal" horizontalAlignment="center">
<Label class="fa" [text]="'fa-utensils' | fonticon"></Label>
</GridLayout>
<GridLayout col="2" orientation="horizontal" horizontalAlignment="center">
<Label class="fa" [text]="'fa-calendar' | fonticon"></Label>
</GridLayout>
<GridLayout col="3" orientation="horizontal" horizontalAlignment="center">
<Label class="fa" [text]="'fa-bookmark' | fonticon"></Label>
</GridLayout>
<!-- </GridLayout> -->
<FlexboxLayout flexDirection="row">
<!-- Use even flexGrow to achieve uniform grid -->
<Label flexGrow="1" class="p-15 text-center font-weight-bold fa" [text]="'fa-list' | fonticon"></Label>
<Label flexGrow="1" class="p-15 text-center font-weight-bold fa icon-utensil" [text]="'fa-utensils' | fonticon"></Label>
<Label flexGrow="1" class="p-15 text-center font-weight-bold fa" [text]="'fa-calendar' | fonticon"></Label>
<Label flexGrow="1" class="p-15 text-center font-weight-bold fa" [text]="'fa-bookmark' | fonticon"></Label>
</FlexboxLayout>
@SGissubelI've stumbled upon similar issue - some specific icons from FontAwesome5 are not shown while most are working as expected. In my case, it appeared that some icons are shown only when using a specific font variant.
For example, for the icon fa-marked-map-alt only the solid font is working
<!-- Works as expectedv with fas map-marked-alt -->
<Label class="fas" text="">
</Label>
<!-- WON'T WORK far map-marked-alt -->
<Label class="far" text="">
</Label>
<!-- WON'T WORK with fab map-marked-alt -->
<Label class="fab" text="">
</Label>
where the fas, far and fab are the following fonts in my CSS
.far {
font-family: Font Awesome 5 Free, fa-regular-400;
font-weight: 400;
}
.fab {
font-family: Font Awesome 5 Brands, fa-brands-400;
font-weight: 400;
}
.fas {
font-family: Font Awesome 5 Free, fa-solid-900;
font-weight: 900;
}
Test app demonstrating the above here.
Closing the issue as the main problem has been answered with a solution.
Which platform(s) does your issue occur on?
tns version: 4.1.2 Cross-platform modules: "version": "4.1.1" "tns-ios": "version": "4.1.1"
Please, tell us how to recreate the issue in as much detail as possible.
Using fonticon with my Nativescript-angular app. I have followed all of the instructions and have even debugged several items.
It displays the icon in
Label
BUT the layout gets completely messed up:Results in:
What I need is to use
ActionItem
:But results in:
In my app.scss:
(I tried using a capital F in Font-family - no change.)
My app module:
In my
fonts
folder I have:fontawesome-webfont.ttf
&FontAwesome.ttf
In my
assets
folder I have:fontawesome.css
(the compiled form of -->)fontawesome.scss
Desired output: