nerdroid23/blade-icomoon

A package to easily make use of "IcoMoon" in your Laravel Blade views.

Fund package maintenance!
nerdroid23

1.1.0 2023-06-28 12:35 UTC

This package is auto-updated.

Last update: 2024-03-28 14:12:56 UTC


README

blade-icomoon.png

Blade IcoMoon

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

A package to easily make use of IcoMoon in your Laravel Blade views.

For a full list of available icons see the SVG directory.

Requirements

  • PHP 7.4 or higher
  • Laravel 8.0 or higher

Install

You can install the package via composer:

composer require nerdroid23/blade-icomoon

Configuration

Blade IcoMoon also offers the ability to use features from Blade Icons like default classes, default attributes, etc. If you'd like to configure these, publish the blade-icomoon.php config file:

You can publish the config file with:

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

This is the contents of the published config file:

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,
    ],

];

Usage

Icons can be used a self-closing Blade components which will be compiled to SVG icons:

<x-icomoon-500px />

You can also pass classes to your icon components:

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

And even use inline styles:

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

Raw SVG Icons

If you want to use the raw SVG icons as assets, you can publish them using:

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

Then use them in your views like:

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

Blade Icons

Blade IcoMoon uses Blade Icons under the hood. Please refer to the Blade Icons readme for additional functionality.

Testing

composer test

Changelog

Please see CHANGELOG for more information on what has changed recently.

Contributing

Please see CONTRIBUTING for details.

Security Vulnerabilities

Please review our security policy on how to report security vulnerabilities.

Credits

License

The MIT License (MIT). Please see License File for more information.