Browse Source

Hello, sass-spritemaker!

Tomek Wójcik 7 months ago
commit
fc60ab110d
100 changed files with 205 additions and 0 deletions
  1. 52 0
      .eslintrc.json
  2. 5 0
      .gitignore
  3. 5 0
      .npmignore
  4. 19 0
      LICENSE
  5. 29 0
      NOTICE.txt
  6. 67 0
      README.md
  7. 28 0
      example/example.js
  8. BIN
      example/icons/basic_accelerator.png
  9. BIN
      example/icons/basic_alarm.png
  10. BIN
      example/icons/basic_anchor.png
  11. BIN
      example/icons/basic_anticlockwise.png
  12. BIN
      example/icons/basic_archive.png
  13. BIN
      example/icons/basic_archive_full.png
  14. BIN
      example/icons/basic_ban.png
  15. BIN
      example/icons/basic_battery_charge.png
  16. BIN
      example/icons/basic_battery_empty.png
  17. BIN
      example/icons/basic_battery_full.png
  18. BIN
      example/icons/basic_battery_half.png
  19. BIN
      example/icons/basic_bolt.png
  20. BIN
      example/icons/basic_book.png
  21. BIN
      example/icons/basic_book_pen.png
  22. BIN
      example/icons/basic_book_pencil.png
  23. BIN
      example/icons/basic_bookmark.png
  24. BIN
      example/icons/basic_calculator.png
  25. BIN
      example/icons/basic_calendar.png
  26. BIN
      example/icons/basic_cards_diamonds.png
  27. BIN
      example/icons/basic_cards_hearts.png
  28. BIN
      example/icons/basic_case.png
  29. BIN
      example/icons/basic_chronometer.png
  30. BIN
      example/icons/basic_clessidre.png
  31. BIN
      example/icons/basic_clock.png
  32. BIN
      example/icons/basic_clockwise.png
  33. BIN
      example/icons/basic_cloud.png
  34. BIN
      example/icons/basic_clubs.png
  35. BIN
      example/icons/basic_compass.png
  36. BIN
      example/icons/basic_cup.png
  37. BIN
      example/icons/basic_diamonds.png
  38. BIN
      example/icons/basic_display.png
  39. BIN
      example/icons/basic_download.png
  40. BIN
      example/icons/basic_exclamation.png
  41. BIN
      example/icons/basic_eye.png
  42. BIN
      example/icons/basic_eye_closed.png
  43. BIN
      example/icons/basic_female.png
  44. BIN
      example/icons/basic_flag1.png
  45. BIN
      example/icons/basic_flag2.png
  46. BIN
      example/icons/basic_floppydisk.png
  47. BIN
      example/icons/basic_folder.png
  48. BIN
      example/icons/basic_folder_multiple.png
  49. BIN
      example/icons/basic_gear.png
  50. BIN
      example/icons/basic_geolocalize-01.png
  51. BIN
      example/icons/basic_geolocalize-05.png
  52. BIN
      example/icons/basic_globe.png
  53. BIN
      example/icons/basic_gunsight.png
  54. BIN
      example/icons/basic_hammer.png
  55. BIN
      example/icons/basic_headset.png
  56. BIN
      example/icons/basic_heart.png
  57. BIN
      example/icons/basic_heart_broken.png
  58. BIN
      example/icons/basic_helm.png
  59. BIN
      example/icons/basic_home.png
  60. BIN
      example/icons/basic_info.png
  61. BIN
      example/icons/basic_ipod.png
  62. BIN
      example/icons/basic_joypad.png
  63. BIN
      example/icons/basic_key.png
  64. BIN
      example/icons/basic_keyboard.png
  65. BIN
      example/icons/basic_laptop.png
  66. BIN
      example/icons/basic_life_buoy.png
  67. BIN
      example/icons/basic_lightbulb.png
  68. BIN
      example/icons/basic_link.png
  69. BIN
      example/icons/basic_lock.png
  70. BIN
      example/icons/basic_lock_open.png
  71. BIN
      example/icons/basic_magic_mouse.png
  72. BIN
      example/icons/basic_magnifier.png
  73. BIN
      example/icons/basic_magnifier_minus.png
  74. BIN
      example/icons/basic_magnifier_plus.png
  75. BIN
      example/icons/basic_mail.png
  76. BIN
      example/icons/basic_mail_multiple.png
  77. BIN
      example/icons/basic_mail_open.png
  78. BIN
      example/icons/basic_mail_open_text.png
  79. BIN
      example/icons/basic_male.png
  80. BIN
      example/icons/basic_map.png
  81. BIN
      example/icons/basic_message.png
  82. BIN
      example/icons/basic_message_multiple.png
  83. BIN
      example/icons/basic_message_txt.png
  84. BIN
      example/icons/basic_mixer2.png
  85. BIN
      example/icons/basic_mouse.png
  86. BIN
      example/icons/basic_notebook.png
  87. BIN
      example/icons/basic_notebook_pen.png
  88. BIN
      example/icons/basic_notebook_pencil.png
  89. BIN
      example/icons/basic_paperplane.png
  90. BIN
      example/icons/basic_pencil_ruler.png
  91. BIN
      example/icons/basic_pencil_ruler_pen .png
  92. BIN
      example/icons/basic_photo.png
  93. BIN
      example/icons/basic_picture.png
  94. BIN
      example/icons/basic_picture_multiple.png
  95. BIN
      example/icons/basic_pin1.png
  96. BIN
      example/icons/basic_pin2.png
  97. BIN
      example/icons/basic_postcard.png
  98. BIN
      example/icons/basic_postcard_multiple.png
  99. BIN
      example/icons/basic_printer.png
  100. 0 0
      example/icons/basic_question.png

