Create FileList component
This commit is contained in:
parent
70edf6f11e
commit
5f8b7415a7
3 changed files with 48 additions and 36 deletions
|
@ -5,6 +5,7 @@
|
|||
let canvasRefs = [];
|
||||
</script>
|
||||
|
||||
{#if files.length !== 0}
|
||||
<div id="container" style="width: 100%; heigth: 100vh;">
|
||||
{#each Array.from(files) as file, i}
|
||||
<div class="canvas-container">
|
||||
|
@ -14,6 +15,7 @@
|
|||
{canvasRefs[i] && startFileRead(file, canvasRefs[i])}
|
||||
{/each}
|
||||
</div>
|
||||
{/if}
|
||||
|
||||
<style>
|
||||
#container {
|
||||
|
|
33
src/lib/FileList.svelte
Normal file
33
src/lib/FileList.svelte
Normal file
|
@ -0,0 +1,33 @@
|
|||
<script>
|
||||
export let files = [];
|
||||
</script>
|
||||
|
||||
{#if files.length !== 0}
|
||||
<div id="selected-files-container">
|
||||
<h2>Selected files:</h2>
|
||||
{#each Array.from(files) as file}
|
||||
<div id="selected-file-card">
|
||||
<p>{file.name} ({file.size / 1000} kb)</p>
|
||||
</div>
|
||||
{/each}
|
||||
</div>
|
||||
{/if}
|
||||
|
||||
<style>
|
||||
#selected-file-card {
|
||||
border: 1px solid #000;
|
||||
width: 500px;
|
||||
padding-left: 15px;
|
||||
margin-top: 10px;
|
||||
}
|
||||
|
||||
@media only screen and (max-device-width: 812px) {
|
||||
#selected-files-container {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
#selected-file-card {
|
||||
width: 100%;
|
||||
}
|
||||
}
|
||||
</style>
|
|
@ -1,5 +1,6 @@
|
|||
<script>
|
||||
import CardList from "./CardList.svelte";
|
||||
import FileList from "./FileList.svelte";
|
||||
|
||||
let files;
|
||||
let filesRendered = false;
|
||||
|
@ -82,19 +83,10 @@
|
|||
<input type="submit" value="Render files" />
|
||||
</form>
|
||||
|
||||
{#if files && files.length !== 0 && !filesRendered}
|
||||
<div id="selected-files-container">
|
||||
<h2>Selected files:</h2>
|
||||
{#each Array.from(files) as file}
|
||||
<div id="selected-file-card">
|
||||
<p>{file.name} ({file.size / 1000} kb)</p>
|
||||
</div>
|
||||
{/each}
|
||||
</div>
|
||||
{/if}
|
||||
|
||||
{#if files && files.length !== 0 && filesRendered}
|
||||
{#if filesRendered}
|
||||
<CardList {files} />
|
||||
{:else}
|
||||
<FileList {files} />
|
||||
{/if}
|
||||
|
||||
<style>
|
||||
|
@ -116,13 +108,6 @@
|
|||
display: none;
|
||||
}
|
||||
|
||||
#selected-file-card {
|
||||
border: 1px solid #000;
|
||||
width: 500px;
|
||||
padding-left: 15px;
|
||||
margin-top: 10px;
|
||||
}
|
||||
|
||||
#dropzone:hover {
|
||||
cursor: pointer;
|
||||
border: 5px dotted #05345f;
|
||||
|
@ -137,13 +122,5 @@
|
|||
#dropzone {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
#selected-files-container {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
#selected-file-card {
|
||||
width: 100%;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
|
|
Loading…
Reference in a new issue