all files / addon/components/polaris-button/ base.js

100% Statements 4/4
100% Branches 3/3
100% Functions 1/1
100% Lines 4/4
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 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59                                                        99×           93×                                            
import Component from '@ember/component';
import { computed } from '@ember/object';
import mapEventToAction from '../../utils/map-event-to-action';
 
export default Component.extend({
  classNames: ['Polaris-Button'],
  classNameBindings: [
    'primary:Polaris-Button--primary',
    'destructive:Polaris-Button--destructive',
    'disabled:Polaris-Button--disabled',
    'loading:Polaris-Button--loading',
    'outline:Polaris-Button--outline',
    'fullWidth:Polaris-Button--fullWidth',
    'plain:Polaris-Button--plain',
    'iconOnly:Polaris-Button--iconOnly',
    'sizeClass',
  ],
  attributeBindings: [
    'disabled',
    'accessibilityLabel:aria-label',
    'ariaControls:aria-controls',
    'ariaExpanded:aria-expanded',
  ],
 
  /*
   * Computed properties.
   */
  sizeClass: computed('size', function() {
    switch (this.get('size')) {
      case 'slim':
        return 'Polaris-Button--sizeSlim';
 
      case 'large':
        return 'Polaris-Button--sizeLarge';
 
      default:
        return null;
    }
  }).readOnly(),
 
  /*
   * When we have an icon and no text.
   *
   * @private
   * @property iconOnly
   * @type {Boolean}
   * @default false
   */
  iconOnly: false,
 
  /**
   * Action handlers.
   */
  click: mapEventToAction('onClick'),
  focusIn: mapEventToAction('onFocus'),
  focusOut: mapEventToAction('onBlur'),
});