From e792bc503ace2ba71595abc1a9422800e6d1604e Mon Sep 17 00:00:00 2001 From: Yasutake Yohei <61961825+yasutakeyohei@users.noreply.github.com> Date: Fri, 20 Nov 2026 15:08:45 +0900 Subject: ScheduleInteractive.astro: 絞り込み表示をカレンダー下の一覧の下に出す MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 表の上下に出していた変更を取り消す(一覧表は元どおり、上だけに表示) - カレンダー直下のその日の一覧の末尾に「絞り込み中:👶 子育て」を出す - 文言は filterNoteHtml にまとめ、カレンダー下と共用する --- src/components/ScheduleInteractive.astro | 66 ++++++++++++++------------------ src/styles/custom.css | 3 -- 2 files changed, 29 insertions(+), 40 deletions(-) (limited to 'src') diff --git a/src/components/ScheduleInteractive.astro b/src/components/ScheduleInteractive.astro index b795613..765e877 100644 --- a/src/components/ScheduleInteractive.astro +++ b/src/components/ScheduleInteractive.astro @@ -163,6 +163,15 @@ return list.filter(matchesCategory); } + // いまの絞り込み状態を表す一文(カレンダー直下と、その日の一覧の下で共用) + function filterNoteHtml() { + return `

${ + activeCategory === 'all' + ? '絞り込みなし(すべての予定を表示)' + : `絞り込み中:${filterLabel()}` + }

`; + } + function renderCalendar() { const index = months.indexOf(currentMonth); const [year, month] = currentMonth.split('-').map(Number); @@ -224,11 +233,7 @@ ).join('')} ${cells.join('')} -

${ - activeCategory === 'all' - ? '絞り込みなし(すべての予定を表示)' - : `絞り込み中:${filterLabel()}` - }

+ ${filterNoteHtml()} `; calendarEl.querySelectorAll('.schedule-cal-day[data-date]').forEach((btn) => { @@ -348,7 +353,7 @@ document.dispatchEvent(new CustomEvent('schedule:day', { detail })); if (list.length === 0) { - detailsEl.innerHTML = `

${title}

${campaignHtml}${pubcommentHtml}

この日の予定はありません。

`; + detailsEl.innerHTML = `

${title}

${campaignHtml}${pubcommentHtml}

この日の予定はありません。

${filterNoteHtml()}`; return; } @@ -361,7 +366,7 @@ }) .join(''); - detailsEl.innerHTML = `

${title}

${campaignHtml}${pubcommentHtml}`; + detailsEl.innerHTML = `

${title}

${campaignHtml}${pubcommentHtml}${filterNoteHtml()}`; detailsEl.querySelectorAll('a.schedule-day-link').forEach((a) => { a.addEventListener('click', () => { const href = a.getAttribute('href') ?? ''; @@ -398,51 +403,38 @@ return `${activeCategory} ${categoryLabel(activeCategory)}`; } - function ensureStatus(container, type, where = 'before') { - const id = `${type}-filter-status-${where}`; + function ensureStatus(container, type) { + const id = `${type}-filter-status`; let status = document.getElementById(id); if (!status) { status = document.createElement('div'); status.id = id; - status.className = - where === 'after' - ? 'schedule-table-status schedule-table-status--below' - : 'schedule-table-status'; + status.className = 'schedule-table-status'; status.setAttribute('role', 'status'); status.setAttribute('aria-live', 'polite'); - if (where === 'after') container.after(status); - else container.parentElement.insertBefore(status, container); + container.parentElement.insertBefore(status, container); } return status; } - // 表の上と下の両方に、絞り込みの状態を出す(長い表でも見失わないように)。 - const meetingStatus = [ - ensureStatus(meetingsTable.parentElement, 'meeting', 'before'), - ensureStatus(meetingsTable.parentElement, 'meeting', 'after'), - ]; - const eventStatus = [ - ensureStatus(eventsTable.parentElement, 'event', 'before'), - ensureStatus(eventsTable.parentElement, 'event', 'after'), - ]; - - function updateTableStatus(statusList, type, total, visible) { + const meetingStatus = ensureStatus(meetingsTable.parentElement, 'meeting'); + const eventStatus = ensureStatus(eventsTable.parentElement, 'event'); + + function updateTableStatus(status, type, total, visible) { const tableLabel = type === 'meeting' ? '審議会等・市議会' : 'イベント'; const filtered = activeCategory !== 'all'; + status.classList.toggle('is-filtered', filtered); const text = filtered ? `${tableLabel}:「${filterLabel()}」で絞り込み中:${visible}件/全${total}件` : `${tableLabel}:全${total}件を表示しています(絞り込みなし)`; - for (const status of statusList) { - status.classList.toggle('is-filtered', filtered); - status.innerHTML = `${text}`; - if (filtered) { - const clear = document.createElement('button'); - clear.type = 'button'; - clear.className = 'schedule-table-status-clear'; - clear.textContent = '絞り込みを解除'; - clear.addEventListener('click', () => setActiveCategory('all')); - status.appendChild(clear); - } + status.innerHTML = `${text}`; + if (filtered) { + const clear = document.createElement('button'); + clear.type = 'button'; + clear.className = 'schedule-table-status-clear'; + clear.textContent = '絞り込みを解除'; + clear.addEventListener('click', () => setActiveCategory('all')); + status.appendChild(clear); } } diff --git a/src/styles/custom.css b/src/styles/custom.css index bfa0c0d..db35dd8 100644 --- a/src/styles/custom.css +++ b/src/styles/custom.css @@ -2409,9 +2409,6 @@ td.sanpi-open .sanpi-title { color: var(--sl-color-gray-3); font-size: 0.85rem; } -.schedule-table-status--below { - margin: 0.3rem 0 0.8rem; -} .schedule-table-status.is-filtered { border-color: var(--sl-color-accent); background: var(--sl-color-accent-low); -- cgit v1.3.1