+ 52 - 0
.eslintrc.json

@@ -0,0 +1,52 @@
+{
+  "env": {
+    "node": true,
+    "es6": true
+  },
+  "extends": "eslint:recommended",
+  "parserOptions": {
+    "ecmaVersion": 6,
+    "sourceType": "module",
+    "ecmaFeatures": {
+      "impliedStrict": true
+    }
+  },
+  "rules": {
+    "no-undef": "error",
+    "quotes": [
+      2, "single", {"avoidEscape": true, "allowTemplateLiterals": true}
+    ],
+    "no-unused-vars": [0],
+    "no-console": [2],
+    "no-empty": ["error", {"allowEmptyCatch": true}],
+    "array-bracket-spacing": ["error", "never"],
+    "block-spacing": ["error", "always"],
+    "brace-style": ["error", "1tbs", {"allowSingleLine": true}],
+    "camelcase": ["error", {"properties": "never"}],
+    "comma-dangle": ["error", "never"],
+    "comma-spacing": ["error", {"before": false, "after": true}],
+    "comma-style": ["error", "last"],
+    "computed-property-spacing": ["error", "never"],
+    "key-spacing": [
+      "error", {"beforeColon": false, "afterColon": true, "mode": "strict"}
+    ],
+    "keyword-spacing": ["error", { "before": true, "after": true }],
+    "linebreak-style": ["error", "unix"],
+    "max-len": ["error", 120],
+    "no-multiple-empty-lines": ["error"],
+    "no-spaced-func": ["error"],
+    "no-trailing-spaces": ["error"],
+    "no-unreachable": [1],
+    "no-whitespace-before-property": ["error"],
+    "object-curly-spacing": ["error", "never"],
+    "one-var-declaration-per-line": ["error", "always"],
+    "one-var": ["error", "never"],
+    "semi-spacing": ["error", {"before": false, "after": true}],
+    "semi": ["error", "always"],
+    "space-before-function-paren": ["error", "always"],
+    "space-before-blocks": ["error", "always"],
+    "space-in-parens": ["error", "never"],
+    "space-infix-ops": ["error"],
+    "unicode-bom": ["error", "never"]
+  }
+}

