From cf3b9f794b20b7e57fb3acaa48ede816feeca727 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1s=20Sucena=20Lopes?= Date: Wed, 27 Nov 2024 00:57:18 +0000 Subject: [PATCH] chore: format code --- src/lib/components/forms/files-input.svelte | 56 +++++----- .../components/forms/picture-input.stories.ts | 2 +- src/lib/components/forms/picture-input.svelte | 104 ++++++++++++------ .../components/forms/radio-buttons.stories.ts | 2 +- src/lib/components/forms/radio-buttons.svelte | 38 ++++--- src/lib/components/icons/icons.ts | 2 +- src/routes/(app)/(home)/+page.svelte | 5 - 7 files changed, 120 insertions(+), 89 deletions(-) diff --git a/src/lib/components/forms/files-input.svelte b/src/lib/components/forms/files-input.svelte index ed646f7a..4918d8d6 100644 --- a/src/lib/components/forms/files-input.svelte +++ b/src/lib/components/forms/files-input.svelte @@ -1,37 +1,31 @@ - +
- + - + -{#if files} - {#each Array.from(files) as file} -
-

{file.name}

-
- {/each} -{/if} + {#if files} + {#each Array.from(files) as file} +
+

{file.name}

+
+ {/each} + {/if}
- \ No newline at end of file diff --git a/src/lib/components/forms/picture-input.stories.ts b/src/lib/components/forms/picture-input.stories.ts index 66245260..57bc4812 100644 --- a/src/lib/components/forms/picture-input.stories.ts +++ b/src/lib/components/forms/picture-input.stories.ts @@ -7,7 +7,7 @@ export default { text: { control: 'text' } }, parameters: { - layout: 'centered', + layout: 'centered' } }; diff --git a/src/lib/components/forms/picture-input.svelte b/src/lib/components/forms/picture-input.svelte index 649e0926..d21d0650 100644 --- a/src/lib/components/forms/picture-input.svelte +++ b/src/lib/components/forms/picture-input.svelte @@ -1,38 +1,74 @@ - + export let text: string; + let avatar, fileinput; -
- - {#if avatar} -
- Avatar - - onFileSelected(e)} bind:this={fileinput}> -
- {:else} -
-

{text}*

- - onFileSelected(e)} bind:this={fileinput}> -
- {/if} + const onFileSelected = (e) => { + let image = e.target.files[0]; + let reader = new FileReader(); + reader.readAsDataURL(image); + reader.onload = (e) => { + avatar = e.target.result; + }; + }; + +
+ {#if avatar} +
+ Avatar + + onFileSelected(e)} + bind:this={fileinput} + /> +
+ {:else} +
+

{text}*

+ + onFileSelected(e)} + bind:this={fileinput} + /> +
+ {/if}
diff --git a/src/lib/components/forms/radio-buttons.stories.ts b/src/lib/components/forms/radio-buttons.stories.ts index c36dd561..ccb52f05 100644 --- a/src/lib/components/forms/radio-buttons.stories.ts +++ b/src/lib/components/forms/radio-buttons.stories.ts @@ -7,7 +7,7 @@ export default { options: { control: 'array' } }, parameters: { - layout: 'centered', + layout: 'centered' } }; diff --git a/src/lib/components/forms/radio-buttons.svelte b/src/lib/components/forms/radio-buttons.svelte index 5ededa51..6e939574 100644 --- a/src/lib/components/forms/radio-buttons.svelte +++ b/src/lib/components/forms/radio-buttons.svelte @@ -1,23 +1,29 @@ -
- {#each options as option} - - - {/each} + {#each options as option} + + + {/each}
diff --git a/src/lib/components/icons/icons.ts b/src/lib/components/icons/icons.ts index e4a1135c..9e5908ee 100644 --- a/src/lib/components/icons/icons.ts +++ b/src/lib/components/icons/icons.ts @@ -10,7 +10,7 @@ import { } from 'svelte-icons-pack/fa'; import { BiMap } from 'svelte-icons-pack/bi'; import { IoMail, IoClose, IoEye, IoEyeOff } from 'svelte-icons-pack/io'; -import { FiEdit2 } from "svelte-icons-pack/fi"; +import { FiEdit2 } from 'svelte-icons-pack/fi'; const Icons = { Instagram: FaBrandsInstagram, diff --git a/src/routes/(app)/(home)/+page.svelte b/src/routes/(app)/(home)/+page.svelte index daf05067..e69de29b 100644 --- a/src/routes/(app)/(home)/+page.svelte +++ b/src/routes/(app)/(home)/+page.svelte @@ -1,5 +0,0 @@ - - - \ No newline at end of file