codingfogey/fontawesome-bundle

此包已被弃用且不再维护。作者建议使用 braincrafted/bootstrap-bundle 包。

将 Font Awesome 易于集成到 Symfony2 项目中。

安装次数: 2,124

依赖者: 0

建议者: 0

安全: 0

星标: 2

关注者: 1

分支: 4

开放问题: 0

类型:symfony-bundle

v0.3.0 2014-01-25 20:12 UTC

This package is not auto-updated.

Last update: 2022-02-01 12:28:29 UTC


README

由于 braincrafted/bootstrap-bundle 现在直接支持 Font Awesome,因此此包不再维护。

CodingfogeyFontAwesomeBundle

License Total Downloads Latest Stable Version Latest Unstable Version Build Status Scrutinizer Quality Score SensioLabsInsight Stories in Ready

knpbundles.com

关于

此 Bundle 使您能够轻松将 Font Awesome 集成到您的 Symfony2 项目中。

先决条件

  • 在您的项目中某处安装了 Font Awesome。它不包含在此包中。您可以使用 ComposerBower 或其他方式来安装它。

安装

  1. codingfogey/fontawesome-bundle 添加到您的 composer.json

     {
         ...
         "require": {
             ...
             "codingfogey/fontawesome-bundle": "dev-master",
             "fortawesome/font-awesome": "v4.0.3"
         }
         ...
     }
    
  2. CodingfogeyFontAwesomeBundle 添加到您的 AppKernel.php

     ...
     public function registerBundles()
     {
         $bundles = array(
             ...
             new Codingfogey\Bundle\FontAwesomeBundle\CodingfogeyFontAwesomeBundle()
         );
         ...
     }
     ...
    
  3. 更新您的依赖项: composer update

注意:通过 composer 安装 Font Awesome 是可选的,但可以使此包立即工作。因此,我建议这种方式。

配置

如果您没有通过 composer 安装 Font Awesome,您需要配置到您的安装路径

codingfogey_font_awesome:
    assets_dir: %kernel.root_dir%/../vendor/fortawesome/font-awesome

定制

如果您想定制 Font Awesome,您必须在您的项目中某处放置一个定制的变量文件,并配置路径。您还需要设置输出路径。

codingfogey_font_awesome:
    filter: less
    customize:
        variables_file:         %kernel.root_dir%/Resources/fontawesome/variables.less
        font_awesome_output:    %kernel.root_dir%/Resources/less/fontawesome.less

如果您想使用 lessphpsass Assetic 过滤器,您必须相应地设置 filter 变量。

有一个命令可以生成一个定制的输出文件,以包含您的定制变量文件

app/console codingfogey:fontawesome:generate

用法

字体文件的安装

此包提供了一个命令,用于将字体文件安装到 web/fonts 目录

app/console codingfogey:fontawesome:install

还有一个 ScriptHandler,可以在每次 composer installcomposer update 时方便地自动执行此操作

...
"scripts": {
    "post-install-cmd": [
        ...
        "Codingfogey\\Bundle\\FontAwesomeBundle\\Composer\\ScriptHandler::install"
    ],
    "post-update-cmd": [
        ...
        "Codingfogey\\Bundle\\FontAwesomeBundle\\Composer\\ScriptHandler::install"
    ]
},
...

要包含 Font Awesome CSS,只需在您的基模板中包含 @fontawesome_css 即可。

<!DOCTYPE html>
<html>
    <head>
        <meta charset="UTF-8" />
        <title>{% block title %}Welcome!{% endblock %}</title>
        {% block stylesheets %}
            {% stylesheets
                '@fontawesome_css'
            %}
                <link rel="stylesheet" href="{{ asset_url }}" media="screen"/>
            {% endstylesheets %}
        {% endblock %}

添加图标

您可以按照 这里 的描述添加图标。

您还可以使用方便的 Twig 函数。

注意:如果您修改了@fa-css-prefix变量,则此功能将无法正常工作。

简单图标

要插入简单图标,请将{{ fa_icon( icon name|options ) }}添加到您的模板中。

参数可以是只包含图标名称(不含fa-前缀)的string,或者更复杂定制的JSON。完整的选项列表如下

{
    icon:           name of the icon without 'fa-' prefix
    scale:          [lg|2x|3x|4x|5x|stack-1x|stack-2x],
    fixed-width:    [true|false],
    list-icon:      [true|false],
    border:         [true|false],
    pull:           [left|right],
    spin:           [true|false],
    rotate:         [90|180|270],
    flip:           [horizontal|vertical],
    inverse:        [true|false]
}

堆叠图标

要插入堆叠图标,请将{{ fa_icon( options, options [, container] ) }}添加到您的模板中。第一个参数用于前景图标,第二个参数用于背景图标。这些参数必须是JSON,因为每个图标至少需要提供两个参数:图标名称和缩放比例。

最后一个参数是可选的,可以包含容器元素的选项。完整的容器选项列表如下

{
    type:           html element type for the container (default: span)
    scale:          [lg|2x|3x|4x|5x]
}

待办事项

请查看这里

许可证

致谢