codeat3 / blade-icon-generation-helpers
codeat3's helper methods to use in blade-icon generation scripts
Fund package maintenance!
swapnilsarwe
Installs: 70 886
Dependents: 59
Suggesters: 0
Security: 0
Stars: 0
Watchers: 1
Forks: 2
Open Issues: 0
pkg:composer/codeat3/blade-icon-generation-helpers
Requires
- codeat3/inlinestyle: ^2.0
- codeat3/laravel-page-speed: 2.2
- illuminate/support: ^8.0|^9.0|^10.0
- symfony/filesystem: ^5.0|^6.0
- symfony/process: ^5.0|^6.0
Requires (Dev)
- codeat3/phpcs-styles: ^1.0
README
A helper package to convert the icons to make it compatible to be used with the blade-icons package.
Installation
composer require codeat3/blade-icon-generation-helpers
Usage
Kindly refer the Generating Icons section from Blade Icons. This Package utilizes the after callback to process the icons as per our need.
The after callback received 3 arguments string $icon - this is the pathname of the icon, array $config - the config specified in the generation.php & SplFileInfo $file - the original icon file instance.
Inside a callback we instantiate our Processor class & use its helper methods to our benefit.
$iconProcessor = new IconProcessor($icon, $config, $sourceFile);
This IconProcessor instance itself does some optimization on its own by default. Minimal usage would be as follows.
$iconProcessor = new IconProcessor($icon, $config, $sourceFile); $iconProcessor ->optimize() ->save();
The optimize method does the following things by default:
- it removes the following attributes from the svg
- 'width', 'height', 'class', 'style', 'id',
- if in the config provided
is-outlineis set astrue- if
fillattribute exists - it will updated tonone - if
strokeattribute exists - it will updated tocurrentColor
- if
- if in the config provided
is-solidis set astrue- if
fillattribute exists - it will updated tocurrentColor
- if
- if in the config provided
custom-attributesis set`- it will set the attributes to the svg
- optionally it provides 2 callable methods
pre&post- both callback receives the
$svgELas theDOMDocument- its the DOMDocument instance of the current icon precan be used if you have to perform some operation before Processor does the default processingpostcan be used if you have to perform some operation after Processor does the default processing
- both callback receives the
The save method