An ember-cli addon for usingFont Awesome icons in Emberapplications.
WARNING: Please verify that you are reading the README corresponding withthe version of ember-font-awesome
you are using.
Please consult the table to check which version of ember-font-awesome
youshould use:
Addon version | Ember version | Addon name |
---|---|---|
>= 4.0.0 , < 5.0.0 |
>= 2.10.0 |
ember-font-awesome |
>= 2.0.0 , < 4.0.0 |
>= 2.3.0 |
ember-font-awesome |
>= 1.0.0 , < 2.0.0 |
>= 1.11.0 |
ember-cli-font-awesome |
>= 0.1.0 , < 1.0.0 |
>= 1.13.0 |
ember-cli-font-awesome |
0.0.9 |
< 1.11.0 |
ember-cli-font-awesome |
Version 4.0.0 of this addon introduces an entirely new approach in which the addon contains no components and has 0 runtime overhead. Instead, all usages of {{fa-icon}}
,{{fa-list}}
and {{fa-stack}}
are transformed into the right markup in compile-time.
To achieve this we had to make the component a bit more constrained so it can be compiledstatically. There is a few (edge) cases that we had to drop to achieve that:
{{fa-icon tagName=boundValue}}
. You cannot pass a bound value to the tag name (you still can pass a fixed value like {{fa-icon tagName="span"}}
){{fa-icon "credit-card"}}
and {{fa-icon "fa-credit-card"}}
were valid invocations. Now only the first one is. You should not include the fa-
prefix on the icon names.{{fa-icon size="2"}}
and {{fa-icon size="2x"}}
were valid sizes. Now only the first one is, you cannot pass a string ending in x
.devDependencies
to dependencies
in your package.json
.EMBER_CLI_FONT_AWESOME_DISABLE_CACHE=true
environment variable to ember build
In return you get a an addon with 0 runtime overhead, that ships 0 bytes of javascript codeand (optionally) removes the CSS of unused icons in production, yielding to even more saved bytes.
NOTE: If your addon is using ember-try
to test against versions of ember lower than 2.10, you will need to make some adjustments.
ember-font-awesome
as a peerDependency
in your addon's ember-try
, using the correct version number according to the table above.null
as the value for ember-font-awesome
in the dependencies
key for that older version of ember under test, otherwise the test build will not use the version specified as a peerDependency
// config/ember-try.js
module.exports = {
scenarios: [
{
name: 'ember-lts-2.8',
bower: {
dependencies: {
'ember': 'components/ember#lts-2-8'
},
resolutions: {
'ember': 'lts-2-8'
}
},
npm: {
dependencies: {
'ember-font-awesome': null // <---
},
peerDependencies: {
'ember-font-awesome': '^3.0.0' // <---
},
devDependencies: {
'ember-source': null
}
}
},
... // other scenarios
]
};
In your application's directory:
$ ember install ember-font-awesome
Use the component in your Handlebars templates:
This will render:
<i class="fa fa-camera"></i>
To see which icons are available please check thecomplete list of Font Awesome icons.
Note: We are currently working hard to get to version 5. Until then we don't support the Font Awesome 5 icons.
The Font Awesome examplesillustrate the various options and their effects. It should be fairly simple tomap these options to their {{fa-icon}}
counterparts.
aria-hidden
AttributeTo better support accessibility (i.e. screen readers), the helper adds thearia-hidden
attribute by default:
Results in:
<i class="fa fa-star" aria-hidden="true"></i>
To remove the aria-hidden
attribute:
aria-label
AttributeTo better support accessibility (i.e. screen readers), the helper adds anoptional aria-label
attribute:
Results in:
<i class="fa fa-star" aria-label="Click Me"></i>
You can respond to actions on the icon by passing on action handlers:
Use tagName
to control the generated markup:
Results in:
<span class="fa fa-star"></span>
Results in:
<i class="fa fa-bicycle my-custom-class"></i>
Results in:
<i class="fa fa-edit" title="Edit the item"></i>
If you are using the ember-cli-sass or ember-cli-less addon, you can opt-in tothe Scss or Less version of font-awesome by adding the following configurationin ember-cli-build.js
:
var app = new EmberApp({
'ember-font-awesome': {
useScss: true, // for ember-cli-sass
useLess: true // for ember-cli-less
}
});
Then in your app.scss
or app.less
:
@import "font-awesome";
You can configure the addon to not import any assets (CSS or font files) by addingthe following configuration in ember-cli-build.js
:
var app = new EmberApp({
'ember-font-awesome': {
includeFontAwesomeAssets: false
}
});
You can also configure the addon to only import specific font formats by addingthe following configuration in ember-cli-build.js
:
Default: ['eot', 'svg', 'ttf', 'woff', 'woff2', 'otf']
var app = new EmberApp({
'ember-font-awesome': {
fontFormats: ['woff', 'woff2']
}
});
In addition, you can configure the addon to exclude the font file assets entirely by addingthe following configuration in ember-cli-build.js
:
var app = new EmberApp({
'ember-font-awesome': {
includeFontFiles: false
}
});
This addon includes an experimental functionality to detect the used icons and remove the ones you don't use.By default this feature is disabled, but you enabled when environment
is 'production'
by doing:
var app = new EmberApp({
'ember-font-awesome': {
removeUnusedIcons: EmberApp.env() === 'production' // The addon will remove unused icons in production
}
});
By default this addon detects which icons are used based on the invocation parameters of {{fa-icon}}
,and removes the rest, but you can whitelist in ember-cli-build.js
some specific icons to be alwaysincluded regardless of if they are used or not:
var app = new EmberApp({
'ember-font-awesome': {
includeStaticIcons: ['sort'],
}
});
Since all invocations of {{fa-icon}}
are transformed to HTML tags at compile time, there's no need for an actual {{fa-icon}}
component. Except for one edge case: Passing a component invoked via the {{component}}
helper.
In your ember-cli-build.js
you can enable the includeComponent
option to include an {{fa-icon}}
component for exactly that use case.You will still benefit from all compile time optimizations, however we'll add a bit of additional JS to your asset bundle size.
var app = new EmberApp({
'ember-font-awesome': {
includeComponent: true
}
});
You can change the directory where the fonts are copied to using the following configuration:
var app = new EmberApp({
'ember-font-awesome': {
fontsOutput: "/some/dir/"
}
});
This is useful when you change the output paths for your ember app. By default, ember-font-awesome copies the font files to /dist/fonts
. The addon produces a css file to load the fonts that will be included in the vendor css file and expect to find the fonts at ../fonts
. If the css directory is not at the same level as the fonts directory, the site won't load the fonts.
For example, moving the css directory to /dist/assets/css
would require the fonts directory to be /dist/assets/fonts
and the configuration would look like this:
var app = new EmberApp({
outputPaths: {
app: {
css: {
app: "/assets/css/app-name.css",
},
js: "/assets/js/app-name.js",
},
vendor: {
css: "/assets/css/vendor.css",
js: "/assets/js/vendor.js",
},
},
'ember-font-awesome': {
fontsOutput: "/assets/fonts"
}
});
discord[new-issue]: https://github.com/martndemus/ember-font-awesome/issues/new
Font Awesome 是一个图标工具包。其已经被重新设计并从头构建。除此之外,还增加了一些功能,比如 icon font ligature、SVG 框架、流行的前端库(如 React)的官方 NPM 包,以及对新 CDN 的访问。Font Awesome 已扩展至 7,865 个图标。
介绍 (Introduction) Font类声明了用于以可见方式呈现文本的字体。 类声明 以下是java.awt.Font类的声明: public class Font extends Object implements Serializable 字段 (Field) 以下是java.awt.geom.Arc2D类的字段: static int BOLD - 粗体样式常量。
描述 (Description) font属性是用于影响文本呈现的简写属性。 可能的值 (Possible Values) 可能的值取决于我们如何使用此属性。 《font-style》 - 属性font-style的任何允许值。 《font-variant》 - 属性font-variant的任何允许值。 《font-weight》 - 属性font-weight的任何允许值。 《font-siz
这是Web开发人员的完整参考指南,其中列出了与万维网联盟推荐的层叠样式表规范2级中定义的字体相关的所有CSS属性。 单击任何属性以查看其描述的示例 - Sr.No. 财产和描述 1 font 设置元素的所有字体属性。 值是 - 的任何值 - font-style font-variant font-weight font-size line-height font-family 2 font-fa
Font Awesome swift 是用于 iOS 的 Font Awesome 库,它不再带没有图标,使用简单。
描述 (Description) font-weight属性改变元素中字符的视觉权重。 可能的值 (Possible Values) 100, 200, 300, 400, 500, 600, 700, 800 and 900 - 从细到粗的字符定义。 400与正常相同,700与粗体相同。 normal - 默认。 定义普通字符并等效于值400。 bold - 相当于值700。 bolder -