https://github.com/codeat3/blade-icon-generation-helpers
https://github.com/codeat3/blade-icon-generation-helpers
Last synced: about 2 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/codeat3/blade-icon-generation-helpers
- Owner: codeat3
- Created: 2021-06-29T17:44:52.000Z (almost 4 years ago)
- Default Branch: 0.x
- Last Pushed: 2024-02-28T09:48:00.000Z (about 1 year ago)
- Last Synced: 2024-05-03T04:00:06.884Z (about 1 year ago)
- Language: PHP
- Size: 24.4 KB
- Stars: 0
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Funding: .github/FUNDING.yml
Awesome Lists containing this project
README
## Blade Icon Generation Helpers
A helper package to convert the icons to make it compatible to be used with the `blade-icons` package.### Installation
```php
composer require codeat3/blade-icon-generation-helpers
```### Usage
Kindly refer the [Generating Icons](https://github.com/blade-ui-kit/blade-icons#generating-icons) section from [Blade Icons](https://github.com/blade-ui-kit/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.
```php
$iconProcessor = new IconProcessor($icon, $config, $sourceFile);
```This `IconProcessor` instance itself does some optimization on its own by default. Minimal usage would be as follows.
```php
$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-outline` is set as `true`
- if `fill` attribute exists - it will updated to `none`
- if `stroke` attribute exists - it will updated to `currentColor`
* if in the config provided `is-solid` is set as `true`
- if `fill` attribute exists - it will updated to `currentColor`
* if in the config provided `custom-attributes` is set`
- it will set the attributes to the svg
* optionally it provides 2 callable methods `pre` & `post`
- both callback receives the `$svgEL` as the `DOMDocument` - its the DOMDocument instance of the current icon
- `pre` can be used if you have to perform some operation before Processor does the default processing
- `post` can be used if you have to perform some operation after Processor does the default processingThe `save` method