-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
4289ef1
commit cf3b9f7
Showing
7 changed files
with
120 additions
and
89 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,37 +1,31 @@ | ||
<script> | ||
let files = null; | ||
$: () => { | ||
if (files) { | ||
console.log(files); | ||
for (const file of files) { | ||
console.log(`${file.name}: ${file.size} bytes`); | ||
} | ||
} | ||
}; | ||
let files = null; | ||
$: () => { | ||
if (files) { | ||
console.log(files); | ||
for (const file of files) { | ||
console.log(`${file.name}: ${file.size} bytes`); | ||
} | ||
} | ||
}; | ||
</script> | ||
|
||
<div class="flex items-center space-x-4"> | ||
<label | ||
for="file-upload" | ||
class="muted-red text-white py-2 px-4 rounded-lg cursor-pointer hover:bg-red-600"> | ||
Selecionar ficheiro | ||
</label> | ||
<label | ||
for="file-upload" | ||
class="muted-red cursor-pointer rounded-lg px-4 py-2 text-white hover:bg-red-600" | ||
> | ||
Selecionar ficheiro | ||
</label> | ||
|
||
<input | ||
id="file-upload" | ||
multiple | ||
type="file" | ||
bind:files | ||
class="hidden" | ||
/> | ||
<input id="file-upload" multiple type="file" bind:files class="hidden" /> | ||
|
||
{#if files} | ||
{#each Array.from(files) as file} | ||
<div class="bg-taupe-200 text-rose-950 py-2 px-4 rounded-lg"> | ||
<p>{file.name}</p> | ||
</div> | ||
{/each} | ||
{/if} | ||
{#if files} | ||
{#each Array.from(files) as file} | ||
<div class="rounded-lg bg-taupe-200 px-4 py-2 text-rose-950"> | ||
<p>{file.name}</p> | ||
</div> | ||
{/each} | ||
{/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 |
---|---|---|
@@ -1,38 +1,74 @@ | ||
<script lang='ts'> | ||
import Icon from '$lib/components/icons/icon.svelte'; | ||
import Icons from '$lib/components/icons/icons'; | ||
<script lang="ts"> | ||
import Icon from '$lib/components/icons/icon.svelte'; | ||
import Icons from '$lib/components/icons/icons'; | ||
export let text: string; | ||
let avatar, fileinput; | ||
const onFileSelected =(e)=>{ | ||
let image = e.target.files[0]; | ||
let reader = new FileReader(); | ||
reader.readAsDataURL(image); | ||
reader.onload = e => { | ||
avatar = e.target.result; | ||
}; | ||
} | ||
</script> | ||
export let text: string; | ||
let avatar, fileinput; | ||
<div id="app" class="flex items-center justify-center flex-col"> | ||
|
||
{#if avatar} | ||
<div class="flex h-[200px] w-[200px] rounded-md overflow-hidden relative"> | ||
<img class="h-[200px] w-[200px] object-cover" src="{avatar}" alt="Avatar" /> | ||
<button type="button" aria-label="Change Avatar" class="bg-rose-950 rounded-md h-[15%] w-[15%] flex items-center justify-center cursor-pointer absolute bottom-0 right-0 m-2" on:click={() => { fileinput.click(); }} on:keydown={(e) => { if (e.key === 'Enter' || e.key === ' ') { fileinput.click(); } }}> | ||
<Icon src={Icons.Edit} color="white" size="70%" /> | ||
</button> | ||
<input style="display:none" type="file" accept=".jpg, .jpeg, .png" on:change={(e) => onFileSelected(e)} bind:this={fileinput}> | ||
</div> | ||
{:else} | ||
<div class="bg-muted-red-400 flex items-center justify-center rounded-md h-[200px] w-[200px] text-center relative"> | ||
<p class="text-white font-medium">{text}<span class="text-4xl">*</span></p> | ||
<button type="button" aria-label="Change Avatar" class="bg-rose-950 rounded-md h-[15%] w-[15%] flex items-center justify-center cursor-pointer absolute bottom-0 right-0 m-2" on:click={() => { fileinput.click(); }} on:keydown={(e) => { if (e.key === 'Enter' || e.key === ' ') { fileinput.click(); } }}> | ||
<Icon src={Icons.Edit} color="white" size="60%" /> | ||
</button> | ||
<input style="display:none" type="file" accept=".jpg, .jpeg, .png" on:change={(e) => onFileSelected(e)} bind:this={fileinput}> | ||
</div> | ||
{/if} | ||
const onFileSelected = (e) => { | ||
let image = e.target.files[0]; | ||
let reader = new FileReader(); | ||
reader.readAsDataURL(image); | ||
reader.onload = (e) => { | ||
avatar = e.target.result; | ||
}; | ||
}; | ||
</script> | ||
|
||
<div id="app" class="flex flex-col items-center justify-center"> | ||
{#if avatar} | ||
<div class="relative flex h-[200px] w-[200px] overflow-hidden rounded-md"> | ||
<img class="h-[200px] w-[200px] object-cover" src={avatar} alt="Avatar" /> | ||
<button | ||
type="button" | ||
aria-label="Change Avatar" | ||
class="absolute bottom-0 right-0 m-2 flex h-[15%] w-[15%] cursor-pointer items-center justify-center rounded-md bg-rose-950" | ||
on:click={() => { | ||
fileinput.click(); | ||
}} | ||
on:keydown={(e) => { | ||
if (e.key === 'Enter' || e.key === ' ') { | ||
fileinput.click(); | ||
} | ||
}} | ||
> | ||
<Icon src={Icons.Edit} color="white" size="70%" /> | ||
</button> | ||
<input | ||
style="display:none" | ||
type="file" | ||
accept=".jpg, .jpeg, .png" | ||
on:change={(e) => onFileSelected(e)} | ||
bind:this={fileinput} | ||
/> | ||
</div> | ||
{:else} | ||
<div | ||
class="relative flex h-[200px] w-[200px] items-center justify-center rounded-md bg-muted-red-400 text-center" | ||
> | ||
<p class="font-medium text-white">{text}<span class="text-4xl">*</span></p> | ||
<button | ||
type="button" | ||
aria-label="Change Avatar" | ||
class="absolute bottom-0 right-0 m-2 flex h-[15%] w-[15%] cursor-pointer items-center justify-center rounded-md bg-rose-950" | ||
on:click={() => { | ||
fileinput.click(); | ||
}} | ||
on:keydown={(e) => { | ||
if (e.key === 'Enter' || e.key === ' ') { | ||
fileinput.click(); | ||
} | ||
}} | ||
> | ||
<Icon src={Icons.Edit} color="white" size="60%" /> | ||
</button> | ||
<input | ||
style="display:none" | ||
type="file" | ||
accept=".jpg, .jpeg, .png" | ||
on:change={(e) => onFileSelected(e)} | ||
bind:this={fileinput} | ||
/> | ||
</div> | ||
{/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 |
---|---|---|
@@ -1,23 +1,29 @@ | ||
<script lang='ts'> | ||
export let options: string[]; | ||
let selectedOption: string; | ||
<script lang="ts"> | ||
export let options: string[]; | ||
let selectedOption: string; | ||
</script> | ||
|
||
<div> | ||
{#each options as option} | ||
<input id="radio-{option}" class="radio-button hidden text-center" type="radio" bind:group={selectedOption} value={option}> | ||
<label | ||
class="m-1 justify-self-start rounded-lg bg-taupe-200 px-5 py-1 text-rose-950" | ||
for="radio-{option}" | ||
> | ||
{option} | ||
</label> | ||
{/each} | ||
{#each options as option} | ||
<input | ||
id="radio-{option}" | ||
class="radio-button hidden text-center" | ||
type="radio" | ||
bind:group={selectedOption} | ||
value={option} | ||
/> | ||
<label | ||
class="m-1 justify-self-start rounded-lg bg-taupe-200 px-5 py-1 text-rose-950" | ||
for="radio-{option}" | ||
> | ||
{option} | ||
</label> | ||
{/each} | ||
</div> | ||
|
||
<style> | ||
.radio-button:checked + label { | ||
background-color: theme('colors.muted-red.400'); | ||
color: theme('colors.taupe.100'); | ||
} | ||
.radio-button:checked + label { | ||
background-color: theme('colors.muted-red.400'); | ||
color: theme('colors.taupe.100'); | ||
} | ||
</style> |
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 |
---|---|---|
@@ -1,5 +0,0 @@ | ||
<script> | ||
import PictureInput from '$lib/components/forms/picture-input.svelte'; | ||
</script> | ||
|
||
<PictureInput text="Adicionar logo"/> | ||