Skip to content

Remove javascript #30

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Apr 8, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 6 additions & 8 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
/.github/ export-ignore
/bin/ export-ignore
/tests/ export-ignore
/.editorconfig export-ignore
/.gitattributes export-ignore
/.gitignore export-ignore
/package.json export-ignore
/package-lock.json export-ignore
/.github/ export-ignore
/bin/ export-ignore
/tests/ export-ignore
/.editorconfig export-ignore
/.gitattributes export-ignore
/.gitignore export-ignore
78 changes: 0 additions & 78 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,80 +1,2 @@
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*

# Runtime data
pids
*.pid
*.seed
*.pid.lock

# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov

# Coverage directory used by tools like istanbul
coverage

# nyc test coverage
.nyc_output

# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
.grunt

# Bower dependency directory (https://bower.io/)
bower_components

# node-waf configuration
.lock-wscript

# Compiled binary addons (https://nodejs.org/api/addons.html)
build/Release

# Dependency directories
node_modules/
jspm_packages/

# TypeScript v1 declaration files
typings/

# Optional npm cache directory
.npm

# Optional eslint cache
.eslintcache

# Optional REPL history
.node_repl_history

# Output of 'npm pack'
*.tgz

# Yarn Integrity file
.yarn-integrity

# dotenv environment variables file
.env

# parcel-bundler cache (https://parceljs.org/)
.cache

# next.js build output
.next

# nuxt.js build output
.nuxt

# vuepress build output
.vuepress/dist

# Serverless directories
.serverless

# FuseBox cache
.fusebox/

/vendor/
/composer.lock
/composer.phar
31 changes: 0 additions & 31 deletions bin/build.js

This file was deleted.

96 changes: 85 additions & 11 deletions bin/build.php
Original file line number Diff line number Diff line change
@@ -1,23 +1,97 @@
<?php

$rootDir = implode(DIRECTORY_SEPARATOR, [dirname(__FILE__), '..']);
function getSvgAttributes(string $svg): array
{
$attributes = [];

$icons = [];
$icon = new SimpleXMLElement($svg);

$xmlNamespaces = $icon->getDocNamespaces();

$attributes['xmlns'] = array_shift($xmlNamespaces);

foreach ($icon->attributes() as $attribute => $value) {
$attributes[(string)$attribute] = (string)$value;
}

unset($attributes['class']);

return $attributes;
}

function getSvgContents(string $svg): string
{
$icon = new SimpleXMLElement($svg);

$doc = new DOMDocument('1.0', 'UTF-8');

$dom = dom_import_simplexml($icon);
$dom = $doc->importNode($dom, true);

$doc->appendChild($dom);

$svgContents = '';

foreach ($doc->getElementsByTagName('svg')[0]->childNodes as $node) {
$svgContents .= $doc->saveXML($node, LIBXML_NOEMPTYTAG);
}

return $svgContents;
}

