diff options
Diffstat (limited to 'vendor/mervick/material-design-icons/scripts')
-rw-r--r-- | vendor/mervick/material-design-icons/scripts/codepoints2scss.sh | 30 | ||||
-rw-r--r-- | vendor/mervick/material-design-icons/scripts/updatedemo.php | 61 |
2 files changed, 91 insertions, 0 deletions
diff --git a/vendor/mervick/material-design-icons/scripts/codepoints2scss.sh b/vendor/mervick/material-design-icons/scripts/codepoints2scss.sh new file mode 100644 index 000000000..e89e68eed --- /dev/null +++ b/vendor/mervick/material-design-icons/scripts/codepoints2scss.sh @@ -0,0 +1,30 @@ +#!/usr/bin/env bash + +pushd `dirname dirname $0` > /dev/null +path=`pwd` +popd > /dev/null + +codepoints_file="${path}/bower_components/material-design-icons/iconfont/codepoints" +icons_scss_file="${path}/scss/_icons.scss" + +# default css prefix +prefix_var_name="md-css-prefix" + +# clear the scss +> "${icons_scss_file}" + +i=0 +while IFS='' read -r line || [[ -n "$line" ]]; do + IFS=' ' read -r -a icon <<< "$line" + if [ "${#icon[@]}" == 2 ] && [ -n "${icon}" ] && [ -n "${icon[1]}" ]; then + echo ".#{\$${prefix_var_name}}-$(echo ${icon} | sed -e 's/_/\-/g'):before { content: "'"'"\\${icon[1]}"'"'"; }" \ + >> "${icons_scss_file}" + else + echo "ERROR: The file ${codepoints_file} has the invalid format on line $((i+1))" 1>&2 + exit 1 + fi + ((i++)) +done < "${codepoints_file}" + +echo "Successfully imported ${i} icons" +exit 0
\ No newline at end of file diff --git a/vendor/mervick/material-design-icons/scripts/updatedemo.php b/vendor/mervick/material-design-icons/scripts/updatedemo.php new file mode 100644 index 000000000..bc7411467 --- /dev/null +++ b/vendor/mervick/material-design-icons/scripts/updatedemo.php @@ -0,0 +1,61 @@ +<?php + +$path = __DIR__ . '/../bower_components/material-design-icons'; +$out = __DIR__ . '/../demo/js/data.js'; +$codepoints = __DIR__ . '/../bower_components/material-design-icons/iconfont/codepoints'; +$oldcodepoints = __DIR__ . '/../fonts/codepoints'; + +$start_js = 'window.data = '; +$end_js = ';'; + +//$categories = file_get_contents($out); +//$categories = substr(substr($categories, strlen($start_js)), 0, - strlen($end_js)); +//$categories = json_decode($categories, true); +//$categories = $categories ?: []; + +$categories = $icons = $old_icons = []; +$count = $count_cats = 0; + +foreach (file($codepoints, FILE_IGNORE_NEW_LINES) as $code) { + $code = explode(' ', $code, 2); + $icons[$code[0]] = $code[1]; +} +foreach (file($oldcodepoints, FILE_IGNORE_NEW_LINES) as $code) { + $code = explode(' ', $code, 2); + $old_icons[$code[0]] = $code[1]; +} + +foreach (array_diff(scandir($path), ['.', '..']) as $category) { + if (is_dir("$path/$category/svg/production")) { + $count_cats ++; + $categories[$category] = []; + foreach (array_diff(scandir("$path/$category/svg/production"), ['.', '..']) as $file) { + if (preg_match('/^ic_(.+?)_\d+px\.svg$/', $file, $match)) { + $icon = $match[1]; + if (isset($icons[$icon])) { + if (!in_array($icons[$icon], $categories[$category])) { + $categories[$category][$icon] = $icons[$icon]; + $count ++; + } + } + } + } + } +} + +$new = 0; + +foreach ($categories as &$category) { + foreach ($category as $icon => &$code) { + $c = $code; + $code = [$c, !isset($old_icons[$icon])]; + if (!isset($old_icons[$icon])) { + $new ++; + } + } +} + + +file_put_contents($out, $start_js . json_encode($categories) . $end_js); + +echo "Found $count icons, ($new new) in $count_cats categories\n";
\ No newline at end of file |