fortifi/fontawesome

Fontawesome icon creation helper

3.4.0 2019-11-07 21:02 UTC

This package is not auto-updated.

Last update: 2024-12-15 05:21:36 UTC


README

A PHP wrapper for easy Font Awesome 5 icon creation

Example

Create Icon:

By default, FaIcon class gives access to all FontAwesome Pro icons.

$icon = FaIcon::create(FaIcon::COMMENT_SMILE);

For Free icons:

There is a helper class for accessing only free icons, using:

$icon = FaIcon::create(FaFreeIcons::ROCKET);

Create Brand Icon:

Whilst FaIcon::create(); will work for creating Brand icons, the below class static is for improved code readability of developer intent.

$brandIcon = FaBrandIcon::create(FaBrandIcon::GOOGLE);

Size options:

$icon->sizeLarge();
$icon->sizeSmall();
$icon->sizeXSmall();

$icon->sizeX1();
$icon->sizeX2();
$icon->sizeX3();
$icon->sizeX4();
$icon->sizeX5();
$icon->sizeX6();
$icon->sizeX7();
$icon->sizeX8();
$icon->sizeX9();
$icon->sizeX10();

Style options (pro only):

$icon->styleRegular();
$icon->styleLight();
$icon->styleSolid();

Transformation options:

Flip:
$icon->flip(FaFlip::VERTICAL);
$icon->flip(FaFlip::HORIZONTAL);

Multiple flips:

$icon->flip(FaFlip::VERTICAL, FaFlip::HORIZONTAL);
Shrink / Grow:
$icon->shrink(10);
$icon->grow(10);

Move:

$icon->moveUp(10);
$icon->moveDown(10);
$icon->moveLeft(10);
$icon->moveRight(10);

Mask:

$icon->mask(FaIcon::PENCIL_ALT, FaStyle::SOLID);

Animation options:

$icon->spin();
$icon->pulse();

Set tag as span (more semantic than default <i> tag):

$icon->span();

Other options:

$icon->fixedWidth();
$icon->border();
$icon->pullLeft();
$icon->pullRight();

Additional:

Icon object is created using Glimpse.

Add/remove classes:

$icon->addClass('someClass', 'anotherClass');
$icon->removeClass('remveThis', 'andThis');

Get Icon Glimpse object and apply custom attributes:

$icon->glimpse()->setId('uniqueId');
$icon->glimpse()->setAttribute('data-whatever', 'someValue');