Skip to content

Commit

Permalink
add calendar modal
Browse files Browse the repository at this point in the history
  • Loading branch information
pizzapanther committed Nov 25, 2023
1 parent f0db3ed commit 613edd9
Show file tree
Hide file tree
Showing 3 changed files with 85 additions and 0 deletions.
68 changes: 68 additions & 0 deletions content/events.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,63 @@ menu:
.fc .fc-list-event:hover td {
background-color: rgba(55, 136, 216, 0.5);
}

dialog[open] {
opacity: 1;
transform: scaleY(1);
}

dialog {
opacity: 0;
transform: scaleY(0);
transition:
opacity 0.3s ease-out,
transform 0.3s ease-out,
overlay 0.3s ease-out allow-discrete,
display 0.3s ease-out allow-discrete;
/* Equivalent to
transition: all 0.7s allow-discrete; */
background: var(--body-background);
color: var(--card-text-color-main);
width: 80%;
max-width: 500px;
height: 320px;
max-height: 90%;
}

/* Before-open state */
/* Needs to be after the previous dialog[open] rule to take effect,
as the specificity is the same */
@starting-style {
dialog[open] {
opacity: 0;
transform: scaleY(0);
}
}

/* Transition the :backdrop when the dialog modal is promoted to the top layer */
dialog::backdrop {
background-color: rgb(0 0 0 / 0);
transition:
display 0.3s allow-discrete,
overlay 0.3s allow-discrete,
background-color 0.3s;
/* Equivalent to
transition: all 0.7s allow-discrete; */
}

dialog[open]::backdrop {
background-color: rgb(0 0 0 / 0.50);
}

/* This starting-style rule cannot be nested inside the above selector
because the nesting selector cannot represent pseudo-elements. */

@starting-style {
dialog[open]::backdrop {
background-color: rgb(0 0 0 / 0);
}
}
</style>

<div id="calendar-js"></div>
Expand All @@ -39,3 +96,14 @@ menu:
[iCal Calendar Subscription Link](webcal://calendar.google.com/calendar/ical/62da059a43acfa2924e50e6aaa43e3aed3728f7eda51af7d7a43f0313404e09c%40group.calendar.google.com/public/basic.ics)

</div>

<dialog id="dialog" class="main-article">
<div class="article-category" style="float: right; display: block">
<a href="javascript:void(0);" onclick="document.querySelector('#dialog').close();" style="font-weight: bold; border-radius: 30px; font-size: 12px;">X</a>
</div>
<h3>Narf</h3>
<hr style="margin: 0; width: 100%;">
<section class="article-content">
<p>content</p>
</section>
</dialog
13 changes: 13 additions & 0 deletions src/cal.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,19 @@ const calendar = new Calendar(calendarEl, {
left: 'prev,next today',
center: 'title',
right: 'listWeek,dayGridMonth'
},
eventClick: (info) => {
var e = info.event;
var title = e.title + '<br>' + e.start.toLocaleDateString() + ' ' + e.start.toLocaleTimeString();
title = title.replace(":00 ", " ");
document.querySelector('#dialog h3').innerHTML = title;
document.querySelector('#dialog section p').innerHTML = info.event.extendedProps.description || "<strong>no details found</strong>";
document.querySelector('#dialog').showModal();
setTimeout(() => {
document.querySelectorAll('#dialog section a').forEach((item) => {
item.target = '_blank';
});
}, 0);
}
});

Expand Down
4 changes: 4 additions & 0 deletions static/overrides.css
Original file line number Diff line number Diff line change
Expand Up @@ -48,3 +48,7 @@ p.j {
.columns > div:last-child {
margin-right: 0;
}

.article-content p a {
text-decoration: underline;
}

0 comments on commit 613edd9

Please sign in to comment.