all files / addon/components/polaris-dropzone/ file-upload.js

50% Statements 4/8
100% Branches 0/0
0% Functions 0/2
50% Lines 4/8
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                                                                                                   
import Component from '@ember/component';
import layout from '../../templates/components/polaris-dropzone/file-upload';
import { computed } from '@ember/object';
import { readOnly } from '@ember/object/computed';
import { capitalize } from '@ember/string';
 
const iconDragDrop = 'drag-drop';
const assetFileUpload = '/ember-polaris/images/file-upload.svg';
const assetImageUpload = '/ember-polaris/images/image-upload.svg';
 
const fileUpload = {
  actionTitleFile: "Add file",
  actionTitleImage: "Add image",
  actionHintFile: "or drop files to upload",
  actionHintImage: "or drop images to upload"
}
 
export default Component.extend({
  layout,
  classNames: ['Polaris-FileUpload'],
 
  type: readOnly('context.type'),
  size: readOnly('context.size'),
 
  iconDragDrop,
  assetFileUpload,
  assetImageUpload,
 
  /**
   * String that appears in file upload
   *
   * @type {String}
   * @default `Add file`
   * @public
   */
  actionTitle: computed('type', function() {
    let type = this.get('type');
    return fileUpload[`actionTitle${ capitalize(type) }`];
  }),
 
  /**
   * String that appears in file upload
   *
   * @type {String}
   * @default `or drop files to upload`
   * @public
   */
  actionHint:  computed('type', function() {
    let type = this.get('type');
    return fileUpload[`actionHint${ capitalize(type) }`];
  }),
});