|
| 1 | +#!/bin/bash |
| 2 | +# |
| 3 | +# @license |
| 4 | +# Copyright (c) 2014 The Polymer Project Authors. All rights reserved. |
| 5 | +# This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt |
| 6 | +# The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt |
| 7 | +# The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt |
| 8 | +# Code distributed by Google as part of the polymer project is also |
| 9 | +# subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt |
| 10 | +# |
| 11 | +set -e |
| 12 | + |
| 13 | +ICONSRC="material-design-icons/" |
| 14 | +ORIGIN="git://github.com/google/material-design-icons.git" |
| 15 | + |
| 16 | +# bootstrap a sparse SVG only checkout |
| 17 | +bootstrap() { |
| 18 | + mkdir -p ${ICONSRC} |
| 19 | + pushd ${ICONSRC} |
| 20 | + git init |
| 21 | + git config core.sparsecheckout true |
| 22 | + echo "*/svg/*_24px.svg" >> .git/info/sparse-checkout |
| 23 | + git remote add -f origin ${ORIGIN} |
| 24 | + popd |
| 25 | +} |
| 26 | + |
| 27 | +header() { |
| 28 | +cat > $1 <<ENDL |
| 29 | +<!-- |
| 30 | +Copyright (c) 2014 The Polymer Project Authors. All rights reserved. |
| 31 | +This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt |
| 32 | +The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt |
| 33 | +The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt |
| 34 | +Code distributed by Google as part of the polymer project is also |
| 35 | +subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt |
| 36 | +--> |
| 37 | +
|
| 38 | +<link rel="import" href="../core-icon/core-icon.html"> |
| 39 | +<link rel="import" href="../core-iconset-svg/core-iconset-svg.html"> |
| 40 | +<core-iconset-svg id="$2" iconSize="24"> |
| 41 | +<svg><defs> |
| 42 | +ENDL |
| 43 | +} |
| 44 | + |
| 45 | +footer(){ |
| 46 | +cat >> $1 <<ENDL |
| 47 | +</defs></svg> |
| 48 | +</core-iconset-svg> |
| 49 | +ENDL |
| 50 | +} |
| 51 | + |
| 52 | +contains() { |
| 53 | + local e |
| 54 | + for e in "${@:2}"; do [[ "$e" == "$1" ]] && return 0; done |
| 55 | + return 1; |
| 56 | +} |
| 57 | + |
| 58 | +build() { |
| 59 | +# dirname of path to current script |
| 60 | +local runfrom="${0%[/\\]*}" |
| 61 | +local folder="$1" |
| 62 | + |
| 63 | +# put these sets into one big "icons" set |
| 64 | +local default=(action alert content file navigation toggle) |
| 65 | + |
| 66 | +local name="icons" |
| 67 | +local file="../core-icons.html" |
| 68 | + |
| 69 | +# special docs header for core-icons.html |
| 70 | +cat > $file <<'ENDL' |
| 71 | +<!-- |
| 72 | +Copyright (c) 2014 The Polymer Project Authors. All rights reserved. |
| 73 | +This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt |
| 74 | +The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt |
| 75 | +The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt |
| 76 | +Code distributed by Google as part of the polymer project is also |
| 77 | +subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt |
| 78 | +--> |
| 79 | +<!-- |
| 80 | +
|
| 81 | +`core-icons` is a utitliy import that includes the definition for the `core-icon` element, `core-iconset-svg` element, as well as an import for the default icon set. |
| 82 | +
|
| 83 | +The `core-icons` directory also includes imports for additional icon sets that can be loaded into your project. |
| 84 | +
|
| 85 | +Example loading icon set: |
| 86 | +
|
| 87 | + <link rel="import" href="../core-icons/maps-icons.html"> |
| 88 | +
|
| 89 | +To use an icon from one of these sets, first prefix your `core-icon` with the icon set name, followed by a colon, ":", and then the icon id. |
| 90 | +
|
| 91 | +Example using the directions-bus icon from the maps icon set: |
| 92 | +
|
| 93 | + <core-icon icon="maps:directions-bus"></core-icon> |
| 94 | +
|
| 95 | +
|
| 96 | +See [core-icon](#core-icon) for more information about working with icons. |
| 97 | +
|
| 98 | +See [core-iconset](#core-iconset) and [core-iconset-svg](#core-iconset-svg) for more information about how to create a custom iconset. |
| 99 | +
|
| 100 | +@group Polymer Core Elements |
| 101 | +@element core-icons |
| 102 | +@homepage polymer.github.io |
| 103 | +--> |
| 104 | +<link rel="import" href="../core-icon/core-icon.html"> |
| 105 | +<link rel="import" href="../core-iconset-svg/core-iconset-svg.html"> |
| 106 | +<core-iconset-svg id="icons" iconSize="24"> |
| 107 | +<svg><defs> |
| 108 | +ENDL |
| 109 | + |
| 110 | +# find all the default icons, sort by basename (in perl), run concat |
| 111 | +find "${default[@]/#/$folder}" -name "*24px.svg" | xargs $runfrom/concat-svg.js | sort >> $file |
| 112 | + |
| 113 | +footer $file |
| 114 | + |
| 115 | +local dir |
| 116 | +for dir in $folder/*/; do |
| 117 | + if contains "`basename $dir`" "${default[@]}"; then |
| 118 | + continue |
| 119 | + fi |
| 120 | + echo $dir |
| 121 | + name=`basename $dir` |
| 122 | + file="../$name-icons.html" |
| 123 | + header $file $name |
| 124 | + find $dir -name "*24px.svg" | xargs $runfrom/concat-svg.js | sort >> $file |
| 125 | + footer $file |
| 126 | +done |
| 127 | +} |
| 128 | + |
| 129 | +[ -d ${ICONSRC} ] || bootstrap |
| 130 | + |
| 131 | +pushd ${ICONSRC} |
| 132 | +git pull origin master |
| 133 | +popd |
| 134 | + |
| 135 | +pushd util |
| 136 | +npm install |
| 137 | +build ../${ICONSRC} |
| 138 | +popd |
0 commit comments