All files / src ux-configuration.ts

47.37% Statements 9/19
0% Branches 0/2
33.33% Functions 2/6
40% Lines 6/15
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36              1x 1x   1x   1x         1x                                 1x  
import { inject } from 'aurelia-dependency-injection';
import { getLogger } from 'aurelia-logging';
import { Loader } from 'aurelia-loader';
import { PLATFORM } from 'aurelia-pal';
import { GlobalStyleEngine } from './styles/global-style-engine';
 
@inject(Loader, GlobalStyleEngine)
export class UXConfiguration {
  private logger = getLogger('aurelia-ux');
 
  constructor(private loader: Loader, private globalStyleEngine: GlobalStyleEngine) { }
 
  public defaultConfiguration() {
    this.cssNormalize();
    return this;
  }
 
  public cssNormalize() {
    PLATFORM.moduleName('./styles/normalize.css');
    const fullCssPath = '@aurelia-ux/core/styles/normalize.css';
    this
      .loader
      .loadText(fullCssPath)
      .catch(err => {
        this.logger.warn('Aurelia-UX Core failed to load normalize.css, some visual errors may appear.', err);
      })
      .then(text => {
        if (text) {
          this.globalStyleEngine.addOrUpdateGlobalStyle(fullCssPath, text);
        }
      });
 
    return this;
  }
}