Skip to content

Commit d56390e

Browse files
committed
goueliou: add to calendar button
1 parent fc57088 commit d56390e

File tree

2 files changed

+55
-5
lines changed

2 files changed

+55
-5
lines changed

frugal.css

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -343,6 +343,8 @@ p {
343343
}
344344

345345
.gouel-title {
346+
width: 101%;
347+
z-index: 10;
346348
position: sticky;
347349
top: 0px;
348350
background-color: var(--lite-bkg);
@@ -351,6 +353,11 @@ p {
351353
border-bottom: 1px solid var(--main-color);
352354
}
353355

356+
#gouel-fest-header {
357+
display: flex;
358+
justify-content: space-between;
359+
}
360+
354361
span.gouel-ville {
355362
font-weight: bold;
356363
}
@@ -522,8 +529,22 @@ span.gouel-ville-proche {
522529
.goueliou-page #question {
523530
font-size: 20px;
524531
}
525-
}
526532

533+
/* add-to-calendar-button */
534+
535+
add-to-calendar-button#goueliou-calendar-button::part(.atcb-button) {
536+
color: unset;
537+
background: unset;
538+
}
539+
540+
add-to-calendar-button#goueliou-calendar-button::part(.atcb-icon) {
541+
margin-left: 20px;
542+
margin-right: 20px;
543+
flex-grow: 1;
544+
flex-shrink: 1;
545+
width: auto;
546+
}
547+
}
527548

528549
@media screen and (min-width: 800px)
529550
/*DESKTOP*/

goueliou/index.html

Lines changed: 33 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@
6666
})();
6767
</script>
6868
<!-- End Matomo Code -->
69+
<script src="https://cdn.jsdelivr.net/npm/add-to-calendar-button@2" async defer></script>
6970
</head>
7071

7172
<body class="goueliou-page">
@@ -104,9 +105,13 @@ <h1>Kerlandrier.cc</h1>
104105
}, {})
105106
const goueliouElement = document.getElementById("goueliou");
106107
// Grist Timestamp to Readable Date
107-
const date_formatted = new Date(timestamp * 1000);
108-
const options = { weekday: 'long', day: 'numeric', month: 'short' };
109-
return date_formatted.toLocaleDateString('fr-FR', options);
108+
function formatDate(timestamp, options) {
109+
const date = new Date(timestamp * 1000);
110+
const style = { weekday: 'long', day: 'numeric', month: 'short' };
111+
if (options == "calendar") {
112+
return `${date.getFullYear()}-${String(date.getMonth() + 1).padStart(2, '0')}-${String(date.getDate()).padStart(2, '0')}`;
113+
}
114+
return date.toLocaleDateString('fr-FR', style);
110115
}
111116
Object.entries(goueliou).forEach(([month, fest]) => {
112117
// Creation des colonnes Mois
@@ -143,7 +148,31 @@ <h1>Kerlandrier.cc</h1>
143148

144149
// Nom du festival
145150
div.innerHTML = `
146-
<h2 id="gouel-title">${fest[i].Nom}</h2>
151+
<div id="gouel-fest-header">
152+
<h2 id="gouel-title">${fest[i].Nom}</h2>
153+
154+
<add-to-calendar-button
155+
styleLight="--btn-background: unset;
156+
--btn-text: unset;
157+
--font: "Barlow Condensed", sans-serif;
158+
159+
id="goueliou-calendar-button"
160+
name="[Festival] ${fest[i].Nom}"
161+
description=
162+
"<p>Ajouté depuis https://kerlandrier.cc/goueliou/\nWebsite: ${fest[i].Website}\nDescription: ${fest[i].Mots_cles}"
163+
startDate="${formatDate(fest[i].Date_debut, "calendar")}"
164+
endDate="${formatDate(fest[i].Date_fin, "calendar")}"
165+
location="${fest[i].Ville}"
166+
options="['Apple','Google','iCal']"
167+
timeZone="Europe/Paris"
168+
trigger="click"
169+
hideBackground="true"
170+
iCalFileName="Reminder-Event"
171+
hideTextLabelButton = "true"
172+
size="3"
173+
language="fr"
174+
/>
175+
</div>
147176
`;
148177
// Lien vers le site du festival
149178
if (fest[i].Website) {

0 commit comments

Comments
 (0)