├── .jenkins ├── .gitignore ├── public ├── favicon.ico ├── test-svg │ ├── flag.png │ ├── arrow-11.svg │ ├── arrow-tiny.svg │ ├── cat.svg │ ├── star.svg │ ├── grunticon.svg │ ├── plus.svg │ ├── bear.svg │ ├── bear.colors-blue-primary-aa0000.svg │ ├── map.svg │ ├── gradients-flat-opacity.svg │ ├── gradients.svg │ ├── gear.svg │ ├── gummy-bears-1.svg │ ├── gummy-bears-2.svg │ ├── Home_Media.svg │ ├── Internet_Tel.svg │ ├── Internet-no-width-no-height.svg │ ├── Internet.svg │ ├── Internet_FP2.svg │ ├── Image_Exchange.svg │ └── Intranet.svg ├── img │ └── logo_filament-group.png ├── js │ ├── download │ │ ├── download-view.js │ │ └── download-button-view.js │ ├── preview │ │ ├── count-view.js │ │ ├── css-preview-view.js │ │ ├── list-view.js │ │ ├── html-preview-view.js │ │ └── results-view.js │ ├── utils │ │ ├── createImage.js │ │ ├── readFile.js │ │ └── colorfy.js │ ├── base │ │ ├── base-view.js │ │ └── toggle-view.js │ ├── svgs │ │ ├── svg-collection.js │ │ ├── upload-view.js │ │ └── svg-model.js │ ├── config │ │ ├── config-view.js │ │ └── config-model.js │ ├── app.js │ └── modernizr.js ├── dist │ └── main.css └── css │ └── main.css ├── .travis.yml ├── templates ├── example-html.html ├── svg-icons.html ├── file-previews.html ├── script-html.html └── preferences.html ├── .jshintrc ├── LICENSE ├── package.json ├── README.md ├── Gruntfile.js └── index.html /.jenkins: -------------------------------------------------------------------------------- 1 | user: NONE 2 | subdir: . 3 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | /node_modules/ 2 | public/lib/ 3 | 4 | .DS_Store 5 | Thumbs.db 6 | .vagrant 7 | -------------------------------------------------------------------------------- /public/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/filamentgroup/grumpicon/HEAD/public/favicon.ico -------------------------------------------------------------------------------- /public/test-svg/flag.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/filamentgroup/grumpicon/HEAD/public/test-svg/flag.png -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: node_js 2 | node_js: 3 | - 0.10 4 | before_script: 5 | - npm install -g grunt-cli 6 | -------------------------------------------------------------------------------- /public/img/logo_filament-group.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/filamentgroup/grumpicon/HEAD/public/img/logo_filament-group.png -------------------------------------------------------------------------------- /templates/example-html.html: -------------------------------------------------------------------------------- 1 | 2 |
{{ cssprefix }}{{ name }}:Grumpiconfig saved in localStorage. Reset to factory setting.
See the grunticon options for the deets.
26 |* colors must be set before dropping SVGs.
27 | 28 | Close -------------------------------------------------------------------------------- /public/js/download/download-button-view.js: -------------------------------------------------------------------------------- 1 | import DownloadView from "./download-view.js"; 2 | import Handlebars from "handlebars"; 3 | import template from "./../templates.js"; 4 | import JSZip from "jszip"; 5 | import _ from "underscore"; 6 | import $ from "jquery"; 7 | 8 | var JST = template.call(window, Handlebars); 9 | 10 | const PNG_URI_PREFIX = "data:image/png;base64,"; 11 | const ZIP_URI_PREFIX = "data:application/zip;base64,"; 12 | 13 | /** 14 | * create a zip file and attach it to the download button 15 | */ 16 | export default class DownloadButtonView extends DownloadView { 17 | initialize(options) { 18 | this.config = options.config; 19 | super.initialize(); 20 | 21 | this.listenTo(this.config, "change", this.render); 22 | } 23 | 24 | render() { 25 | var data = this.config.toJSON(); 26 | var zip = new JSZip(); 27 | var pngs = zip.folder(data.pngfolder); 28 | var $link = this.$el.find( "#download" ); 29 | 30 | if (this.collection.length) { 31 | 32 | // add each fallback png to the png folder 33 | this.collection.each(model => { 34 | pngs.file(model.get("name") + ".png", 35 | model.get("pngDataUri").replace(PNG_URI_PREFIX, "") + "\n", 36 | {base64: true}); 37 | }); 38 | 39 | // get the file previews and save them as actual files in the zip 40 | zip.file(data.datasvgcss, $("#svg-css-results").text()); 41 | zip.file(data.datapngcss, $("#png-css-results").text()); 42 | zip.file(data.urlpngcss, $("#fallback-css-results").text()); 43 | zip.file(data.loadersnippet, $("#js-results").text()); 44 | zip.file("preview.html", _.unescape($("#preview-html").html())); 45 | 46 | if( Modernizr.adownload && ( window.URL && window.URL.createObjectURL ) ){ 47 | let blob = zip.generate({ type: "blob" }); 48 | 49 | $link.attr({ 50 | href: window.URL.createObjectURL(blob), 51 | download: "grunticon.zip" 52 | }); 53 | } else { 54 | let blob = zip.generate(); 55 | 56 | $link.on("click", e => { 57 | e.preventDefault(); 58 | location.href = ZIP_URI_PREFIX + blob; 59 | }); 60 | } 61 | 62 | this.$el.fadeIn(); 63 | } 64 | } 65 | } -------------------------------------------------------------------------------- /public/test-svg/map.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 34 | -------------------------------------------------------------------------------- /public/js/config/config-model.js: -------------------------------------------------------------------------------- 1 | import {Model} from "backbone"; 2 | import _ from "underscore"; 3 | 4 | /** 5 | * A model that stores all of the grumpiconfigs 6 | */ 7 | export default class ConfigModel extends Model { 8 | /* config from grunticon */ 9 | defaults() { 10 | return { 11 | datasvgcss: "icons.data.svg.css", 12 | datapngcss: "icons.data.png.css", 13 | urlpngcss: "icons.fallback.css", 14 | /*files: { 15 | loader: path.join( __dirname, 'grunticon', 'static', 'grunticon.loader.js'), 16 | embed: path.join( __dirname, 'grunticon', 'static', 'grunticon.embed.js'), 17 | corsEmbed: path.join( __dirname, 'grunticon', 'static', 'grunticon.embed.cors.js'), 18 | banner: path.join( __dirname, 'grunticon', 'static', 'grunticon.loader.banner.js') 19 | },*/ 20 | previewhtml: "preview.html", 21 | loadersnippet: "grunticon.loader.js", 22 | //cssbasepath: path.sep, 23 | customselectors: {}, 24 | cssprefix: ".icon-", 25 | //defaultWidth: "400px", 26 | //defaultHeight: "300px", 27 | colors: {}, 28 | dynamicColorOnly: false, 29 | pngfolder: "png", 30 | pngpath: "png", 31 | template: `{{#each customselectors}}{{this}},{{/each}} 32 | {{prefix}}{{name}} { 33 | background-image: url('{{datauri}}'); 34 | background-repeat: no-repeat; 35 | }` 36 | //tmpPath: os.tmpDir(), 37 | //tmpDir: "grunticon-tmp", 38 | //previewTemplate: path.join( __dirname, "..", "example", "preview.hbs" ), 39 | //compressPNG: false, 40 | //optimizationLevel: 3, 41 | //enhanceSVG: false, 42 | //corsEmbed: false 43 | }; 44 | } 45 | 46 | /** 47 | * extend the defaults with the data store in localStorage 48 | * @return {[type]} [description] 49 | */ 50 | initialize() { 51 | this.set(_.extend(this.defaults(), this.getLocalStorage())); 52 | } 53 | 54 | /** 55 | * save off the whole model to localStorage 56 | */ 57 | setLocalStorage() { 58 | this.set("fromStorage", true); 59 | localStorage.setItem("grumpiconfig", JSON.stringify(this.toJSON())); 60 | } 61 | 62 | /** 63 | * retrieve the model from localStorage 64 | * @return {Object} The model's data 65 | */ 66 | getLocalStorage() { 67 | var config = localStorage.getItem("grumpiconfig") || "{}"; 68 | config = JSON.parse(config); 69 | 70 | this.set("fromStorage", !_.isEmpty(config)); 71 | 72 | return config; 73 | } 74 | 75 | /** 76 | * clear from localStorage 77 | */ 78 | removeLocalStorage() { 79 | localStorage.removeItem("grumpiconfig"); 80 | } 81 | 82 | /** 83 | * reset the model 84 | */ 85 | setToDefault() { 86 | this.set(this.defaults()); 87 | this.set("fromStorage", false); 88 | this.removeLocalStorage(); 89 | } 90 | } -------------------------------------------------------------------------------- /Gruntfile.js: -------------------------------------------------------------------------------- 1 | 2 | module.exports = function(grunt) { 3 | "use strict"; 4 | 5 | var to5ify = require("6to5ify"); 6 | 7 | // Project configuration. 8 | grunt.initConfig({ 9 | jshint: { 10 | options: { 11 | jshintrc: ".jshintrc" 12 | }, 13 | gruntfile: { 14 | src: "Gruntfile.js" 15 | }, 16 | lib: { 17 | src: ["lib/**/*.js"] 18 | }, 19 | test: { 20 | src: ["test/**/*.js"] 21 | } 22 | }, 23 | handlebars: { 24 | compile: { 25 | files: { 26 | "public/js/templates.js": [ 27 | "templates/**/*", 28 | "node_modules/grunt-grunticon/example/**.hbs", 29 | "node_modules/grunt-grunticon/example/output/grunticon.loader.js" 30 | ] 31 | }, 32 | options: { 33 | commonjs: true 34 | } 35 | } 36 | }, 37 | modernizr: { 38 | build: { 39 | devFile: "public/lib/modernizr/modernizr.js", 40 | outputFile: "public/js/modernizr.js", 41 | parseFiles: false, 42 | tests: [ 43 | "a_download", 44 | "blob-constructor", 45 | "draganddrop", 46 | "file_api" 47 | ] 48 | } 49 | }, 50 | cssmin: { 51 | build: { 52 | files: { 53 | "public/dist/main.css": ["public/css/main.css"] 54 | } 55 | } 56 | }, 57 | browserify: { 58 | build: { 59 | files: { 60 | "public/dist/grumpicon.js": "public/js/app.js" 61 | }, 62 | options: { 63 | basedir: "public/js/", 64 | transform: [to5ify] 65 | } 66 | } 67 | }, 68 | uglify: { 69 | build: { 70 | files: { 71 | "public/dist/grumpicon.min.js": "public/dist/grumpicon.js" 72 | } 73 | } 74 | }, 75 | watch: { 76 | gruntfile: { 77 | files: "<%= jshint.gruntfile.src %>", 78 | tasks: ["jshint:gruntfile"] 79 | }, 80 | lib: { 81 | files: "<%= jshint.lib.src %>", 82 | tasks: ["jshint:lib"] 83 | }, 84 | pub: { 85 | files: ["public/js/**/*.js", "!public/js/grunticon-ui.min.js"], 86 | tasks: [ "default" ] 87 | }, 88 | test: { 89 | files: "<%= jshint.test.src %>", 90 | tasks: ["jshint:test"] 91 | } 92 | } 93 | }); 94 | 95 | // These plugins provide necessary tasks. 96 | grunt.loadNpmTasks("grunt-contrib-jshint"); 97 | grunt.loadNpmTasks("grunt-contrib-handlebars"); 98 | grunt.loadNpmTasks("grunt-modernizr"); 99 | grunt.loadNpmTasks("grunt-contrib-cssmin"); 100 | grunt.loadNpmTasks("grunt-contrib-uglify"); 101 | grunt.loadNpmTasks("grunt-browserify"); 102 | grunt.loadNpmTasks("grunt-contrib-watch"); 103 | 104 | // Default task. 105 | grunt.registerTask("default", ["jshint", "handlebars:compile", "browserify:build", "uglify", "cssmin"]); 106 | grunt.registerTask( "stage", ["default"] ); 107 | 108 | }; 109 | -------------------------------------------------------------------------------- /public/js/svgs/svg-model.js: -------------------------------------------------------------------------------- 1 | import * as $ from "jquery"; 2 | import {Model} from "backbone"; 3 | import readFile from "./../utils/readFile.js"; 4 | import createImage from "./../utils/createImage.js"; 5 | 6 | const SVG_TAG = /(