Skip to content

Commit 6dcdecb

Browse files
committed
fixes issue #2
1 parent 635ceff commit 6dcdecb

File tree

2 files changed

+13
-14
lines changed

2 files changed

+13
-14
lines changed

src/lib/actions/filedrop.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,7 @@ export const filedrop = function (node: HTMLElement, opts?: FileDropOptions): Ac
185185
if (isNode(ev.target) && input.isEqualNode(ev.target)) {
186186
return;
187187
}
188+
ev.preventDefault();
188189
triggerEvent = ev;
189190
openDialog();
190191
}

src/lib/components/FileDrop/FileDrop.svelte

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,6 @@
55
import type { Events } from "../../event";
66
import type { FileDropOptions } from "../../options";
77
export let id: string = undefined;
8-
export let style: string = $$props.style;
9-
export let containerClass = $$props.class as string | undefined;
108
export let accept: string | string[] = undefined;
119
export let multiple: boolean = undefined;
1210
export let disabled: boolean = undefined;
@@ -19,7 +17,6 @@
1917
$: {
2018
options = {
2119
id,
22-
style,
2320
accept,
2421
disabled,
2522
clickToUpload,
@@ -40,13 +37,11 @@
4037
dispatch(type, ev.detail);
4138
};
4239
}
43-
4440
$: isMulti = (fileLimit === undefined || fileLimit > 1) && (multiple === undefined || multiple);
4541
</script>
4642

4743
<label
4844
{id}
49-
class:filedrop={!containerClass}
5045
use:filedrop={options}
5146
on:filedrop={proxy("filedrop")}
5247
on:filedialogcancel={proxy("filedialogcancel")}
@@ -58,15 +53,18 @@
5853
on:windowfiledragenter={proxy("windowfiledragenter")}
5954
on:windowfiledragleave={proxy("windowfiledragleave")}
6055
on:windowfiledragover={proxy("windowfiledragover")}
56+
on:dragenter
57+
on:dragleave
58+
on:dragover
6159
>
62-
<input type="file" />
6360
<slot>
64-
<p>Drag &amp; drop or select to upload {isMulti ? "files" : "a file "}</p>
61+
<p><span>Drag &amp; drop or select to upload {isMulti ? "files" : "a file "}</span></p>
6562
</slot>
63+
<input type="file" />
6664
</label>
6765

6866
<style>
69-
.filedrop {
67+
p {
7068
background-color: #f0f0f0;
7169
display: flex;
7270
flex-direction: column;
@@ -79,22 +77,22 @@
7977
outline-offset: -1.3em;
8078
padding: 0.475em;
8179
}
82-
.filedrop:focus {
80+
p:focus {
8381
border-color: #2196f3;
8482
}
85-
.filedrop:hover {
83+
p:hover {
8684
border-color: #343434;
8785
}
88-
.filedrop p {
86+
p span {
8987
transition: color 0.1s;
9088
transition: fill 0.1s;
9189
}
92-
.filedrop:focus p {
90+
p:focus span {
9391
color: #2196f3;
9492
fill: #2196f3;
9593
}
96-
.filedrop:hover p,
97-
p {
94+
p:hover span,
95+
p span {
9896
color: #373737;
9997
font-size: 1.2em;
10098
cursor: default;

0 commit comments

Comments
 (0)