creo el compontent text
parent
0cdd63439f
commit
362c697f79
@ -0,0 +1,23 @@
|
||||
import { getMonthName } from '$lib/monthName';
|
||||
/**
|
||||
* @param {string} date - Fecha del evento
|
||||
* @returns {string} - Fecha en dia (número) mes (letras)
|
||||
*/
|
||||
export const convertDate = (date) => {
|
||||
if (date == undefined) {
|
||||
return '';
|
||||
}
|
||||
/** @type {string} */ const monthNumber = date.split('-')[1];
|
||||
/** @type {string} */ let day = date.split('-')[2].split('T')[0];
|
||||
/** @type {number} */ const dayNumber = Number(day);
|
||||
/** @type {string} */ const month = getMonthName(monthNumber);
|
||||
|
||||
/** Removes 0 on single digit days */
|
||||
if (dayNumber < 10) {
|
||||
day = day.charAt(1);
|
||||
}
|
||||
|
||||
/** @type {string} */ const res = `${day} ${month}`;
|
||||
return res;
|
||||
};
|
||||
|
@ -0,0 +1,37 @@
|
||||
<script>
|
||||
import { templates } from '$lib/templates/templates';
|
||||
import {
|
||||
heading,
|
||||
title,
|
||||
subtitle,
|
||||
content,
|
||||
date,
|
||||
time,
|
||||
weekday,
|
||||
address
|
||||
} from '$lib/stores/store';
|
||||
|
||||
import { convertDate } from '$lib/convertDate';
|
||||
|
||||
/** @type number */ export let templateIndex;
|
||||
|
||||
const template = templates[templateIndex];
|
||||
|
||||
/** @type {string} */ let textDate;
|
||||
/** @type {string} */ let textHeading;
|
||||
/** @type {string} */ let textWeekday;
|
||||
|
||||
$: if ($date !== '') {
|
||||
textDate = convertDate($date);
|
||||
}
|
||||
$: if ($heading !== '') {
|
||||
textHeading = $heading;
|
||||
}
|
||||
$: if ($weekday !== '') {
|
||||
textWeekday = $weekday;
|
||||
}
|
||||
</script>
|
||||
|
||||
<div class="text" contenteditable="true">
|
||||
<p>El {textWeekday}, {textDate}, te invitamos a participar en el {textHeading}</p>
|
||||
</div>
|
Loading…
Reference in New Issue