From f243624fbd175a93cf24fcdf970b72425afa246d Mon Sep 17 00:00:00 2001 From: Cole Bemis Date: Sat, 18 Nov 2017 20:00:16 -0800 Subject: [PATCH] feat: Update API BREAKING CHANGE: Each icon in the `feather.icons` object is now an `Icon` object with a `name`, `contents`, `tags` and `attrs` property. ```js /* BEFORE */ feather.icons.x // '' /* AFTER */ feather.icons.x // { // name: 'x', // contents: '`, // tags: ['cancel', 'close', 'delete', 'remove'], // attrs: { // class: 'feather feather-x', // xmlns: 'http://www.w3.org/2000/svg', // width: 24, // height: 24, // viewBox: '0 0 24 24', // fill: 'none', // stroke: 'currentColor', // 'stroke-width': 2, // 'stroke-linecap': 'round', // 'stroke-linejoin': 'round', // } // } ``` `feather.toSvg()` has been deprecated in favor of `feather.icons[name].toSvg()`: ```js /* BEFORE */ feather.toSvg('x') /* AFTER */ feather.icons.x.toSvg() ``` `feather.replace()` now copies all attributes on the placeholder element (i.e. ``) to the `` tag instead of just `class` and `id`: ```html ``` --- .babelrc | 5 +- .eslintrc.json | 9 +- .travis.yml | 2 +- Makefile | 34 --- README.md | 147 +++++++---- .../build-icons-object.test.js.snap | 8 + bin/__tests__/build-icons-object.test.js | 17 ++ bin/build-icons-json.js | 19 ++ bin/build-icons-object.js | 34 +++ bin/build-json.js | 71 ------ bin/build-svgs.js | 16 +- bin/build.sh | 14 + bin/process-svg.js | 10 +- bin/process-svgs.js | 13 +- package-lock.json | 240 ++++++++++++++++++ package.json | 16 +- src/__tests__/__snapshots__/icon.test.js.snap | 54 ++++ .../__snapshots__/icons.test.js.snap | 45 ++++ .../__snapshots__/replace.test.js.snap | 13 + .../__snapshots__/to-svg.test.js.snap | 7 + src/__tests__/icon.test.js | 28 ++ src/__tests__/icons.test.js | 16 ++ src/__tests__/index.test.js | 8 + src/__tests__/replace.test.js | 32 +++ src/__tests__/to-svg.test.js | 21 ++ ...ult-attributes.json => default-attrs.json} | 0 src/icon.js | 55 ++++ src/icons.js | 10 + src/index.js | 6 +- src/replace.js | 70 ++--- src/tags.json | 7 + src/to-svg.js | 72 ++---- 32 files changed, 825 insertions(+), 274 deletions(-) delete mode 100644 Makefile create mode 100644 bin/__tests__/__snapshots__/build-icons-object.test.js.snap create mode 100644 bin/__tests__/build-icons-object.test.js create mode 100644 bin/build-icons-json.js create mode 100644 bin/build-icons-object.js delete mode 100755 bin/build-json.js create mode 100755 bin/build.sh create mode 100644 src/__tests__/__snapshots__/icon.test.js.snap create mode 100644 src/__tests__/__snapshots__/icons.test.js.snap create mode 100644 src/__tests__/__snapshots__/replace.test.js.snap create mode 100644 src/__tests__/__snapshots__/to-svg.test.js.snap create mode 100644 src/__tests__/icon.test.js create mode 100644 src/__tests__/icons.test.js create mode 100644 src/__tests__/index.test.js create mode 100644 src/__tests__/replace.test.js create mode 100644 src/__tests__/to-svg.test.js rename src/{default-attributes.json => default-attrs.json} (100%) create mode 100644 src/icon.js create mode 100644 src/icons.js create mode 100644 src/tags.json diff --git a/.babelrc b/.babelrc index 3c078e9..831f20a 100644 --- a/.babelrc +++ b/.babelrc @@ -1,5 +1,4 @@ { - "presets": [ - "es2015" - ] + "presets": ["es2015"], + "plugins": ["transform-object-rest-spread"] } diff --git a/.eslintrc.json b/.eslintrc.json index f020c3c..4317b2d 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -1,12 +1,11 @@ { "extends": "airbnb-base", - "plugins": [ - "import" - ], + "plugins": ["import"], "rules": { - "no-use-before-define": "off", "arrow-parens": ["error", "as-needed"], + "no-console": ["error", { "allow": ["warn", "error"] }], + "no-param-reassign": "off", "no-shadow": "off", - "no-console": ["error", { "allow": ["warn", "error"] }] + "no-use-before-define": "off" } } diff --git a/.travis.yml b/.travis.yml index 0c28266..4ba7f6c 100644 --- a/.travis.yml +++ b/.travis.yml @@ -8,6 +8,6 @@ node_js: 6 before_script: - npm prune script: - - npm run all + - npm start after_success: - npm run semantic-release diff --git a/Makefile b/Makefile deleted file mode 100644 index 7a28afc..0000000 --- a/Makefile +++ /dev/null @@ -1,34 +0,0 @@ -src_files := src/*.js -src_dir := src - -.PHONY: all lint test build - -all: lint test build - -lint: dist/icons.json - ./node_modules/.bin/eslint . - -test: - ./node_modules/.bin/jest - -build: dist/feather.js dist/feather.min.js dist/icons - -node_modules: - npm install - -dist: - mkdir dist - -dist/icons.json: node_modules dist icons icons/*.svg - ./node_modules/.bin/babel-node bin/build-json.js - -dist/feather.js: dist/icons.json $(src_dir) $(src_files) - ./node_modules/.bin/webpack --output-filename feather.js - -dist/feather.min.js: dist/icons.json $(src_dir) $(src_files) - ./node_modules/.bin/webpack --output-filename feather.min.js -p - -dist/icons: dist/icons.json - rm -rf dist/icons - mkdir -p dist/icons - ./node_modules/.bin/babel-node bin/build-svgs.js diff --git a/README.md b/README.md index e6afc75..bdc7920 100644 --- a/README.md +++ b/README.md @@ -3,12 +3,12 @@ [![Travis branch](https://img.shields.io/travis/colebemis/feather/master.svg?style=flat-square)](https://travis-ci.org/colebemis/feather) [![npm](https://img.shields.io/npm/v/feather-icons.svg?style=flat-square)](https://www.npmjs.com/package/feather-icons) [![npm](https://img.shields.io/npm/dm/feather-icons.svg?style=flat-square)](https://npm-stat.com/charts.html?package=feather-icons&from=2017-06-01) -[![Code Climate](https://img.shields.io/codeclimate/github/colebemis/feather.svg?style=flat-square)](https://codeclimate.com/github/colebemis/feather) [![CDNJS version](https://img.shields.io/cdnjs/v/feather-icons.svg?style=flat-square)](https://cdnjs.com/libraries/feather-icons) +[![Code Climate](https://img.shields.io/codeclimate/github/colebemis/feather.svg?style=flat-square)](https://codeclimate.com/github/colebemis/feather) ## What is Feather? -Feather is a collection of **simply beautiful open source icons**. Each icon is designed on a 24x24 grid with an emphasis on simplicity, consistency and readability. +Feather is a collection of simply beautiful open source icons. Each icon is designed on a 24x24 grid with an emphasis on simplicity, consistency and readability. **[feathericons.com](https://feathericons.com)** @@ -20,12 +20,13 @@ npm install feather-icons * [Quick Start](#quick-start) * [Usage](#usage) - * [Client-side JavaScript](#client-side-javascript) + * [Client-side](#client-side) * [Node](#node) * [API Reference](#api-reference) * [`feather.icons`](#feathericons) - * [`feather.toSvg()`](#feathertosvgkey-options) - * [`feather.replace()`](#featherreplaceoptions) + * [`feather.icons[name].toSvg()`](#feathericonsnametosvgattrs) + * [`feather.replace()`](#featherreplaceattrs) + * [[DEPRECATED] `feather.toSvg()`](#deprecated-feathertosvgname-attrs) * [Roadmap](#roadmap) * [Contributing](#contributing) * [Related Projects](#related-projects) @@ -60,7 +61,7 @@ At its core, Feather is a collection of [SVG](https://svgontheweb.com/#svg) file The following are additional ways you can use Feather. -### Client-side JavaScript +### Client-side #### 1. Install @@ -79,7 +80,7 @@ Or just copy [`feather.js`](https://unpkg.com/feather-icons/dist/feather.js) or Include `feather.js` or `feather.min.js` with a ` + ``` Or load the script from a CDN provider. @@ -104,7 +105,7 @@ See the complete list of icons at [feathericons.com](https://feathericons.com). #### 4. Replace -Call the `feather.replace` method. +Call the `feather.replace()` method. ```html ``` -You can pass `feather.replace()` an `options` object: +You can pass `feather.replace()` an `attrs` object: ```html