+ 5 - 0
.gitignore

@@ -0,0 +1,5 @@
+example/.sass-cache/
+example/output/sprite*
+node_modules/
+tmp_spritemaker*/
+bthlabs-sass-spritemaker-*.tgz

+ 5 - 0
.npmignore

@@ -0,0 +1,5 @@
+example/**/*
+test/**/*
+yarn.lock
+.eslintrc.json
+bthlabs-sass-spritemaker-*.tgz

+ 19 - 0
LICENSE

@@ -0,0 +1,19 @@
+Copyright (c) 2019-present Tomek Wójcik <contact@bthlabs.pl>
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+THE SOFTWARE.

+ 29 - 0
NOTICE.txt

@@ -0,0 +1,29 @@
+sass-spritemaker
+Copyright (c) 2019-present Tomek Wójcik <contact@bthlabs.pl>
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+THE SOFTWARE.
+
+---
+
+sass-spritemaker includes the following third party software and resources
+
+Linea Iconset
+Copyright (c) Dario Ferrando
+Licensed under terms of CCBY license
+http://creativecommons.org/licenses/by/4.0/

+ 67 - 0
README.md

@@ -0,0 +1,67 @@
+# sass-spritemaker
+
+Convert a bunch of PNGs to a Sass spritemap.
+
+## Installation
+
+sass-spritemaker requires **Node 6.9.0 or later**.
+
+```
+npm install --save-dev @bthlabs/sass-spritemaker
+```
+
+This assumes that you’re using [npm](http://npmjs.com/) package manager.
+sass-spritemaker supports [yarn](https://yarnpkg.com/), too.
+
+## Usage example
+
+The following JavaScript code demonstrates the most common usage of the
+library:
+
+```javascript
+const {spritemaker} = require('../lib/spritemaker.js');
+
+spritemaker({
+  files: ['./icons/*.png'],
+  output: './output/'
+});
+```
+
+## API
+
+### `spritemaker(options)`
+
+This is the main entrypoint of the library. The *options* argument is an object
+that specifies the function's behaviour.
+
+**Options object fields**:
+
+* `fields` - array of globs that will be resolved to construct input files
+  list. Defaults to `[]`.
+* `output` - path to output directory. Defaults to `sprite/`.
+* `urlPrefix` - URL prefix for background image URLs. Defaults to `/`.
+
+## Development
+
+To bootstrap the development environment, clone the repo and run `npm install`
+from the root directory.
+
+The `package.json` file provides the following scripts:
+
+* `lint` - performs an eslint run over the source code,
+* `test` - performs a single test run.
+
+## Contributing
+
+If you think you found a bug or want to send a patch, feel free to contact
+me through e-mail.
+
+If you're sending a patch, make sure it passes eslint checks and is tested.
+
+## Author
+
+sass-spritemaker is developed by [Tomek Wójcik](https://www.bthlabs.pl/).
+
+## License
+
+sass-spritemaker is licensed under the MIT License.

+ 28 - 0
example/example.js

@@ -0,0 +1,28 @@
+/**
+ * Copyright (c) 2019-present Tomek Wójcik <contact@bthlabs.pl>
+ * 
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ * 
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ * 
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+
+const {spritemaker} = require('../lib/spritemaker.js');
+
+spritemaker({
+  files: ['./icons/*.png'],
+  output: './output/'
+});

BIN
example/icons/basic_accelerator.png


BIN
example/icons/basic_alarm.png


BIN
example/icons/basic_anchor.png


BIN
example/icons/basic_anticlockwise.png


BIN
example/icons/basic_archive.png


BIN
example/icons/basic_archive_full.png


BIN
example/icons/basic_ban.png


BIN
example/icons/basic_battery_charge.png


BIN
example/icons/basic_battery_empty.png


BIN
example/icons/basic_battery_full.png


BIN
example/icons/basic_battery_half.png


BIN
example/icons/basic_bolt.png


BIN
example/icons/basic_book.png


BIN
example/icons/basic_book_pen.png


BIN
example/icons/basic_book_pencil.png


BIN
example/icons/basic_bookmark.png


BIN
example/icons/basic_calculator.png


BIN
example/icons/basic_calendar.png


BIN
example/icons/basic_cards_diamonds.png


BIN
example/icons/basic_cards_hearts.png


BIN
example/icons/basic_case.png


BIN
example/icons/basic_chronometer.png


BIN
example/icons/basic_clessidre.png


BIN
example/icons/basic_clock.png


BIN
example/icons/basic_clockwise.png


BIN
example/icons/basic_cloud.png


BIN
example/icons/basic_clubs.png


BIN
example/icons/basic_compass.png


BIN
example/icons/basic_cup.png


BIN
example/icons/basic_diamonds.png


BIN
example/icons/basic_display.png


BIN
example/icons/basic_download.png


BIN
example/icons/basic_exclamation.png


BIN
example/icons/basic_eye.png


BIN
example/icons/basic_eye_closed.png


BIN
example/icons/basic_female.png


BIN
example/icons/basic_flag1.png


BIN
example/icons/basic_flag2.png


BIN
example/icons/basic_floppydisk.png


BIN
example/icons/basic_folder.png


BIN
example/icons/basic_folder_multiple.png


BIN
example/icons/basic_gear.png


BIN
example/icons/basic_geolocalize-01.png


BIN
example/icons/basic_geolocalize-05.png


BIN
example/icons/basic_globe.png


BIN
example/icons/basic_gunsight.png


BIN
example/icons/basic_hammer.png


BIN
example/icons/basic_headset.png


BIN
example/icons/basic_heart.png


BIN
example/icons/basic_heart_broken.png


BIN
example/icons/basic_helm.png


BIN
example/icons/basic_home.png


BIN
example/icons/basic_info.png


BIN
example/icons/basic_ipod.png


BIN
example/icons/basic_joypad.png


BIN
example/icons/basic_key.png


BIN
example/icons/basic_keyboard.png


BIN
example/icons/basic_laptop.png


BIN
example/icons/basic_life_buoy.png


BIN
example/icons/basic_lightbulb.png


BIN
example/icons/basic_link.png


BIN
example/icons/basic_lock.png


BIN
example/icons/basic_lock_open.png


BIN
example/icons/basic_magic_mouse.png


BIN
example/icons/basic_magnifier.png


BIN
example/icons/basic_magnifier_minus.png


BIN
example/icons/basic_magnifier_plus.png


BIN
example/icons/basic_mail.png


BIN
example/icons/basic_mail_multiple.png


BIN
example/icons/basic_mail_open.png


BIN
example/icons/basic_mail_open_text.png


BIN
example/icons/basic_male.png


BIN
example/icons/basic_map.png


BIN
example/icons/basic_message.png


BIN
example/icons/basic_message_multiple.png


BIN
example/icons/basic_message_txt.png


BIN
example/icons/basic_mixer2.png


BIN
example/icons/basic_mouse.png


BIN
example/icons/basic_notebook.png


BIN
example/icons/basic_notebook_pen.png


BIN
example/icons/basic_notebook_pencil.png


BIN
example/icons/basic_paperplane.png


BIN
example/icons/basic_pencil_ruler.png


BIN
example/icons/basic_pencil_ruler_pen .png


BIN
example/icons/basic_photo.png


BIN
example/icons/basic_picture.png


BIN
example/icons/basic_picture_multiple.png


BIN
example/icons/basic_pin1.png


BIN
example/icons/basic_pin2.png


BIN
example/icons/basic_postcard.png


BIN
example/icons/basic_postcard_multiple.png


BIN
example/icons/basic_printer.png


+ 0 - 0
example/icons/basic_question.png


Some files were not shown because too many files changed in this diff