日程檢視是放在一個面板上的團隊行事曆:用來切換期間的標頭、依該期間的事件資料呈現的行事曆內容,以及點開事件後顯示的詳細資料。行事曆的部分由日程表及其行為負責;區塊則加上面板、真實一週的事件和抽屜。
日程檢視
<section class="sheet p-lg" data-example="schedule-view" aria-label="Team calendar"> <div class="schedule-view" id="team"> <div class="schedule-view-header"> <button type="button" class="btn btn-sm schedule-view-today">Today</button> <button type="button" class="btn btn-sm btn-square btn-quiet schedule-view-previous" aria-label="Previous"> <svg class="icon" viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"> <path d="M6 3.5L10.3586 7.8586A0.2 0.2 0 0 1 10.3586 8.1414L6 12.5" transform="rotate(180 8 8)" /> </svg> </button> <button type="button" class="btn btn-sm btn-square btn-quiet schedule-view-next" aria-label="Next"> <svg class="icon" viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"> <path d="M6 3.5L10.3586 7.8586A0.2 0.2 0 0 1 10.3586 8.1414L6 12.5" /> </svg> </button> <h2 class="schedule-view-title" aria-live="polite">November 2026</h2> <div class="segmented segmented-sm schedule-view-switch" role="radiogroup" aria-label="View"> <label class="segmented-item"> <input type="radio" class="segmented-input" name="team-view" value="day">Day</label> <label class="segmented-item"> <input type="radio" class="segmented-input" name="team-view" value="week">Week</label> <label class="segmented-item"> <input type="radio" class="segmented-input" name="team-view" value="month" checked>Month</label> <label class="segmented-item"> <input type="radio" class="segmented-input" name="team-view" value="agenda">Agenda</label> </div> </div> <div class="schedule-view-body"></div> </div> <dialog class="dialog dialog-drawer" id="team-event" closedby="any" aria-labelledby="team-event-title"> <header class="dialog-header"> <p class="m(0)"> <span class="badge badge-category badge-dot" id="team-event-calendar"></span> </p> <h2 class="dialog-title" id="team-event-title"></h2> <p class="dialog-description" id="team-event-when"></p> </header> <div class="dialog-body"> <dl class="data-list"> <div class="data-list-item"> <dt class="data-list-term">Where</dt> <dd class="data-list-value" id="team-event-where"></dd> </div> <div class="data-list-item"> <dt class="data-list-term">Who</dt> <dd class="data-list-value" id="team-event-who"></dd> </div> </dl> </div> <footer class="dialog-footer"> <button type="button" class="btn" commandfor="team-event" command="close">Close</button> </footer> </dialog></section>import { schedule } from '@master/ui/behaviors/schedule.js'import { calendars, events } from './events.js'/** * A team calendar: the schedule behavior writes the period from the events, and an event, a button without a * link, opens its details in a drawer. Returns the function that stops it. */export function mount(root) { const view = root.querySelector('.schedule-view') const dialog = root.querySelector('dialog') const field = (name) => root.querySelector(`#team-event-${name}`) const detach = schedule(view, { events, today: '2026-11-13', locale: 'en-US', weekStart: 1, value: { date: '2026-11-13', view: 'month' } }) const controller = new AbortController() view.addEventListener('click', (click) => { const button = click.target.closest('button.schedule-event') const event = button && events.find((each) => each.id === button.value) if (!event) return const badge = field('calendar') badge.className = `badge badge-category badge-dot category-${event.category}` badge.textContent = calendars[event.category] field('title').textContent = event.title field('when').textContent = button.getAttribute('aria-label').slice(event.title.length + 2) field('where').textContent = event.where field('who').textContent = event.who // A day's list is a popover in the top layer; the drawer goes over it, and the list closes behind it. The // event's own button is then hidden, so when the drawer closes focus goes to the button that opened the list. const list = button.closest('[popover]') const opener = list ? view.querySelector(`[popovertarget="${list.id}"]`) : null list?.hidePopover() if (opener) dialog.addEventListener('close', () => opener.focus(), { once: true, signal: controller.signal }) dialog.showModal() }, { signal: controller.signal }) return () => { controller.abort() detach() if (dialog.open) dialog.close() }}/** * A week of a design team's calendar, as an application hands it to the schedule: days for all-day events, * local times for the others, each end exclusive, and a category for the calendar it belongs to. */export const calendars = { violet: 'Research', teal: 'Design system', orange: 'Launch', blue: 'Customers', green: 'Team',}export const events = [ { id: 'interviews', title: 'User interviews', start: '2026-11-03T10:00', end: '2026-11-03T11:30', category: 'violet', where: 'Room 4', who: 'Yi-ching, Misaki' }, { id: 'offsite', title: 'Design offsite', start: '2026-11-07', end: '2026-11-11', allDay: true, category: 'green', where: 'Lisbon', who: 'The whole team' }, { id: 'audit', title: 'Token audit', start: '2026-11-10T13:00', end: '2026-11-10T15:00', category: 'teal', where: 'Online', who: 'Kenta, Ji-hoon' }, { id: 'deploy', title: 'Deploy window', start: '2026-11-12T22:00', end: '2026-11-13T01:00', category: 'orange', where: 'On call', who: 'Seo-yeon' }, { id: 'launch', title: 'Launch day', start: '2026-11-13', end: '2026-11-14', allDay: true, category: 'orange', where: 'Everywhere', who: 'Everyone' }, { id: 'standup', title: 'Standup', start: '2026-11-13T09:00', end: '2026-11-13T09:15', category: 'green', where: 'Online', who: 'The whole team' }, { id: 'review', title: 'Design review', start: '2026-11-13T10:00', end: '2026-11-13T11:30', category: 'teal', where: 'Room 2', who: 'Yi-ching, Kenta' }, { id: 'lunch', title: 'Team lunch', start: '2026-11-13T12:00', end: '2026-11-13T13:00', category: 'green', where: 'Canteen', who: 'The whole team' }, { id: 'call', title: 'Customer call', start: '2026-11-13T14:00', end: '2026-11-13T15:00', category: 'blue', where: 'Online', who: 'Misaki' }, { id: 'retro', title: 'Retro', start: '2026-11-13T16:30', end: '2026-11-13T17:15', category: 'green', where: 'Room 4', who: 'The whole team' }, { id: 'planning', title: 'Planning', start: '2026-11-17T09:30', end: '2026-11-17T11:00', category: 'teal', where: 'Room 2', who: 'Ji-hoon' }, { id: 'synthesis', title: 'Research synthesis', start: '2026-11-18T14:00', end: '2026-11-18T16:00', category: 'violet', where: 'Room 4', who: 'Yi-ching' }, { id: 'conference', title: 'Design conference', start: '2026-11-19', end: '2026-11-22', allDay: true, category: 'violet', where: 'Berlin', who: 'Yi-ching, Misaki' }, { id: 'onboarding', title: 'Onboarding', start: '2026-11-24T10:00', end: '2026-11-24T12:00', category: 'blue', where: 'Room 1', who: 'Seo-yeon' },]點按日期數字開啟該日、點按事件查看詳細資料,或切換到週檢視或議程。
區塊提供可直接複製的標記,沿用頁面的文字顏色和字級。預覽在 body 上設定 fg-text-body text-sm。每個區塊都是尺寸容器,無論放在寬大的頁面、側邊欄大小的空間,還是對話框裡,都會依自身寬度重新排列。
#組成
- 由一個面板容納
schedule-view。它的標頭包含「今天」、「上一個」與「下一個」按鈕、期間名稱(變更時會由輔助技術宣告),以及在日、週、月和議程之間切換的分段控制項。 - 事件是資料。
events.js是應用程式交付的一週資料:全天事件以日期表示,其他事件以當地時間表示,事件範圍一律不含結束日期或結束時間,並以分類色標示所屬的行事曆。schedule行為負責排列這些事件,但從不編輯或儲存任何事件。 - 分類會寫出名稱。 每份行事曆的色彩都會在抽屜的徽章中搭配其名稱,事件的標題則說明事件的內容。
- 事件會開啟抽屜。 沒有連結的事件是一個
value為其 id 的按鈕;頁面監聽它,並在對話框抽屜中填入事件的時間、地點和參與者。某一天的事件清單是一個彈出面板,抽屜開啟時它會隨之關閉。 - 空間較窄時仍然易讀。 月檢視在日期數字下方為每個事件顯示一個圓點,標頭將期間名稱放在獨立的一行,議程則依日期列出整個月。
#哪些功能需要腳本
main.js 以事件資料和今天的日期掛上行為,並開啟抽屜。在期間與檢視之間移動,以及排列月、週和議程,都由行為負責。建立、移動和儲存事件,以及時區和重複事件,仍由應用程式處理,並將所顯示期間的事件交給日程表。
#無障礙
- 面板命名為「團隊行事曆」,期間名稱是一個即時區域,會說明切換到了哪個期間。
- 日期數字以其日期和當天的事件數命名;「更多」按鈕會說明還有幾個事件,以及是哪一天。
- 事件以其標題和時間命名。抽屜是以事件標題命名的強制回應對話框,關閉時會將焦點交回該事件。
- 分類色從不單獨出現:它的名稱會寫在抽屜中。