first version of proper braindump composer
This commit is contained in:
+52
-3
@@ -1,18 +1,67 @@
|
||||
import './styles/app.scss';
|
||||
import './styles/brain-dump.scss';
|
||||
import htmx from 'htmx.org';
|
||||
|
||||
window.htmx = htmx;
|
||||
|
||||
document.body.addEventListener('htmx:beforeRequest', function () {
|
||||
document.getElementById('request-failed').hidden = true;
|
||||
const error = document.getElementById('request-failed');
|
||||
if (error) error.hidden = true;
|
||||
});
|
||||
|
||||
document.body.addEventListener('htmx:responseError', function () {
|
||||
document.getElementById('request-failed').hidden = false;
|
||||
const error = document.getElementById('request-failed');
|
||||
if (error) error.hidden = false;
|
||||
});
|
||||
|
||||
document.body.addEventListener('htmx:sendError', function () {
|
||||
document.getElementById('request-failed').hidden = false;
|
||||
const error = document.getElementById('request-failed');
|
||||
if (error) error.hidden = false;
|
||||
});
|
||||
|
||||
function activateComposerTab(tab) {
|
||||
const composer = tab.closest('.task-composer');
|
||||
if (!composer) return;
|
||||
|
||||
composer.querySelectorAll('[role="tab"]').forEach((candidate) => {
|
||||
const selected = candidate === tab;
|
||||
candidate.setAttribute('aria-selected', String(selected));
|
||||
candidate.tabIndex = selected ? 0 : -1;
|
||||
const panel = document.getElementById(candidate.getAttribute('aria-controls'));
|
||||
if (panel) panel.hidden = !selected;
|
||||
});
|
||||
}
|
||||
|
||||
document.addEventListener('click', (event) => {
|
||||
const tab = event.target.closest('.task-composer [role="tab"]');
|
||||
if (tab) activateComposerTab(tab);
|
||||
|
||||
const closeButton = event.target.closest('[data-close-brain-dump-dialog]');
|
||||
if (closeButton) closeButton.closest('dialog')?.close();
|
||||
});
|
||||
|
||||
document.addEventListener('keydown', (event) => {
|
||||
const tab = event.target.closest?.('.task-composer [role="tab"]');
|
||||
if (!tab || !['ArrowLeft', 'ArrowRight', 'Home', 'End'].includes(event.key)) return;
|
||||
|
||||
const tabs = [...tab.closest('[role="tablist"]').querySelectorAll('[role="tab"]')];
|
||||
const currentIndex = tabs.indexOf(tab);
|
||||
const nextIndex = event.key === 'Home' ? 0
|
||||
: event.key === 'End' ? tabs.length - 1
|
||||
: (currentIndex + (event.key === 'ArrowRight' ? 1 : -1) + tabs.length) % tabs.length;
|
||||
event.preventDefault();
|
||||
tabs[nextIndex].focus();
|
||||
activateComposerTab(tabs[nextIndex]);
|
||||
});
|
||||
|
||||
document.body.addEventListener('htmx:afterSwap', (event) => {
|
||||
const dialog = event.detail.target?.querySelector('.brain-dump-proposal-dialog');
|
||||
if (!dialog) return;
|
||||
|
||||
dialog.addEventListener('close', () => dialog.remove(), {once: true});
|
||||
if (typeof dialog.showModal === 'function' && !dialog.open) dialog.showModal();
|
||||
});
|
||||
|
||||
document.addEventListener('click', (event) => {
|
||||
const button = event.target.closest('[data-weather-location]');
|
||||
if (!button) return;
|
||||
|
||||
@@ -0,0 +1,92 @@
|
||||
.task-composer__tabs {
|
||||
display: flex;
|
||||
gap: .5rem;
|
||||
padding: 0 25px 1rem;
|
||||
border-bottom: 1px solid #d9e6eb;
|
||||
|
||||
[role='tab'] {
|
||||
background: #eef8fb;
|
||||
border: 1px solid #b9d8e4;
|
||||
color: #075d7f;
|
||||
padding: .55rem .8rem;
|
||||
}
|
||||
|
||||
[role='tab'][aria-selected='true'] {
|
||||
background: #087aa9;
|
||||
border-color: #087aa9;
|
||||
color: #fff;
|
||||
}
|
||||
|
||||
[role='tab']:focus-visible {
|
||||
outline: 3px solid #f2ad00;
|
||||
outline-offset: 2px;
|
||||
}
|
||||
}
|
||||
|
||||
#manual-task-panel,
|
||||
#brain-dump-panel {
|
||||
padding: 25px;
|
||||
}
|
||||
|
||||
.brain-dump-feedback {
|
||||
margin-top: 1rem;
|
||||
}
|
||||
|
||||
.brain-dump-feedback--error {
|
||||
color: #8b1a1a;
|
||||
font-weight: 700;
|
||||
}
|
||||
|
||||
.brain-dump-proposal-dialog {
|
||||
width: min(720px, calc(100vw - 2rem));
|
||||
max-height: min(80vh, 760px);
|
||||
}
|
||||
|
||||
.brain-dump-proposal-dialog__content {
|
||||
display: grid;
|
||||
gap: 1rem;
|
||||
}
|
||||
|
||||
.brain-dump-proposal-list {
|
||||
display: grid;
|
||||
gap: .75rem;
|
||||
padding: 0;
|
||||
list-style: none;
|
||||
}
|
||||
|
||||
.brain-dump-proposal-list > li {
|
||||
padding: 1rem;
|
||||
border: 1px solid #d9e6eb;
|
||||
border-radius: .5rem;
|
||||
}
|
||||
|
||||
.brain-dump-proposal-list h3,
|
||||
.brain-dump-proposal-list h4,
|
||||
.brain-dump-proposal-list p {
|
||||
margin: 0 0 .4rem;
|
||||
}
|
||||
|
||||
.brain-dump-proposal-list__meta,
|
||||
.brain-dump-proposal-list li li span {
|
||||
color: #4f7280;
|
||||
font-size: .9rem;
|
||||
}
|
||||
|
||||
.brain-dump-proposal-list ul {
|
||||
display: grid;
|
||||
gap: .45rem;
|
||||
margin: .5rem 0 0;
|
||||
}
|
||||
|
||||
.brain-dump-proposal-list li li {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
gap: 1rem;
|
||||
}
|
||||
|
||||
.brain-dump-proposal-dialog__actions {
|
||||
display: flex;
|
||||
justify-content: flex-end;
|
||||
gap: .75rem;
|
||||
margin: 0;
|
||||
}
|
||||
Reference in New Issue
Block a user