日程视图把团队日历放在一块面板上:用于切换时间段的标题区、按事件排布的当前时段视图,以及点开事件后显示的详情。日历本身由日程表及其行为脚本负责;区块补上面板、一周的真实事件和抽屉。
日程视图
<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 传入事件和今天的日期来挂载行为脚本,并负责打开抽屉。在时间段和视图之间切换,以及排布月、周和日程列表,由行为脚本负责。创建、移动和保存事件、时区以及重复事件仍由应用负责,应用把当前显示时间段的事件交给日程表。
#无障碍
- 面板名为“Team calendar”,时间段名称是实时区域,会说明切换到了哪里。
- 日期数字以日期和当天的事件数命名;“更多”按钮说明还有多少个事件以及在哪一天。
- 事件以标题和时间命名。抽屉是以事件标题命名的模态对话框,关闭时把焦点还给该事件。
- 分类色从不单独出现:抽屉中会写出分类名称。