From 9c70564063b5633dea035944008c72620d3b72cb Mon Sep 17 00:00:00 2001 From: brobert Date: Tue, 27 Sep 2022 09:03:49 +0000 Subject: [PATCH] colabs (#3) Co-authored-by: Borja Robert Reviewed-on: https://git.server.brobert.net/brobert/carteles/pulls/3 --- src/lib/form/Colabs.svelte | 110 +++++++++++++++++++++++++++++++++ src/lib/form/Form.svelte | 20 +++--- src/lib/form/Organized.svelte | 19 +++--- src/lib/preview/Preview.svelte | 89 +++++++++++++++++++++++--- src/lib/stores/store.js | 2 +- src/routes/todos/+page.svelte | 1 - 6 files changed, 211 insertions(+), 30 deletions(-) create mode 100644 src/lib/form/Colabs.svelte diff --git a/src/lib/form/Colabs.svelte b/src/lib/form/Colabs.svelte new file mode 100644 index 0000000..e1ed355 --- /dev/null +++ b/src/lib/form/Colabs.svelte @@ -0,0 +1,110 @@ + + +
+ {#if $colabs[0]} + {#each $colabs as organization, i} +
+
{ + removecolabs(i); + }} + > + x +
+ + +
+ {/each} + {/if} +
+ + + onFileSelected(e)} + bind:this={fileinput} +/> + + diff --git a/src/lib/form/Form.svelte b/src/lib/form/Form.svelte index e2d32ee..16d5110 100644 --- a/src/lib/form/Form.svelte +++ b/src/lib/form/Form.svelte @@ -2,6 +2,7 @@ import { onMount } from 'svelte'; import html2canvas from 'html2canvas'; import Organized from '$lib/form/Organized.svelte'; + import Colabs from './Colabs.svelte'; import { title, heading, @@ -10,7 +11,7 @@ date, address, organizedBy, - collabs, + colabs, canvas } from '$lib/stores/store'; @@ -26,12 +27,14 @@ console.log('no hay editor'); return; } - $content = editor.firstChild.innerHTML; + if (editor && editor.firstChild !== null) { + $content = editor.firstChild.innerHTML; + } }; const downloadCanvas = async () => { if ($canvas !== undefined) { - const res = await html2canvas($canvas); + const res = await html2canvas($canvas, { backgroundColor: '#fffffff' }); const image = await res.toDataURL('image/png'); const link = document.createElement('a'); link.download = 'cartel.png'; @@ -95,6 +98,8 @@
+ +
@@ -134,13 +139,4 @@ font-size: 1.1rem; cursor: pointer; } - - .upload { - max-width: 48px; - cursor: pointer; - } - - .chan { - cursor: pointer; - } diff --git a/src/lib/form/Organized.svelte b/src/lib/form/Organized.svelte index 66c2412..896acc5 100644 --- a/src/lib/form/Organized.svelte +++ b/src/lib/form/Organized.svelte @@ -7,13 +7,13 @@ date, address, organizedBy, - collabs, + colabs, canvas } from '$lib/stores/store'; - let fileinput, avatar; + /** @type {HTMLInputElement} */ let fileinput; - const onFileSelected = (e) => { + const onFileSelected = (/** @type {Event} */ e) => { let image = e.target.files[0]; let reader = new FileReader(); reader.readAsDataURL(image); @@ -22,7 +22,7 @@ }; }; - const removeOrganizer = (index) => { + const removeOrganizer = (/** @type {number} */ index) => { if (index > -1) { $organizedBy.splice(index, 1); $organizedBy = $organizedBy; @@ -65,7 +65,7 @@ diff --git a/src/lib/stores/store.js b/src/lib/stores/store.js index 0b73f46..cb3a652 100644 --- a/src/lib/stores/store.js +++ b/src/lib/stores/store.js @@ -7,5 +7,5 @@ export const content = writable(""); export const date = writable(""); export const address = writable(""); export const organizedBy = writable([]); -export const collabs = writable([]); +export const colabs = writable([]); export const canvas = writable(); diff --git a/src/routes/todos/+page.svelte b/src/routes/todos/+page.svelte index adcbe22..992427a 100644 --- a/src/routes/todos/+page.svelte +++ b/src/routes/todos/+page.svelte @@ -89,7 +89,6 @@ } input:focus-visible { - box-shadow: inset 1px 1px 6px rgba(0, 0, 0, 0.1); border: 1px solid #ff3e00 !important; outline: none; }