Skip to content

Commit

Permalink
added auto update generation script (#4)
Browse files Browse the repository at this point in the history
* added auto update generation script

* fixes tests
  • Loading branch information
swapnilsarwe authored Mar 10, 2023
1 parent 4b912fc commit 0250721
Show file tree
Hide file tree
Showing 311 changed files with 384 additions and 310 deletions.
1 change: 1 addition & 0 deletions .commit
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
bdcfcda5700b931b436dd665df7f3ed544da3a96
2 changes: 2 additions & 0 deletions .env
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
REPOSITORY=dovy/elusive-icons
BRANCH=master
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,5 @@ composer.lock
phpunit.xml
.php-cs-fixer.cache
package-lock.json
.php_cs.cache
dist/
1 change: 0 additions & 1 deletion .php_cs.cache

This file was deleted.

73 changes: 71 additions & 2 deletions config/generation.php
100755 → 100644
Original file line number Diff line number Diff line change
@@ -1,8 +1,77 @@
<?php

use Codeat3\BladeIconGeneration\IconProcessor;

$svgNormalization = static function (string $tempFilepath, array $iconSet) {

$attrsToRemove = [
'sodipodi:docname',
'version',
'docname',
'enable-background',
'x',
'y'
];
$nsAttrsToRemove = [
'dc' => 'http://purl.org/dc/elements/1.1/',
'cc' => 'http://creativecommons.org/ns#',
'rdf' => 'http://www.w3.org/1999/02/22-rdf-syntax-ns#',
'svg' => 'http://www.w3.org/2000/svg',
'sodipodi' => 'http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd',
'inkscape' => 'http://www.inkscape.org/namespaces/inkscape',
'xlink' => 'http://www.w3.org/1999/xlink',
'version' => '0.48.4 r9939'
];

// perform generic optimizations
$iconProcessor = new IconProcessor($tempFilepath, $iconSet);
$iconProcessor
->optimize(pre: function (&$svgEl) use ($attrsToRemove, $nsAttrsToRemove) {
foreach ($svgEl->attributes as $att) { // get the attributes
if (in_array($att->nodeName, $attrsToRemove)) {
$svgEl->removeAttributeNode($att); //remove the attribute
$svgEl->removeAttribute($att->nodeName); //remove the attribute
}
}

foreach ($nsAttrsToRemove as $nk => $nv) {
$svgEl->removeAttributeNS($nv, $nk);
}


$namedview = $svgEl->getElementsByTagName('namedview');
if ($namedview && $namedview[0]) {
$svgEl->removeChild($namedview[0]);
}


})
->postOptimizationAsString(function ($svgLine) {
$svgLine = str_replace('<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">', '', $svgLine);
return $svgLine;
// $replacePattern = [
// '/<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">/s' => '',
// ];
// return preg_replace(array_keys($replacePattern), array_values($replacePattern), $svgLine);
})
->save();
};

return [
[
'source' => null,
'destination' => __DIR__.'/../resources/svg',
// Define a source directory for the sets like a node_modules/ or vendor/ directory...
'source' => __DIR__ . '/../dist/dev/icons-svg',

// Define a destination directory for your icons. The below is a good default...
'destination' => __DIR__ . '/../resources/svg',

// Enable "safe" mode which will prevent deletion of old icons...
'safe' => false,

// Call an optional callback to manipulate the icon
// with the pathname of the icon and the settings from above...
'after' => $svgNormalization,

'is-solid' => true,
],
];
1 change: 1 addition & 0 deletions dist
Submodule dist added at 5ddd91
2 changes: 1 addition & 1 deletion resources/svg/address-book-alt.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion resources/svg/address-book.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion resources/svg/adjust-alt.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion resources/svg/adjust.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion resources/svg/adult.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion resources/svg/align-center.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion resources/svg/align-justify.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion resources/svg/align-left.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion resources/svg/align-right.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion resources/svg/arrow-down.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion resources/svg/arrow-left.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion resources/svg/arrow-right.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion resources/svg/arrow-up.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit 0250721

Please sign in to comment.