File tree Expand file tree Collapse file tree 1 file changed +33
-2
lines changed
Expand file tree Collapse file tree 1 file changed +33
-2
lines changed Original file line number Diff line number Diff line change 77
88 export let label: string | null = null ;
99 let errorString = " " ;
10+ let loading = false ;
1011
1112 export let onDropped: OnDroppedCallback = (files ) => {
1213 console .warn (" Files were dropped but 'onDropped' callback is not set" );
2324 if (! files || files .length == 0 )
2425 return ;
2526
27+ loading = true ;
28+
2629 const errorRes: OnDroppedCallbackResult = await onDropped (files );
2730 const errType = typeof (errorRes );
2831
4043
4144 break ;
4245 }
46+
47+ loading = false ;
4348 }
4449
4550 function inputChange(e : Event ) {
7378
7479<style >
7580 .file-upload {
81+ position : relative ;
7682 text-align : center ;
7783 border : var (--panel-outline ) 2px solid ;
7884 transition : 0.25s ;
9298 padding : 20px ;
9399 }
94100
95- .file-upload-content h1 {
101+ .file-upload-label {
96102 margin : 0 ;
97103 }
98104
101107 height : 2em ;
102108 }
103109
110+ .file-upload-loading {
111+ background-color : var (--colorA );
112+ position : absolute ;
113+ top : 0 ;
114+ left : 0 ;
115+ width : 100% ;
116+ height : 100% ;
117+ display : flex ;
118+ align-items : center ;
119+ justify-content : center ;
120+ opacity : 0 ;
121+ pointer-events : none ;
122+ transition : 0.5s ;
123+ }
124+
125+ .file-upload-loading.visible {
126+ opacity : 1 ;
127+ pointer-events : unset ;
128+ }
129+
104130 </style >
105131
106132<div class ="file-upload panel" class:file-hover ={fileHover }>
107133 <div class =" file-upload-content" >
108134 {#if label }
109- <h1 >{label }</h1 >
135+ <h1 class = "file-upload-label" >{label }</h1 >
110136 {/if }
111137
112138 <div class =" file-upload-error" >
113139 {errorString }
114140 </div >
141+
115142 <div >
116143 Drag and drop a file or use <input type ="file" onchange ={inputChange } aria-label =" file picker" />
117144 </div >
145+
146+ <div class ="file-upload-loading" class:visible ={loading }>
147+ <h1 >Processing...</h1 >
148+ </div >
118149 </div >
119150</div >
You can’t perform that action at this time.
0 commit comments