all files / addon/components/ polaris-skeleton-display-text.js

100% Statements 6/6
100% Branches 2/2
100% Functions 1/1
100% Lines 6/6
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 37 38 39 40 41 42 43 44                                                                13× 13×     13×        
import Component from '@ember/component';
import { computed } from '@ember/object';
import { classify } from '@ember/string';
 
const allowedSizes = [
  'small',
  'medium',
  'large',
  'extraLarge'
];
const defaultSize = 'medium';
 
export default Component.extend({
  classNames: ['Polaris-SkeletonDisplayText__DisplayText'],
  classNameBindings: ['sizeClass'],
 
  /**
   * Size of the text
   *
   * @property size
   * @public
   * @type {String}
   * @default 'medium'
   */
  size: defaultSize,
 
  /**
   * Class name to set the display text size.
   *
   * @property sizeClass
   * @private
   * @type {String}
   */
  sizeClass: computed('size', function() {
    let size = this.get('size');
    if (allowedSizes.indexOf(size) === -1) {
      size = defaultSize;
    }
 
    return `Polaris-SkeletonDisplayText--size${ classify(size) }`;
  }).readOnly(),
});