function writeAttributes(array $attributes): void
{
global $rootDir;

$export = var_export($attributes, true);

foreach (glob(implode(DIRECTORY_SEPARATOR, [$rootDir, 'icons', '*.svg'])) as $file) {
$iconName = preg_replace('/\.svg$/i', '', basename($file));
$iconContents = file_get_contents($file);
file_put_contents(
implode(DIRECTORY_SEPARATOR, [$rootDir, 'src', 'defaultAttributes.php']),
<<<EOT
<?php

/* !!! THIS FILE IS AUTO-GENERATED !!! */

namespace Feather;

$icons[$iconName] = $iconContents;
const DEFAULT_ATTRIBUTES = $export;

EOT
);
}

$export = var_export($icons, true);
function writeIcons(array $icons): void
{
global $rootDir;

file_put_contents(
implode(DIRECTORY_SEPARATOR, [$rootDir, 'resources', 'icons.php']),
<<<EOT
$export = var_export($icons, true);

file_put_contents(
implode(DIRECTORY_SEPARATOR, [$rootDir, 'resources', 'icons.php']),
<<<EOT
<?php

return $export;

EOT
);
);
}

$rootDir = implode(DIRECTORY_SEPARATOR, [dirname(__FILE__), '..']);

$icons = [];

$defaultAttributes = null;

foreach (glob(implode(DIRECTORY_SEPARATOR, [$rootDir, 'vendor', 'npm-asset', 'feather-icons', 'dist', 'icons', '*.svg'])) as $file) {
$iconName = preg_replace('/\.svg$/i', '', basename($file));

if (null === $defaultAttributes) {
$defaultAttributes = getSvgAttributes(file_get_contents($file));
}

$icons[$iconName] = getSvgContents(file_get_contents($file));
}

writeAttributes($defaultAttributes);
writeIcons($icons);
12 changes: 11 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,22 @@
"Feather\\": "src/"
}
},
"repositories": [
{
"type": "composer",
"url": "https://asset-packagist.org"
}
],
"require": {
"php": ">=7.3"
},
"require-dev": {
"ext-dom": "*",
"ext-json": "*",
"phpunit/phpunit": "^9.5"
"ext-libxml": "*",
"ext-simplexml": "*",
"phpunit/phpunit": "^9.5",
"npm-asset/feather-icons": "4.26.0"
},
"scripts": {
"test": "phpunit --verbose tests"
Expand Down
1 change: 0 additions & 1 deletion icons/activity.svg

This file was deleted.

1 change: 0 additions & 1 deletion icons/airplay.svg

This file was deleted.

1 change: 0 additions & 1 deletion icons/alert-circle.svg

This file was deleted.

1 change: 0 additions & 1 deletion icons/alert-octagon.svg

This file was deleted.

1 change: 0 additions & 1 deletion icons/alert-triangle.svg

This file was deleted.

1 change: 0 additions & 1 deletion icons/align-center.svg

This file was deleted.

1 change: 0 additions & 1 deletion icons/align-justify.svg

This file was deleted.

1 change: 0 additions & 1 deletion icons/align-left.svg

This file was deleted.

1 change: 0 additions & 1 deletion icons/align-right.svg

This file was deleted.

1 change: 0 additions & 1 deletion icons/anchor.svg

This file was deleted.

1 change: 0 additions & 1 deletion icons/aperture.svg

This file was deleted.

1 change: 0 additions & 1 deletion icons/archive.svg

This file was deleted.

1 change: 0 additions & 1 deletion icons/arrow-down-circle.svg

This file was deleted.

1 change: 0 additions & 1 deletion icons/arrow-down-left.svg

This file was deleted.

1 change: 0 additions & 1 deletion icons/arrow-down-right.svg

This file was deleted.

1 change: 0 additions & 1 deletion icons/arrow-down.svg

This file was deleted.

1 change: 0 additions & 1 deletion icons/arrow-left-circle.svg

This file was deleted.

1 change: 0 additions & 1 deletion icons/arrow-left.svg

This file was deleted.

1 change: 0 additions & 1 deletion icons/arrow-right-circle.svg

This file was deleted.

1 change: 0 additions & 1 deletion icons/arrow-right.svg

This file was deleted.

1 change: 0 additions & 1 deletion icons/arrow-up-circle.svg

This file was deleted.

1 change: 0 additions & 1 deletion icons/arrow-up-left.svg

This file was deleted.

1 change: 0 additions & 1 deletion icons/arrow-up-right.svg

This file was deleted.

1 change: 0 additions & 1 deletion icons/arrow-up.svg

This file was deleted.

1 change: 0 additions & 1 deletion icons/at-sign.svg

This file was deleted.

1 change: 0 additions & 1 deletion icons/award.svg
Diff not rendered.
1 change: 0 additions & 1 deletion icons/bar-chart-2.svg
Diff not rendered.
1 change: 0 additions & 1 deletion icons/bar-chart.svg
Diff not rendered.
1 change: 0 additions & 1 deletion icons/battery-charging.svg
Diff not rendered.
1 change: 0 additions & 1 deletion icons/battery.svg
Diff not rendered.
1 change: 0 additions & 1 deletion icons/bell-off.svg
Diff not rendered.
1 change: 0 additions & 1 deletion icons/bell.svg
Diff not rendered.
1 change: 0 additions & 1 deletion icons/bluetooth.svg
Diff not rendered.
1 change: 0 additions & 1 deletion icons/bold.svg
Diff not rendered.
1 change: 0 additions & 1 deletion icons/book-open.svg
Diff not rendered.
1 change: 0 additions & 1 deletion icons/book.svg
Diff not rendered.
1 change: 0 additions & 1 deletion icons/bookmark.svg
Diff not rendered.
1 change: 0 additions & 1 deletion icons/box.svg
Diff not rendered.
1 change: 0 additions & 1 deletion icons/briefcase.svg
Diff not rendered.
1 change: 0 additions & 1 deletion icons/calendar.svg
Diff not rendered.
1 change: 0 additions & 1 deletion icons/camera-off.svg
Diff not rendered.
1 change: 0 additions & 1 deletion icons/camera.svg
Diff not rendered.
1 change: 0 additions & 1 deletion icons/cast.svg
Diff not rendered.
1 change: 0 additions & 1 deletion icons/check-circle.svg
Diff not rendered.
1 change: 0 additions & 1 deletion icons/check-square.svg
Diff not rendered.
1 change: 0 additions & 1 deletion icons/check.svg
Diff not rendered.
Loading