承接 rasteiner/k3-awesome-picker 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

rasteiner/k3-awesome-picker

Composer 安装命令:

composer require rasteiner/k3-awesome-picker

包简介

Kirby 3 panel field that lets you choose a (free) icon from Font Awesome

README 文档

README

Animation showing the plugin in action

Show and pick a free Font Awesome icon.

Install

Download Zip file

Copy plugin folder into site/plugins

Composer

Run composer require rasteiner/k3-awesome-picker.

Usage

Add an icon field to your blueprint. You can also choose to filter the available icons by declaring the wanted styles: brands (Logos), solid (filled icons), regular (outlined icons)

In your template you will get the class names for the chosen icon.

Example

Blueprint:

fields:
  myIcon:
    label: My Icon
    type: icon
    styles: 
      - brands 
      - solid

Template:

<script src="https://kit.fontawesome.com/<yourkit>.js" crossorigin="anonymous"></script>

This is the chosen icon: <i class="<?= $page->icon() ?>"></i>

Config options

Under the rasteiner.awesome-picker namespace, you'll have access to the following options:

option default description
'css-url' 'https://kit-free.fontawesome.com/releases/latest/css/free.min.css' Used in the panel, the URL to the font awesome CSS
'meta-source' 'github' File path, or function returning the file path, to the "icons.yml" file containing all metadata of the icons. The default setting of 'github' downloads the metadata from github on first usage, then it stores the file on the server
'sprites-folder' false Useful when using the SVG setup (see below). Path, or function returning the path, to the sprites folder
'default-styles' ["solid", "regular", "brands", "light", "duotone"] Array or string for which styles should be available when the styles setting in your blueprint isn't used
'loaded-styles' ["solid", "regular", "brands", "light", "duotone"] Array or string for which styles should ever be available for use

SVG setup

If you prefer having your icons embedded in your page and use them via SVG links, this plugin offers you a way to manage this, but you need to prepare it for the use case.

  1. Download your icons
    Font Awesome gives you the option to download their icons. Download the "web" version from here: https://fontawesome.com/download. Unzip the file and upload it to your server.

  2. Configure the plugin
    The plugin needs to know 3 things:

    1. The URL to the CSS file with all classes you intend to use (this is used only for the panel, you'll find them in the css folder you downloaded)
    2. The file path to the metadata of your icons (you'll find this in the "metadata" folder, look for an "icons.yml" file)
    3. The file path to the folder containing the sprite sheets (this is the "sprites" folder)

    Here's an example config:

    <?php
    
    return [
        'rasteiner.awesome-picker' => [
            'css-url' => function() {
                return url('assets/fontawesome-free-5.15.1-web/css/all.min.css');
            },
            'meta-source' => 'assets/fontawesome-free-5.15.1-web/metadata/icons.yml',
            'sprites-folder' => 'assets/fontawesome-free-5.15.1-web/sprites',
        ]
    ];

    You can assign all those config options either a string, or a function that returns a string.

  3. Adapt the templates
    Linked svg icons need 2 steps to work:

    1. Use the icons, via the <use xlink:href="#icon-id"> tag
    2. Embed all used icons in the page, via many <symbol id="icon-id"> tags

    This plugin offers you some functions to help you do this, it tracks which icons have been used, and then injects all used items as symbols. To do this, you'll use the following methods:

    1. the $field->toIcon() field method. This gives you an "Icon" object
    2. the $icon->use($attrs) method of the Icon object, this gives you an svg element containing a corresponding <use> tag. This method optionally lets you specify the attributes given to the <svg> tag.
    3. the $site->iconSymbols() method which generates an svg element containing all previously used icons as <symbol> elements.

    Here's a short example template:

    <!-- in your page -->
    <?= $page->myIcon()->toIcon()->use(['class' => 'my-icon-css-class']) ?>
    
    <!-- bottom of your page -->
    <?= $site->iconSymbols() ?>

    This will output something like this:

    <!-- in your page -->
    <svg class="my-icon-css-class"><use xlink:href="#fas-cloud-sun"></use></svg>
    
    <!-- bottom of your page -->
    <svg xmlns="http://www.w3.org/2000/svg" width="0" height="0" style="display: none;">
      <symbol id="fas-cloud-sun" viewBox="0 0 640 512">
        <path d="..." />
      </symbol>
    </svg>

    Notice: you need to call $site->iconSymbols() after all $icon->use() calls. So either put the symbols at the end of the page, or output buffer your page.

rasteiner/k3-awesome-picker 适用场景与选型建议

rasteiner/k3-awesome-picker 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 386 次下载、GitHub Stars 达 16, 最近一次更新时间为 2020 年 10 月 13 日, 在 PHP 生态内属于活跃度较高的组件。

我们在过去多个企业项目中使用过 rasteiner/k3-awesome-picker 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 rasteiner/k3-awesome-picker 我们能提供哪些服务?
定制开发 / 二次开发

基于 rasteiner/k3-awesome-picker 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 386
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 16
  • 点击次数: 4
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 16
  • Watchers: 3
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2020-10-13