Skip to content

Commit

Permalink
feat: Import Font Awesome assets by default (#168)
Browse files Browse the repository at this point in the history
* feat: Import Font Awesome assets into app by default

BREAKING CHANGE: Font Awesome assets now imported by default, breaking previous convention of import when defined

* docs: Update dummy app
  • Loading branch information
ynnoj committed Aug 18, 2017
1 parent 8ab4bf8 commit 85b63e9
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 21 deletions.
2 changes: 1 addition & 1 deletion addon/services/notification-messages-service.js
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ const NotificationMessagesService = ArrayProxy.extend({
});

NotificationMessagesService.reopenClass({
isServiceFactory: true,
isServiceFactory: true
});

export default NotificationMessagesService;
33 changes: 17 additions & 16 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ module.exports = {
},

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
Expand All @@ -38,7 +41,10 @@ module.exports = {

this.app = app;

this.importFontAwesome(app);
// Don't import Font Awesome assets if specified in consuming app
if (config.includeFontAwesome !== false) {
this.importFontAwesome(app);
}
},

importFontAwesome(app) {
Expand All @@ -47,20 +53,15 @@ module.exports = {
const absoluteFontsPath = path.join(faPath, 'fonts');
const fontsToImport = fs.readdirSync(absoluteFontsPath);

const projectConfig = this.project.config(app.env);
const config = projectConfig['ember-cli-notifications'] || { includeFontAwesome: false };

if (config.includeFontAwesome) {
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')
});
}
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')
});
}
};
6 changes: 3 additions & 3 deletions tests/dummy/app/templates/application.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -230,15 +230,15 @@ var ENV = {
}
{{/themed-syntax}}
<h3>Icons</h3>
<p><a href="http://fontawesome.io/" target="_blank">Font Awesome</a> is a requirement to display the icons on the notifications.</p>
<p><a href="http://fontawesome.io/" target="_blank">Font Awesome</a> is a requirement to display the icons on the notifications and is installed as a dependency.</p>

<p>If Font Awesome is not already included in the consuming application, add the following to your environment config file.</p>
<p>If you don't want to import the Font Awesome assets into the consuming application, add the following to the app config file.</p>

{{#themed-syntax lang="js" theme="dark" class="h5" withBuffers=false}}
// config/environment.js
var ENV = {
'ember-cli-notifications': {
includeFontAwesome: true
includeFontAwesome: false
}
}
{{/themed-syntax}}
Expand Down
1 change: 0 additions & 1 deletion tests/dummy/config/environment.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ module.exports = function(environment) {
},

'ember-cli-notifications': {
includeFontAwesome: true,
autoClear: false,
clearDuration: 2400
}
Expand Down

0 comments on commit 85b63e9

Please sign in to comment.