goldfinch/icon-field

Advanced Icon Field for Silverstripe

Installs: 152

Dependents: 1

Suggesters: 0

Security: 0

Stars: 0

Watchers: 1

Forks: 0

Open Issues: 0

Type:silverstripe-vendormodule

v2.0.4 2024-03-11 11:55 UTC

This package is auto-updated.

Last update: 2024-05-11 12:34:22 UTC


README

Silverstripe Version Package Version Total Downloads License

Advanced Icon Field for Silverstripe. It can handle up to 4 different types of icon sources:

  • font icons (css file)
  • directory (icons within specific folder)
  • upload folder (folder through SilverStripe assets module)
  • json (source file)

Install

composer require goldfinch/icon-field

Available Taz commands

If you haven't used Taz🌪️ before, taz file must be presented in your root project folder cp vendor/goldfinch/taz/taz taz

Add new icon set

php taz iconset

Publish icon templates

php taz vendor:icon-field:templates

Usage

use Goldfinch\IconField\Forms\IconField;

class Page
{
    private static $db = [
        'Icon' => 'Icon',
    ];

    public function getCMSFields()
    {
        $fields = parent::getCMSFields();

        $fields->insertBefore('Content', IconField::create('icon_set_name', 'Icon'));
    }
}
<!-- template.ss -->

$Icon
$Icon.Key
$Icon.Size(100).Color(green)
$Icon.URL
$Icon.Title
$Icon.IconSetName
$Icon.IconType

Vite support

If you use Vite as a front-end build tool, you might want to include a dynamic vite link as a source for your icons. Easy, just use prefix vite: followed by relative path to the file of your build, as you have it in your vite.config.js.

example:

Goldfinch\IconField\Forms\IconField:
  icons_sets:
    my_icons_set:
      type: font
      source: 'vite:themes/main/src/icons.scss'

License

The MIT License (MIT)