Modal tests.
This commit is contained in:
parent
a530e8c4be
commit
2aeb21a7ba
3 changed files with 26 additions and 2 deletions
|
|
@ -37,6 +37,11 @@ const meta = `{
|
|||
|
||||
<Layout title=`${note.data.title} - ${note.data.sub_heading}`>
|
||||
{meta && <script type="application/ld+json" is:inline set:html={meta} />}
|
||||
<script type="module" src="/src/utils/modal.js"></script>
|
||||
<script>
|
||||
import { bindModals } from '../../utils/modal.js';
|
||||
bindModals();
|
||||
</script>
|
||||
<article class="mx-auto p-4 lg:p-0 lg:max-w-6xl xl:p-0 xl:max-w-6xl 2xl:p-0 2xl:max-w-6xl" id="notes-page">
|
||||
<div class="header">
|
||||
<hgroup>
|
||||
|
|
@ -55,5 +60,9 @@ const meta = `{
|
|||
<div id="content" class="p-6">
|
||||
<Content />
|
||||
</div>
|
||||
<dialog data-scripture=""
|
||||
class="p-8 bg-white rounded-sm w-full max-w-md m-auto flex-col flex hidden">
|
||||
<div tabindex="-1" autofocus></div>
|
||||
<p>Scripture dialog.</p></dialog>
|
||||
</article>
|
||||
</Layout>
|
||||
|
|
@ -54,6 +54,11 @@
|
|||
}
|
||||
}
|
||||
|
||||
html:has(dialog[open]:modal) {
|
||||
overflow: hidden;
|
||||
scrollbar-gutter: stable both-edges;
|
||||
}
|
||||
|
||||
body {
|
||||
@apply duration-700 transition-colors;
|
||||
@apply dark:bg-gray-900;
|
||||
|
|
|
|||
|
|
@ -3,8 +3,18 @@ export const modal = (el) => {
|
|||
};
|
||||
|
||||
export const bindModals = () => {
|
||||
const elems = document.querySelector('a[data-scripture]');
|
||||
const elems = document.querySelectorAll('a[data-scripture]');
|
||||
const dialog = document.querySelectorAll('dialog[data-scripture]');
|
||||
elems.forEach((e) => {
|
||||
console.log(e);
|
||||
e.addEventListener('click', (evt) => {
|
||||
const scripture = e.attributes.getNamedItem('data-scripture');
|
||||
evt.preventDefault();
|
||||
console.log(scripture);
|
||||
dialog[0]?.showModal();
|
||||
dialog[0]?.setAttribute('data-scripture', scripture);
|
||||
dialog[0]?.classList.remove("hidden");
|
||||
//document.body.classList.add("overflow-hidden");
|
||||
|
||||
});
|
||||
});
|
||||
};
|
||||
Loading…
Reference in a new issue