summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorYasutake Yohei <61961825+yasutakeyohei@users.noreply.github.com>2026-11-20 15:08:45 +0900
committerYasutake Yohei <61961825+yasutakeyohei@users.noreply.github.com>2026-11-20 15:08:45 +0900
commite792bc503ace2ba71595abc1a9422800e6d1604e (patch)
treef52442765f9cc58b3ac38dd64e174a5931adc543
parent8159f27ea110872a62002553ff141be12eeabdf6 (diff)
ScheduleInteractive.astro: 絞り込み表示をカレンダー下の一覧の下に出す
- 表の上下に出していた変更を取り消す(一覧表は元どおり、上だけに表示) - カレンダー直下のその日の一覧の末尾に「絞り込み中:👶 子育て」を出す - 文言は filterNoteHtml にまとめ、カレンダー下と共用する
-rw-r--r--src/components/ScheduleInteractive.astro64
-rw-r--r--src/styles/custom.css3
2 files changed, 28 insertions, 39 deletions
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 `<p class="schedule-cal-filter-note">${
+ activeCategory === 'all'
+ ? '絞り込みなし(すべての予定を表示)'
+ : `絞り込み中:${filterLabel()}`
+ }</p>`;
+ }
+
function renderCalendar() {
const index = months.indexOf(currentMonth);
const [year, month] = currentMonth.split('-').map(Number);
@@ -224,11 +233,7 @@
).join('')}
${cells.join('')}
</div>
- <p class="schedule-cal-filter-note">${
- activeCategory === 'all'
- ? '絞り込みなし(すべての予定を表示)'
- : `絞り込み中:${filterLabel()}`
- }</p>
+ ${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 = `<h3>${title}</h3>${campaignHtml}${pubcommentHtml}<p>この日の予定はありません。</p>`;
+ detailsEl.innerHTML = `<h3>${title}</h3>${campaignHtml}${pubcommentHtml}<p>この日の予定はありません。</p>${filterNoteHtml()}`;
return;
}
@@ -361,7 +366,7 @@
})
.join('');
- detailsEl.innerHTML = `<h3>${title}</h3>${campaignHtml}${pubcommentHtml}<ul>${items}</ul>`;
+ detailsEl.innerHTML = `<h3>${title}</h3>${campaignHtml}${pubcommentHtml}<ul>${items}</ul>${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'),
- ];
+ const meetingStatus = ensureStatus(meetingsTable.parentElement, 'meeting');
+ const eventStatus = ensureStatus(eventsTable.parentElement, 'event');
- function updateTableStatus(statusList, type, total, visible) {
+ 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 = `<span class="schedule-table-status-text">${text}</span>`;
- 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 = `<span class="schedule-table-status-text">${text}</span>`;
+ 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);