Dialog WIP, mostly working.

Styling still needs tweaking and the Bible Gateway link needs to be
fixed.
This commit is contained in:
Benjamin A. Shelton 2026-08-06 15:41:25 -06:00
commit 69bb3f4ad3
Signed by: zancarius
GPG key ID: 8BD42DBD6C337E01
3 changed files with 59 additions and 9 deletions

View file

@ -63,8 +63,23 @@ const meta = `{
<dialog data-scripture="" <dialog data-scripture=""
class="p-0 bg-white rounded-sm w-full max-w-md m-auto flex-col flex hidden scripture"> class="p-0 bg-white rounded-sm w-full max-w-md m-auto flex-col flex hidden scripture">
<div tabindex="-1" autofocus class="p-4"> <div tabindex="-1" autofocus class="p-4">
<article> <button data-close="">
<span class="align-middle">close</span>
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-x-circle inline" viewBox="0 0 16 16">
<path d="M8 15A7 7 0 1 1 8 1a7 7 0 0 1 0 14m0 1A8 8 0 1 0 8 0a8 8 0 0 0 0 16"/>
<path d="M4.646 4.646a.5.5 0 0 1 .708 0L8 7.293l2.646-2.647a.5.5 0 0 1 .708.708L8.707 8l2.647 2.646a.5.5 0 0 1-.708.708L8 8.707l-2.646 2.647a.5.5 0 0 1-.708-.708L7.293 8 4.646 5.354a.5.5 0 0 1 0-.708"/>
</svg>
</button>
<article class="mt-6">
</article> </article>
<nav>
<a href="#">
Open on Bible Gateway
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-link inline" viewBox="0 0 16 16">
<path d="M6.354 5.5H4a3 3 0 0 0 0 6h3a3 3 0 0 0 2.83-4H9q-.13 0-.25.031A2 2 0 0 1 7 10.5H4a2 2 0 1 1 0-4h1.535c.218-.376.495-.714.82-1z"/>
<path d="M9 5.5a3 3 0 0 0-2.83 4h1.098A2 2 0 0 1 9 6.5h3a2 2 0 1 1 0 4h-1.535a4 4 0 0 1-.82 1H12a3 3 0 1 0 0-6z"/>
</svg></a>
</nav>
</div> </div>
</dialog> </dialog>
</article> </article>

View file

@ -136,6 +136,24 @@ dialog.scripture {
p:first-child { p:first-child {
@apply mt-0; @apply mt-0;
} }
p.poem-1, p.poem-2 {
@apply mb-0;
}
p.poem-2 {
@apply mt-0;
}
button[data-close] {
@apply absolute top-0 right-0 pr-2 pb-2 pt-2 text-sm text-gray-500 cursor-pointer hover:text-red-900;
span {
text-transform: uppercase;
}
}
nav {
@apply mt-8;
a {
@apply absolute bottom-0 right-0 text-sm text-blue-400 pr-4 pb-4;
}
}
} }
#notes-list { #notes-list {

View file

@ -35,7 +35,10 @@ function parseRef(ref) {
if (verses !== undefined) { if (verses !== undefined) {
if (verses.indexOf('-') < 0) { if (verses.indexOf('-') < 0) {
refdata['verse'] = verses; refdata['verses'] = {
start: verses,
end: verses
};
} else { } else {
refdata['verses'] = { refdata['verses'] = {
start: verses.substring(0, verses.indexOf('-')), start: verses.substring(0, verses.indexOf('-')),
@ -68,7 +71,7 @@ function parseRef(ref) {
function render(dialog, response) { function render(dialog, response) {
const content = response?.chapter?.content; const content = response?.chapter?.content;
const refs = parseRef('gen+1'); const refs = parseRef('gen+1:4');
let inSpan = false; let inSpan = false;
if (dialog === null || dialog === undefined) { if (dialog === null || dialog === undefined) {
@ -112,15 +115,22 @@ function render(dialog, response) {
continue continue
} }
if ('lineBreak' in v) { if ('lineBreak' in v) {
para.insertAdjacentElement('beforeend', document.createElement('br')); if (para.innerHTML.length != 0 || para.innerText.length != 0) {
section.insertAdjacentElement('beforeend', para);
para = document.createElement('p');
}
//para.insertAdjacentElement('beforeend', document.createElement('br'));
//para = document.createElement('p'); //para = document.createElement('p');
} }
if ('text' in v) { if ('text' in v) {
const span = document.createElement('span'); para.insertAdjacentText('beforeend', v.text);
span.insertAdjacentText('beforeend', v.text);
para.insertAdjacentElement('beforeend', span);
if ('poem' in v) { if ('poem' in v) {
span.classList.add('poem-'+v.poem); para.classList.add('poem-'+v.poem);
if (para.innerHTML.length != 0 || para.innerText.length != 0) {
section.insertAdjacentElement('beforeend',
para);
}
para = document.createElement('p');
} }
} }
} }
@ -162,6 +172,13 @@ export const bindModals = () => {
}); });
dialog[0]?.addEventListener('click', (evt) => { dialog[0]?.addEventListener('click', (evt) => {
evt.target === dialog[0] && dialog[0]?.close(); evt.target === dialog[0] && dialog[0]?.close();
dialog[0]?.querySelector('article')?.replaceChildren();
});
dialog[0]?.querySelector('button[data-close]')?.addEventListener('click', (evt) => {
evt.preventDefault();
dialog[0]?.close();
dialog[0]?.querySelector('article')?.replaceChildren();
}); });
}; };