Skip to content

Commit a3a44ec

Browse files
committed
Merge pull request NativeScript#176 from NativeScript/icon-font-snippet
Icon font sinppets
2 parents 24d8832 + 686e86d commit a3a44ec

File tree

8 files changed

+58
-1
lines changed

8 files changed

+58
-1
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ src/nativescript-angular/**/*.js
77
.tscache
88
.nvm
99
.vscode
10+
.DS_Store
1011
nativescript-angular*.tgz
1112

1213
tests/app/**/*.js

tests/app/fonts/icomoon.ttf

93.1 KB
Binary file not shown.

tests/app/main.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,9 @@ import {nativeScriptBootstrap} from "nativescript-angular/application";
33
import {AppComponent} from "./app.component";
44
import {GestureComponent} from "./snippets/gestures.component";
55
import {LayoutsComponent} from "./snippets/layouts.component";
6+
import {IconFontComponent} from "./snippets/icon-font.component";
67

78
nativeScriptBootstrap(AppComponent);
89
// nativeScriptBootstrap(GestureComponent);
910
// nativeScriptBootstrap(LayoutsComponent);
11+
// nativeScriptBootstrap(IconFontComponent);
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
/* >> icon-font-sample */
2+
.icon {
3+
font-family: 'icomoon';
4+
font-size: 48;
5+
}
6+
/* << icon-font-sample */
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
import {Component} from "angular2/core";
2+
3+
// >> icon-font-sample
4+
@Component({
5+
// >> (hide)
6+
selector: "icon-font",
7+
templateUrl: "snippets/icon-font.component.xml",
8+
styleUrls: ["snippets/icon-font.component.css"]
9+
// << (hide)
10+
// ...
11+
})
12+
export class IconFontComponent {
13+
public glyphs = new Array<{ icon: string, code: string }>();
14+
constructor() {
15+
for (var charCode = 0xe903; charCode <= 0xeaea; charCode++) {
16+
var glyph = {
17+
icon: String.fromCharCode(charCode),
18+
code: charCode.toString(16)
19+
}
20+
this.glyphs.push(glyph);
21+
}
22+
}
23+
}
24+
// << icon-font-sample
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<!-- >> icon-font-sample -->
2+
<GridLayout>
3+
<ListView [items]="glyphs">
4+
<template #item="item">
5+
<StackLayout orientation="horizontal">
6+
<Label [text]="item.icon" class="icon"></Label>
7+
<Label [text]="item.code"></Label>
8+
</StackLayout>
9+
</template>
10+
</ListView>
11+
</GridLayout>
12+
<!-- << icon-font-sample -->

tests/app/tests/list-view-tests.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ export class TestListViewComponent {
4343
}
4444
}
4545

46-
// TODO: Skip list-view trest until
46+
// TODO: Skip list-view test until karma test launcher double navigate bug is fixed
4747
(IS_IOS ? describe.skip : describe)('ListView-tests', () => {
4848
let testApp: TestApp = null;
4949

tests/app/tests/snippets.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,10 @@ import {TestApp} from "./test-app";
55

66
import {GestureComponent} from "../snippets/gestures.component";
77
import {LayoutsComponent} from "../snippets/layouts.component";
8+
import {IconFontComponent} from "../snippets/icon-font.component";
9+
10+
import {device, platformNames} from "platform";
11+
const IS_IOS = (device.os === platformNames.ios);
812

913
describe('Snippets', () => {
1014
let testApp: TestApp = null;
@@ -32,4 +36,12 @@ describe('Snippets', () => {
3236
assert.instanceOf(componentInstance, LayoutsComponent);
3337
});
3438
});
39+
40+
// TODO: Skip list-view test until karma test launcher double navigate bug is fixed
41+
(IS_IOS ? it.skip : it)("Icon-font snippets can be loaded", () => {
42+
return testApp.loadComponent(IconFontComponent).then((componentRef) => {
43+
const componentInstance = componentRef.instance;
44+
assert.instanceOf(componentInstance, IconFontComponent);
45+
});
46+
});
3547
})

0 commit comments

Comments
 (0)