-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.gjs
55 lines (51 loc) · 1.85 KB
/
index.gjs
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
import Component from '@glimmer/component';
import FileDropzone from 'ember-file-upload/components/file-dropzone';
import fileQueue from 'ember-file-upload/helpers/file-queue';
import { t } from 'ember-intl';
import Avatar from '../../../avatar';
import Instructions from './instructions';
import { action } from '@ember/object';
import { on } from '@ember/modifier';
import { Button } from '@frontile/buttons';
export default class OpenToFilesUpload extends Component {
@action
toggleFileSelector() {
// This is quite an ugly hack, but ... it works :shrug:
document.querySelector('#file-input').click();
}
<template>
{{#let (fileQueue onFileAdded=this.uploadPhoto) as |queue|}}
<FileDropzone @queue={{queue}} class='' as |dropzone|>
{{#if dropzone.active}}
<Instructions>
<span
class='text-xl font-black shadow-md text-white bg-gradient-to-r from-indigo-500 from-10% via-sky-500 via-30% to-emerald-500 to-90% px-6 py-2 rounded-lg'
>
{{t 'drag-and-drop.drop-now'}}
</span>
</Instructions>
{{else}}
<div class='relative w-full aspect-square'>
<div class='absolute top-0 left-0 w-full aspect-square'>
<Avatar
class='border-dashed border-4 border-slate-400'
@file='/images/unicorn.webp'
/>
</div>
<Instructions>
<Button @intent='primary' {{on 'click' this.toggleFileSelector}}>
{{t 'drag-and-drop.instructions'}}
<input
id='file-input'
type='file'
{{queue.selectFile}}
class='hidden'
/>
</Button>
</Instructions>
</div>
{{/if}}
</FileDropzone>
{{/let}}
</template>
}