añado cosas

pull/1/head
Borja Robert 2 years ago
parent b52e79acac
commit 444bfbb60a

@ -0,0 +1,24 @@
FROM node:18
WORKDIR /app
# COPY package.json and package-lock.json files
COPY package*.json ./
COPY vite.config.js ./
# COPY tsconfig.json file
COPY jsconfig.json ./
# COPY
COPY . .
RUN npm install
RUN npm run build
RUN [ "chmod", "+x", "/app/start.sh"]
EXPOSE 3000
CMD [ "/app/start.sh" ]

@ -0,0 +1,4 @@
{
"schemaVersion": 2,
"dockerfilePath": "./Dockerfile"
}

@ -1,32 +1,43 @@
<script> <script>
import html2canvas from 'html2canvas';
import { title, subtitle, date, address, content, heading } from '$lib/stores/store';
import {title, subtitle, date, address, content, heading} from '$lib/stores/store' let newdate = '';
let inner;
let newdate = "";
const convertDateTime = (datetime) => { const convertDateTime = (datetime) => {
if (datetime == undefined) { if (datetime == undefined) {
return { return {
date: "", date: '',
time: "" time: ''
};
}; };
const year = datetime.split("-")[0]; }
const month = datetime.split("-")[1]; const year = datetime.split('-')[0];
const day = datetime.split("-")[2].split("T")[0]; const month = datetime.split('-')[1];
const time = datetime.split("T")[1]; const day = datetime.split('-')[2].split('T')[0];
const time = datetime.split('T')[1];
return { return {
date: `${day}/${month}`, date: `${day}/${month}`,
time: time, time: time
} };
} };
$: if ($date !== "") {newdate = convertDateTime($date)}; $: if ($date !== '') {
newdate = convertDateTime($date);
}
const takeScreenshot = async () => {
const res = await html2canvas(inner);
const image = await res.toDataURL('image/png');
const link = document.createElement('a');
link.download = 'cartel.png';
link.href = image;
link.click();
};
</script> </script>
<div class="preview"> <div class="preview">
<div class="result"> <div class="result" bind:this={inner}>
<div class="heading">{$heading}</div> <div class="heading">{$heading}</div>
<div class="title">{$title}</div> <div class="title">{$title}</div>
<div class="subtitle">{$subtitle}</div> <div class="subtitle">{$subtitle}</div>
@ -35,6 +46,7 @@
{#if newdate}<div class="time">{newdate.time}</div>{/if} {#if newdate}<div class="time">{newdate.time}</div>{/if}
<div class="address">{$address}</div> <div class="address">{$address}</div>
</div> </div>
<button on:click|preventDefault={takeScreenshot}>Descargar</button>
</div> </div>
<style> <style>

Loading…
Cancel
Save