• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

FokkeZB/IconFont: CLI that converts Icon Font CSS StyleSheets into CommonJS modu ...

原作者: [db:作者] 来自: 网络 收藏 邀请

开源软件名称:

FokkeZB/IconFont

开源软件地址:

https://github.com/FokkeZB/IconFont

开源编程语言:

CSS 61.6%

开源软件介绍:

IconFont

CLI to convert CSS StyleSheets for Icon Fonts like FontAwesome to a CommonJS module or Alloy TSS file that exports all unicodes by name.

I use them in native iOS & Android apps build with Titanium.

Example

Install the CLI npm

Install the CLI via NPM like this:

$ [sudo] npm install -g iconfont

CommonJS

Generate it

Just point the CLI to the CSS file:

$ iconfont font-awesome.css

This would create a file named font-awesome.js in the same directory as the CSS file. If you want to write to a different path, simply pass it as the second argument:

$ iconfont font-awesome.css ~/fa.js

Use it

In Titanium, I'd use the module like this:

var icons = require('font-awesome');

var button = Ti.UI.createButton({
	font: {
		fontFamily: 'FontAwesome'
	},
	title: icons.flag
});

In Alloy you can do:

alloy.js

Alloy.Globals.icons = require('font-awesome');

index.tss

"Button": {
	title: Alloy.Globals.icons.flag
}

Alloy TSS

Credits: Jong Eun Lee.

Generate it

Add the -t or --tss flag:

$ iconfont font-awesome.css -t

Or when using the second output-argument, make sure its extension is .tss:

$ iconfont font-awesome.css ~/fa.tss

Use it

Since you cannot import TSS files at the moment, you'd probably copy-paste the contents of the generated file to your app/styles/app.tss file.

index.xml

Use the classes just like in HTML:

<Label class="fa-thumbs-up otherClassName"></Label>

index.tss

And overwrite any property using additional class names:

".otherClassName": {
	font: {
		fontSize: 40
	}
}

Notes

  • For JS:
    • Icon names are camel-cased (arrow-up becomes arrowUp).
    • If all icon names share the same prefix this will be stripped out (icon-flag becomes flag).
  • The CLI expects selectors ending with :before.
  • The CLI expects declerations with a content property and a valid (unicode) string as value.

Changelog

  • 0.3.0: Adds support for generating TSS files
  • 0.2.0:
    • Adds support for non-unicode content
    • Fixes camelCase for some-1 (#3)
  • 0.1.0: Initial release

Issues

Please report issues and features requests in the repo's issue tracker.

License

Distributed under MIT License.




鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap