hiz-grup/blade-icomoon

一个易于在Laravel Blade视图中使用"IcoMoon"的包。

1.2.0 2024-09-16 04:13 UTC

This package is not auto-updated.

Last update: 2024-10-01 02:40:05 UTC


README

blade-icomoon.png

Blade IcoMoon

Latest Version on Packagist GitHub Tests Action Status GitHub Code Style Action Status Total Downloads

一个易于在Laravel Blade视图中使用IcoMoon的包。

查看完整图标列表,请参阅SVG目录

要求

  • PHP 7.4或更高版本
  • Laravel 8.0或更高版本

安装

您可以通过composer安装此包

composer require nerdroid23/blade-icomoon

配置

Blade IcoMoon还提供了使用Blade Icons功能的能力,如默认类、默认属性等。如果您想配置这些,请发布blade-icomoon.php配置文件

您可以使用以下命令发布配置文件

php artisan vendor:publish --provider="Nerdroid23\BladeIcomoon\BladeIcomoonServiceProvider" --tag="blade-icomoon-config"

这是发布配置文件的内容

return [

    /*
    |-----------------------------------------------------------------
    | Default Prefix
    |-----------------------------------------------------------------
    |
    | This config option allows you to define a default prefix for
    | your icons. The dash separator will be applied automatically
    | to every icon name. It's required and needs to be unique.
    |
    */

    'prefix' => 'icomoon',

    /*
    |-----------------------------------------------------------------
    | Fallback Icon
    |-----------------------------------------------------------------
    |
    | This config option allows you to define a fallback
    | icon when an icon in this set cannot be found.
    |
    */

    'fallback' => '',

    /*
    |-----------------------------------------------------------------
    | Default Set Classes
    |-----------------------------------------------------------------
    |
    | This config option allows you to define some classes which
    | will be applied by default to all icons within this set.
    |
    */

    'class' => '',

    /*
    |-----------------------------------------------------------------
    | Default Set Attributes
    |-----------------------------------------------------------------
    |
    | This config option allows you to define some attributes which
    | will be applied by default to all icons within this set.
    |
    */

    'attributes' => [
        // 'fill'   => 'currentColor',
        // 'width'  => 32,
        // 'height' => 32,
    ],

];

使用方法

图标可以作为自闭合的Blade组件使用,将被编译为SVG图标

<x-icomoon-500px />

您还可以向图标组件传递类

<x-icomoon-500px class="w-6 h-6 text-red-500" />

并且还可以使用内联样式

<x-icomoon-500px style="color: red" />

原始SVG图标

如果您想将原始SVG图标作为资产使用,您可以使用以下命令发布它们

php artisan vendor:publish --tag=blade-icomoon-icons --force

然后在视图中使用它们,如下所示

<img src="{{ asset('vendor/blade-icomoon/500px.svg') }}" width="24" height="24"/>

Blade Icons

Blade IcoMoon底层使用Blade Icons。有关附加功能的详细信息,请参阅Blade Icons的README

测试

composer test

变更日志

有关最近更改的更多信息,请参阅CHANGELOG

贡献

有关详细信息,请参阅CONTRIBUTING

安全漏洞

有关报告安全漏洞的详细信息,请参阅我们的安全策略

致谢

许可证

MIT许可证(MIT)。有关更多信息,请参阅许可证文件