-
Notifications
You must be signed in to change notification settings - Fork 131
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add GUI file dialog component (#199)
* Add text divider and space for file browser * Add initial file browser component * Make file browser functional and add warning * Support dragging onto custom file browser * Fix file browser dragging bug * Add explanation to big file warning * More informative oversize file warning * Bump GUI version to match OFRAK version * Remove file button but make header clickable * Make big div clickable instead of just header * Prevent dropdown and butotn clicks from bubbling * Update CHANGELOG * Add additional file browser text * Fix styling --------- Co-authored-by: Edward Larson <[email protected]>
- Loading branch information
1 parent
b602045
commit d0d58af
Showing
6 changed files
with
236 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
<style> | ||
button { | ||
padding-top: 0.5em; | ||
padding-bottom: 0.5em; | ||
padding-left: 1em; | ||
padding-right: 1em; | ||
margin-right: 2ch; | ||
} | ||
button:hover, | ||
button:focus { | ||
outline: none; | ||
box-shadow: inset 1px 1px 0 currentColor, inset -1px -1px 0 currentColor; | ||
} | ||
button:active { | ||
box-shadow: inset 2px 2px 0 currentColor, inset -2px -2px 0 currentColor; | ||
} | ||
.filelabel { | ||
cursor: pointer; | ||
font-family: inherit; | ||
font-size: inherit; | ||
color: inherit; | ||
background: inherit; | ||
border-color: inherit; | ||
box-shadow: none; | ||
user-select: none; | ||
line-height: inherit; | ||
} | ||
.filelabel span { | ||
width: 100%; | ||
margin-left: 2ch; | ||
background: inherit; | ||
color: inherit; | ||
/* border-bottom: 1px solid var(--main-fg-color); */ | ||
} | ||
input[type="file"] { | ||
display: none; | ||
} | ||
label { | ||
display: flex; | ||
flex-direction: row; | ||
flex-wrap: nowrap; | ||
justify-content: space-evenly; | ||
align-items: baseline; | ||
align-content: center; | ||
white-space: nowrap; | ||
} | ||
</style> | ||
|
||
<script> | ||
export let files, input; | ||
let dragging = false; | ||
</script> | ||
|
||
<div | ||
on:dragover|preventDefault="{() => (dragging = true)}" | ||
on:dragleave|preventDefault="{() => (dragging = false)}" | ||
on:drop|preventDefault="{(e) => { | ||
files = e.dataTransfer.files; | ||
dragging = false; | ||
}}" | ||
> | ||
{#if !dragging} | ||
<label class="filelabel"> | ||
<slot /> | ||
<input type="file" bind:this="{input}" bind:files="{files}" /> | ||
<span> | ||
<button on:click="{() => input.click()}"> Browse... </button> | ||
{#if files} | ||
{Array.from(files) | ||
.map((f) => f?.name) | ||
.join(", ")} | ||
{:else} | ||
No file selected. | ||
{/if} | ||
</span> | ||
</label> | ||
{:else} | ||
Drop the files to upload. | ||
{/if} | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
<style> | ||
div { | ||
width: 100%; | ||
margin: 2em 0; | ||
display: flex; | ||
flex-direction: row; | ||
flex-wrap: nowrap; | ||
align-items: center; | ||
justify-content: center; | ||
} | ||
hr { | ||
flex-grow: 1; | ||
border: none; | ||
color: inherit; | ||
border-bottom: 1px solid currentColor; | ||
} | ||
span { | ||
padding: 0 2ch; | ||
} | ||
</style> | ||
|
||
<script> | ||
export let color; | ||
</script> | ||
|
||
<div> | ||
<hr style:color="{color}" /> | ||
<span><slot /></span> | ||
<hr style:color="{color}" /> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters