aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/components/ScheduleInteractive.astro
diff options
context:
space:
mode:
authorYasutake Yohei <61961825+yasutakeyohei@users.noreply.github.com>2026-11-02 09:22:42 +0900
committerYasutake Yohei <61961825+yasutakeyohei@users.noreply.github.com>2026-11-02 09:22:42 +0900
commitc17312b14977cb8fb032e5f394a64aa0327abef2 (patch)
treea490ee29c68cbed867d068b92c230db77ec64b82 /src/components/ScheduleInteractive.astro
parentbbf533017650012d7ff4a898e890f402b4b52b1e (diff)
hp-archive: カレンダーに「今日」ボタンを追加
- 月表示の横に「今日」ボタンを置き、押すと今日の日付を選んでその月に戻る - ヘッダーの高さが変わらないよう行の高さを固定 - X投稿用のキャプチャ画像を追加
Diffstat (limited to 'src/components/ScheduleInteractive.astro')
-rw-r--r--src/components/ScheduleInteractive.astro14
1 files changed, 13 insertions, 1 deletions
diff --git a/src/components/ScheduleInteractive.astro b/src/components/ScheduleInteractive.astro
index 6bcbb1c..4e1894b 100644
--- a/src/components/ScheduleInteractive.astro
+++ b/src/components/ScheduleInteractive.astro
@@ -323,7 +323,10 @@
calendarEl.innerHTML = `
<div class="schedule-cal-header">
<button type="button" class="schedule-cal-nav" data-dir="-1" aria-label="前の月" ${index <= 0 ? 'disabled' : ''}>‹</button>
- <div class="schedule-cal-title">${year}年${month}月</div>
+ <div class="schedule-cal-mid">
+ <div class="schedule-cal-title">${year}年${month}月</div>
+ <button type="button" class="schedule-cal-today" aria-label="今日を選ぶ">今日</button>
+ </div>
<button type="button" class="schedule-cal-nav" data-dir="1" aria-label="次の月" ${index >= months.length - 1 ? 'disabled' : ''}>›</button>
</div>
<div class="schedule-cal-grid">
@@ -348,6 +351,15 @@
});
});
+ calendarEl.querySelectorAll('.schedule-cal-today').forEach((btn) => {
+ btn.addEventListener('click', () => {
+ selectedDate = todayKey;
+ currentMonth = todayMonth;
+ renderCalendar();
+ showDayDetails(selectedDate);
+ });
+ });
+
calendarEl.querySelectorAll('.schedule-cal-nav').forEach((btn) => {
btn.addEventListener('click', () => {
const next = months.indexOf(currentMonth) + Number(btn.dataset.dir);