From 9d75398fad450947ced115b8b9ed0a54b6ffc891 Mon Sep 17 00:00:00 2001 From: Chris Manson Date: Mon, 11 Nov 2019 12:45:49 +0000 Subject: [PATCH] only supporting svg icons --- addon/components/notification-message.js | 45 +---- .../components/notification-message.hbs | 20 +- index.js | 49 ----- package-lock.json | 187 ------------------ package.json | 2 - tests/dummy/app/templates/application.hbs | 23 +-- 6 files changed, 11 insertions(+), 315 deletions(-) diff --git a/addon/components/notification-message.js b/addon/components/notification-message.js index 378e4fa2..fe713d59 100644 --- a/addon/components/notification-message.js +++ b/addon/components/notification-message.js @@ -1,7 +1,6 @@ import { htmlSafe } from '@ember/string'; import Component from '@ember/component'; -import { computed, get } from '@ember/object'; -import { equal } from '@ember/object/computed'; +import { computed } from '@ember/object'; import Ember from 'ember'; import layout from '../templates/components/notification-message'; @@ -32,45 +31,15 @@ export default Component.extend({ return false; }), - canShowSVG: equal('icons', 'svg'), - - closeIcon: computed('icons', function() { - const icons = this.get('icons'); - if (icons === 'bootstrap') return 'glyphicon glyphicon-remove'; - - if(icons === 'svg') return 'close'; - - return 'fa fa-times'; - }), - - // Set icon depending on notification type - notificationIcon: computed('notification.type', 'icons', function() { - const icons = this.get('icons'); - const notificationType = this.get('notification.type'); - - if(icons == 'svg') return get(this.get('svgs'), notificationType); - - if (icons === 'bootstrap') { - switch (notificationType){ - case "info": - return 'glyphicon glyphicon-info-sign'; - case "success": - return 'glyphicon glyphicon-ok-sign'; - case "warning": - case "error": - return 'glyphicon glyphicon-exclamation-sign'; - } - } - - switch (notificationType){ + notificationSVGPath: computed('notification.type', function() { + switch(this.get('notification.type')) { + case "error": case "info": - return 'fa fa-info-circle'; + return 'M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm1 15h-2v-6h2v6zm0-8h-2V7h2v2z'; case "success": - return 'fa fa-check'; + return 'M9 16.17L4.83 12l-1.42 1.41L9 19 21 7l-1.41-1.41z'; case "warning": - return 'fa fa-warning'; - case "error": - return 'fa fa-exclamation-circle'; + return 'M1 21h22L12 2 1 21zm12-3h-2v-2h2v2zm0-4h-2v-4h2v4z'; } return ''; diff --git a/addon/templates/components/notification-message.hbs b/addon/templates/components/notification-message.hbs index 1635ae61..4c6a1c0b 100644 --- a/addon/templates/components/notification-message.hbs +++ b/addon/templates/components/notification-message.hbs @@ -1,18 +1,8 @@
- {{#if canShowSVG}} + {{#if notificationSVGPath}} - {{#if (equal notificationIcon 'success')}} - - {{else if (equal notificationIcon 'warning')}} - - {{else if (equal notificationIcon 'info')}} - - {{else if (equal notificationIcon 'error')}} - - {{/if}} + - {{else}} - {{/if}}
@@ -22,11 +12,7 @@ {{notification.message}} {{/if}}
- {{#if canShowSVG}} - - {{else}} - - {{/if}} +
diff --git a/index.js b/index.js index 1dea54f2..db77abbc 100644 --- a/index.js +++ b/index.js @@ -1,12 +1,7 @@ 'use strict'; -const Funnel = require('broccoli-funnel'); -const path = require('path'); -const fs = require('fs'); - const PresetEnv = require('postcss-preset-env'); -const faPath = path.dirname(require.resolve('font-awesome/package.json')); module.exports = { name: require('./package').name, @@ -27,48 +22,4 @@ module.exports = { } } }, - - treeForVendor() { - return new Funnel(faPath, { - destDir: 'font-awesome', - include: ['css/*', `fonts/*`] - }); - }, - - included(app) { - const projectConfig = this.project.config(app.env); - const config = projectConfig['ember-cli-notifications']; - - this._super.included.apply(this, arguments); - - // see: https://github.com/ember-cli/ember-cli/issues/3718 - if (typeof app.import !== 'function' && app.app) { - app = app.app; - } - - this.app = app; - - // Don't import Font Awesome assets if specified in consuming app - if (config && config.includeFontAwesome && config.includeFontAwesome !== false) { - this.importFontAwesome(app); - } - }, - - importFontAwesome(app) { - const cssPath = 'vendor/font-awesome/css'; - const fontsPath = 'vendor/font-awesome/fonts'; - const absoluteFontsPath = path.join(faPath, 'fonts'); - const fontsToImport = fs.readdirSync(absoluteFontsPath); - - fontsToImport.forEach((fontFilename) => { - app.import( - path.join(fontsPath, fontFilename), - { destDir: '/fonts' } - ); - }); - app.import({ - development: path.join(cssPath, 'font-awesome.css'), - production: path.join(cssPath, 'font-awesome.min.css') - }); - } }; diff --git a/package-lock.json b/package-lock.json index 11c2cb83..2296008b 100644 --- a/package-lock.json +++ b/package-lock.json @@ -6082,132 +6082,6 @@ } } }, - "ember-runtime-enumerable-includes-polyfill": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/ember-runtime-enumerable-includes-polyfill/-/ember-runtime-enumerable-includes-polyfill-2.1.0.tgz", - "integrity": "sha512-au18iI8VbEDYn3jLFZzETnKN5ciPgCUxMRucEP3jkq7qZ6sE0FVKpWMPY/h9tTND3VOBJt6fgPpEBJoJVCUudg==", - "requires": { - "ember-cli-babel": "^6.9.0", - "ember-cli-version-checker": "^2.1.0" - }, - "dependencies": { - "amd-name-resolver": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/amd-name-resolver/-/amd-name-resolver-1.2.0.tgz", - "integrity": "sha512-hlSTWGS1t6/xq5YCed7YALg7tKZL3rkl7UwEZ/eCIkn8JxmM6fU6Qs/1hwtjQqfuYxlffuUcgYEm0f5xP4YKaA==", - "requires": { - "ensure-posix-path": "^1.0.1" - } - }, - "babel-plugin-debug-macros": { - "version": "0.2.0", - "resolved": "https://registry.npmjs.org/babel-plugin-debug-macros/-/babel-plugin-debug-macros-0.2.0.tgz", - "integrity": "sha512-Wpmw4TbhR3Eq2t3W51eBAQSdKlr+uAyF0GI4GtPfMCD12Y4cIdpKC9l0RjNTH/P9isFypSqqewMPm7//fnZlNA==", - "requires": { - "semver": "^5.3.0" - } - }, - "broccoli-babel-transpiler": { - "version": "6.5.1", - "resolved": "https://registry.npmjs.org/broccoli-babel-transpiler/-/broccoli-babel-transpiler-6.5.1.tgz", - "integrity": "sha512-w6GcnkxvHcNCte5FcLGEG1hUdQvlfvSN/6PtGWU/otg69Ugk8rUk51h41R0Ugoc+TNxyeFG1opRt2RlA87XzNw==", - "requires": { - "babel-core": "^6.26.0", - "broccoli-funnel": "^2.0.1", - "broccoli-merge-trees": "^2.0.0", - "broccoli-persistent-filter": "^1.4.3", - "clone": "^2.0.0", - "hash-for-dep": "^1.2.3", - "heimdalljs-logger": "^0.1.7", - "json-stable-stringify": "^1.0.0", - "rsvp": "^4.8.2", - "workerpool": "^2.3.0" - } - }, - "broccoli-merge-trees": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/broccoli-merge-trees/-/broccoli-merge-trees-2.0.1.tgz", - "integrity": "sha512-WjaexJ+I8BxP5V5RNn6um/qDRSmKoiBC/QkRi79FT9ClHfldxRyCDs9mcV7mmoaPlsshmmPaUz5jdtcKA6DClQ==", - "requires": { - "broccoli-plugin": "^1.3.0", - "merge-trees": "^1.0.1" - } - }, - "broccoli-persistent-filter": { - "version": "1.4.6", - "resolved": "https://registry.npmjs.org/broccoli-persistent-filter/-/broccoli-persistent-filter-1.4.6.tgz", - "integrity": "sha512-0RejLwoC95kv4kta8KAa+FmECJCK78Qgm8SRDEK7YyU0N9Cx6KpY3UCDy9WELl3mCXLN8TokNxc7/hp3lL4lfw==", - "requires": { - "async-disk-cache": "^1.2.1", - "async-promise-queue": "^1.0.3", - "broccoli-plugin": "^1.0.0", - "fs-tree-diff": "^0.5.2", - "hash-for-dep": "^1.0.2", - "heimdalljs": "^0.2.1", - "heimdalljs-logger": "^0.1.7", - "mkdirp": "^0.5.1", - "promise-map-series": "^0.2.1", - "rimraf": "^2.6.1", - "rsvp": "^3.0.18", - "symlink-or-copy": "^1.0.1", - "walk-sync": "^0.3.1" - }, - "dependencies": { - "rsvp": { - "version": "3.6.2", - "resolved": "https://registry.npmjs.org/rsvp/-/rsvp-3.6.2.tgz", - "integrity": "sha512-OfWGQTb9vnwRjwtA2QwpG2ICclHC3pgXZO5xt8H2EfgDquO0qVdSb5T88L4qJVAEugbS56pAuV4XZM58UX8ulw==" - } - } - }, - "ember-cli-babel": { - "version": "6.18.0", - "resolved": "https://registry.npmjs.org/ember-cli-babel/-/ember-cli-babel-6.18.0.tgz", - "integrity": "sha512-7ceC8joNYxY2wES16iIBlbPSxwKDBhYwC8drU3ZEvuPDMwVv1KzxCNu1fvxyFEBWhwaRNTUxSCsEVoTd9nosGA==", - "requires": { - "amd-name-resolver": "1.2.0", - "babel-plugin-debug-macros": "^0.2.0-beta.6", - "babel-plugin-ember-modules-api-polyfill": "^2.6.0", - "babel-plugin-transform-es2015-modules-amd": "^6.24.0", - "babel-polyfill": "^6.26.0", - "babel-preset-env": "^1.7.0", - "broccoli-babel-transpiler": "^6.5.0", - "broccoli-debug": "^0.6.4", - "broccoli-funnel": "^2.0.0", - "broccoli-source": "^1.1.0", - "clone": "^2.0.0", - "ember-cli-version-checker": "^2.1.2", - "semver": "^5.5.0" - } - }, - "merge-trees": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/merge-trees/-/merge-trees-1.0.1.tgz", - "integrity": "sha1-zL5nRWl4f53vF/1G5lJfVwC70j4=", - "requires": { - "can-symlink": "^1.0.0", - "fs-tree-diff": "^0.5.4", - "heimdalljs": "^0.2.1", - "heimdalljs-logger": "^0.1.7", - "rimraf": "^2.4.3", - "symlink-or-copy": "^1.0.0" - } - }, - "rsvp": { - "version": "4.8.5", - "resolved": "https://registry.npmjs.org/rsvp/-/rsvp-4.8.5.tgz", - "integrity": "sha512-nfMOlASu9OnRJo1mbEk2cz0D56a1MBNrJ7orjRZQG10XDyuvwksKbuXNp6qa+kbn839HwjwhBzhFmdsaEAfauA==" - }, - "workerpool": { - "version": "2.3.3", - "resolved": "https://registry.npmjs.org/workerpool/-/workerpool-2.3.3.tgz", - "integrity": "sha512-L1ovlYHp6UObYqElXXpbd214GgbEKDED0d3sj7pRdFXjNkb2+un/AUcCkceHizO0IVI6SOGGncrcjozruCkRgA==", - "requires": { - "object-assign": "4.1.1" - } - } - } - }, "ember-source": { "version": "3.13.4", "resolved": "https://registry.npmjs.org/ember-source/-/ember-source-3.13.4.tgz", @@ -7333,11 +7207,6 @@ } } }, - "font-awesome": { - "version": "4.7.0", - "resolved": "https://registry.npmjs.org/font-awesome/-/font-awesome-4.7.0.tgz", - "integrity": "sha1-j6jPBBGhoxr9B7BtKQK7n8gVoTM=" - }, "for-in": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/for-in/-/for-in-1.0.2.tgz", @@ -9871,31 +9740,6 @@ "integrity": "sha1-AerA/jta9xoqbAL+q7jB/vfgDqs=", "dev": true }, - "postcss": { - "version": "7.0.21", - "resolved": "https://registry.npmjs.org/postcss/-/postcss-7.0.21.tgz", - "integrity": "sha512-uIFtJElxJo29QC753JzhidoAhvp/e/Exezkdhfmt8AymWT6/5B7W1WmponYWkHk2eg6sONyTch0A3nkMPun3SQ==", - "requires": { - "chalk": "^2.4.2", - "source-map": "^0.6.1", - "supports-color": "^6.1.0" - }, - "dependencies": { - "source-map": { - "version": "0.6.1", - "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz", - "integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==" - }, - "supports-color": { - "version": "6.1.0", - "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-6.1.0.tgz", - "integrity": "sha512-qe1jfm1Mg7Nq/NSh6XE24gPXROEVsWHxC1LIx//XNlD9iw7YZQGjZNjYN7xGaEG6iKdA8EtNFW6R0gjnVXp+wQ==", - "requires": { - "has-flag": "^3.0.0" - } - } - } - }, "postcss-color-functional-notation": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/postcss-color-functional-notation/-/postcss-color-functional-notation-2.0.1.tgz", @@ -10260,17 +10104,6 @@ } } }, - "postcss-import": { - "version": "12.0.1", - "resolved": "https://registry.npmjs.org/postcss-import/-/postcss-import-12.0.1.tgz", - "integrity": "sha512-3Gti33dmCjyKBgimqGxL3vcV8w9+bsHwO5UrBawp796+jdardbcFl4RP5w/76BwNL7aGzpKstIfF9I+kdE8pTw==", - "requires": { - "postcss": "^7.0.1", - "postcss-value-parser": "^3.2.3", - "read-cache": "^1.0.0", - "resolve": "^1.1.7" - } - }, "postcss-lab-function": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/postcss-lab-function/-/postcss-lab-function-2.0.1.tgz", @@ -10698,11 +10531,6 @@ } } }, - "postcss-value-parser": { - "version": "3.3.1", - "resolved": "https://registry.npmjs.org/postcss-value-parser/-/postcss-value-parser-3.3.1.tgz", - "integrity": "sha512-pISE66AbVkp4fDQ7VHBwRNXzAAKJjw4Vw7nWI/+Q3vuly7SNfgYXvm6i5IgFylHGK5sP/xHAbB7N49OS4gWNyQ==" - }, "prelude-ls": { "version": "1.1.2", "resolved": "https://registry.npmjs.org/prelude-ls/-/prelude-ls-1.1.2.tgz", @@ -10939,21 +10767,6 @@ } } }, - "read-cache": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/read-cache/-/read-cache-1.0.0.tgz", - "integrity": "sha1-5mTvMRYRZsl1HNvo28+GtftY93Q=", - "requires": { - "pify": "^2.3.0" - }, - "dependencies": { - "pify": { - "version": "2.3.0", - "resolved": "https://registry.npmjs.org/pify/-/pify-2.3.0.tgz", - "integrity": "sha1-7RQaasBDqEnqWISY59yosVMw6Qw=" - } - } - }, "readable-stream": { "version": "1.0.34", "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-1.0.34.tgz", diff --git a/package.json b/package.json index d5e6f152..9ac83012 100644 --- a/package.json +++ b/package.json @@ -29,12 +29,10 @@ "test:all": "ember try:each" }, "dependencies": { - "broccoli-funnel": "^2.0.1", "ember-cli-babel": "^7.11.1", "ember-cli-htmlbars": "^4.0.0", "ember-cli-postcss": "^5.0.0", "ember-get-config": "^0.2.4", - "font-awesome": "^4.7.0", "postcss-preset-env": "^6.7.0" }, "devDependencies": { diff --git a/tests/dummy/app/templates/application.hbs b/tests/dummy/app/templates/application.hbs index 2b04b1cd..59c27a3b 100644 --- a/tests/dummy/app/templates/application.hbs +++ b/tests/dummy/app/templates/application.hbs @@ -214,30 +214,9 @@ var ENV = { clearDuration: 2400 } } - -

Icons

-

Font Awesome is a requirement to display the icons on the notifications and is installed as a dependency.

- -

If you don't want to import the Font Awesome assets into the consuming application, add the following to the app config file.

- -// config/environment.js -var ENV = { - 'ember-cli-notifications': { - includeFontAwesome: false - } -} - - -

Alternatively, the notifications can use the Glyphicons icon package. Glyphicons will not added to your application via this addon.

- -// config/environment.js -var ENV = { - 'ember-cli-notifications': { - icons: 'bootstrap' - } -} +

Extend