Communitygithub.com

coastdigitalgroup/coastai-skills

设计一个系统化的日期和时间选择框架,管理日历网格、范围选择器和调度界面,确保精确性和可访问性。

coastai-skills 是什么?

该技能提供了一个完整的方法论,用于设计用户选择单个日期、日期范围或特定时间段时使用的界面。它强调了日期选择的高摩擦特性,需要处理如“下周二”或“本月最后一个周末”等复杂心智模型。该技能支持多种平台(如Claude Code、Cursor、Codex),其工作流包括选择输入模式(直接输入、选择器触发或内联显示)、设计日历网格、定义范围选择逻辑、确保可访问性以及规划响应式适配。核心决策规则包括始终允许手动输入、为远期日期提供年份/月份下拉选择、以及立即反馈无效选择。该技能旨在避免常见失败模式,如无限点击、隐藏输入、小触摸目标和混乱的范围表示,并提供了验证标准以确保符合WCAG AA可访问性标准。

兼容平台~Claude Code~Codex CLI~Cursor
npx skills add https://github.com/coastdigitalgroup/coastai-skills/tree/HEAD/website-design/calendar-and-date-system

在你喜欢的 AI 中提问

打开一个已预加载此 Agent Skill 的新对话。

文档

日历与日期选择系统

目的

日历与日期选择系统提供了一套方法论,用于设计允许用户选择单个日期、日期范围或特定时间段的界面。选择日期是一项高摩擦任务,涉及复杂的心智模型(例如“下周二”、“本月的最后一个周末”)。本系统确保日期选择器在视觉上清晰、易于通过键盘和触摸导航,并能即时提供有效性和可用性反馈。

用例

  • 预订与预约: 选择酒店入住/退房日期或航班出发日期。
  • 日程安排: 为会议、预约或配送选择时间段。
  • 分析与报告: 定义自定义日期范围(起始日期到结束日期)用于数据筛选。
  • 出生日期录入: 为年龄验证或资料设置捕获出生日期。
  • 活动规划: 在项目管理工具中管理截止日期或里程碑。

何时不使用

  • 简单日期: 如果只需一个众所周知的日期(如“今天”或“昨天”),请使用简单的按钮或链接。
  • 易记日期: 对于用户熟记的日期(如生日或信用卡到期日),使用标准文本输入框,类型为type="number"或type="tel",而不是日历网格,因为直接输入比在网格中导航更快。
  • 相对时间: 如果用户只需选择“最近7天”或“本月”,使用下拉菜单或按钮组即可,无需完整的日历。

输入

  1. 选择模式: 单个日期、日期范围或时间段。
  2. 约束条件: 最小/最大日期、禁用日期(例如过去的日期、已订满的时间段)。
  3. 上下文: 是独立的页面元素还是弹出框/模态框触发器?
  4. 本地化: 地区日期格式(MM/DD/YYYY 与 DD/MM/YYYY)以及一周的第一天(周日与周一)。

输出

  1. 网格结构说明: 月份标题、星期标签和日期单元格的视觉定义。
  2. 状态矩阵: 今天、已选择、范围起始、范围结束、在范围内、悬停和禁用状态的视觉处理。
  3. 输入连接说明: 日历如何与文本输入字段关联(触发器图标、格式化和手动输入支持)。
  4. 可访问性计划: 键盘快捷键(方向键、Enter、Escape)以及用于状态更新的ARIA实时区域。

工作流程

1. 选择输入模式

选择用户输入日期的方式:

  • 直接输入: 带掩码的文本输入框。最适合快速、已知日期的输入。
  • 选择器触发: 带有日历图标的输入框,用于打开覆盖层。适用于大多数用例。
  • 内联/持久显示: 日历始终在页面上可见。最适合日程密集型任务。

2. 设计日历网格

为月份视图建立一致的空间节奏:

  • 标题: 月份和年份,带有“上个月”和“下个月”导航按钮。
  • 星期行: 单字母或简短标签(S、M、T...)以便快速定位。
  • 7列网格: 确保每个日期单元格有足够的空间显示日期和潜在状态指示器(例如表示事件的小点)。

3. 定义范围逻辑(如适用)

选择范围时,界面必须跟踪三种状态:

  • 起始选择: 第一次点击的日期。
  • “跨度”: 起始日期与当前悬停位置之间的视觉连接。
  • 结束选择: 第二次点击的日期,确定范围。
  • 视觉反馈: 使用微妙的背景填充表示“在范围内”的日期,并为“起始”和“结束”端点使用不同的形状或更高的对比度。

4. 为可访问性设计

  • 键盘导航: 用户必须能够使用方向键在日期之间移动,使用 PageUp/PageDown 切换月份,并使用 Enter 键选择。
  • 焦点管理: 当选择器打开时,焦点应移动到当前选中的日期或“今天”。
  • ARIA 角色: 为日历使用 role="grid",为星期使用 role="columnheader",为日期使用 role="gridcell"。为当前选择使用 aria-selected="true"。

5. 规划响应式适配

  • 移动端视图: 在小屏幕上,单月视图通常最佳。对于范围选择,考虑垂直堆叠两个月或使用全屏覆盖层。
  • 触摸目标: 确保每个日期单元格至少为 44x44 像素,或提供足够的填充以防止意外点击。

决策规则

  • “先输入”规则: 始终允许用户在输入字段中手动输入日期。不要强迫用户使用日历。
  • 月份限制: 如果选择遥远的过去或将来的日期(例如 5 年以上),请提供年份/月份下拉选择器,而不是强迫用户多次点击“下个月”。
  • 即时反馈: 如果用户选择了无效日期(例如选择周日作为仅限工作日配送的日期),应立即显示上下文相关的错误消息,而不是等到表单提交。
  • 一周起始日: 默认使用用户所在地区设置(通常美国为周日,英国/EU为周一)。

约束条件

  • 可访问性: 所有日期状态必须满足 WCAG AA 对比度要求(4.5:1)。选定日期必须能够通过颜色以外的特征区分(例如实心背景与无背景)。
  • 响应式: 日历绝不能溢出视口。弹出式选择器应使用“翻转”逻辑,在输入框下方没有空间时保持可见。
  • 本地化: 支持不同的日期格式以及月份和日期名称的翻译。

常见失败模式

  • “无限点击”: 迫使用户点击 12 个月才能找到日期,而不是提供年份选择器。
  • 隐藏输入: 阻止用户输入日期,这会让高级用户和行动障碍用户感到沮丧。
  • 小目标: 设计只有 20 像素单元格的网格,在移动设备上无法使用。
  • 缺乏“今天”上下文: 未能高亮显示当前日期,使用户更难定位。
  • 混乱的范围: 未清晰区分范围的“起始”和“结束”,或未能显示“在范围内”的跨度。

验证标准

  • 用户仅使用键盘即可浏览日历并选择日期。
  • 支持在输入字段中手动输入文本并进行验证。
  • 今天的日期在视觉上与众不同,但不与选择项冲突。
  • 范围选择具有清晰的“起始”、“结束”和“跨度”视觉处理。
  • 日期单元格的触摸目标符合 44x44 像素建议(或最少 24x24 像素并带间距)。
  • 所有状态(悬停、选定、禁用)的对比度比满足 WCAG AA 标准。
  • 日历在移动设备上调整布局(或切换为全屏)。

Individual skills in this repo

This repo contains 20 individual skills — each has its own dedicated page.

coastdigitalgroup/coastai-skills

Design and implement a systematic framework for progressive disclosure using accordions, ensuring structural integrity, visual affordances, and accessibility across different content densities and devices.

coastdigitalgroup/coastai-skills

Design and implement a systematic framework for long-form content, managing readability, vertical rhythm, and information density to ensure a superior reading experience.

coastdigitalgroup/coastai-skills

Design and implement a systematic framework for informational elements that communicate state (Badges) and categorization (Tags) with clarity and accessibility.

coastdigitalgroup/coastai-skills

Design and implement a systematic framework for non-overlay notifications, managing global announcements and contextual inline alerts to communicate system states without interrupting the user's flow.

coastdigitalgroup/coastai-skills

Design and implement a systematic, asymmetrical bento-grid layout framework to organize diverse content types cohesively while maintaining strict visual hierarchy, logical focus order, and responsive flexibility.

coastdigitalgroup/coastai-skills

Design a responsive, mobile-first bottom navigation bar and persistent action dock system for mobile websites and web applications, establishing spatial anchors, tab bar anatomy, badge indicators, thumb-zone ergonomics, safe area inset handling, active/inactive state contrast, and desktop responsive adaptation rules.

coastdigitalgroup/coastai-skills

Design a mobile-first bottom sheet overlay system with configurable detents, drag affordances, safe area padding, responsive desktop modal/popover adaptation, and WCAG AA accessibility compliance.

coastdigitalgroup/coastai-skills

Design and implement a systematic framework for secondary navigation trails that provide orientation, context, and one-click access to parent levels in deep information architectures.

coastdigitalgroup/coastai-skills

Design and implement a systematic framework for buttons and interactive triggers, managing visual hierarchy, variant logic, and action grouping to ensure clear intent and accessible interaction.

coastdigitalgroup/coastai-skills

Design and implement a systematic framework for modular content containers that maintain hierarchy, structural integrity, and action alignment across variable content and responsive viewports.

coastdigitalgroup/coastai-skills

Design and implement a systematic framework for horizontal discovery components, managing navigation affordances, scroll behavior, and accessibility to ensure effective content density without compromising usability.

coastdigitalgroup/coastai-skills

Design a systematic, highly accessible, and developer-friendly UI layout framework for code blocks, snippet showcases, multi-file code tabs, line-highlighting, diff views, and syntax token contrast in technical documentation and developer platforms.

coastdigitalgroup/coastai-skills

Design a systematic framework for global command menus (Cmd+K panels) that combines keyboard-driven navigation, command execution, and shortcut discovery into an accessible, responsive overlay.

coastdigitalgroup/coastai-skills

Design and implement a systematic framework for threaded conversations, managing nesting depths, action hierarchies, and community signaling to foster engagement and readability.

coastdigitalgroup/coastai-skills

Design and implement a systematic framework for side-by-side comparison interfaces, managing high attribute density and responsive complexity to support informed decision-making.

coastdigitalgroup/coastai-skills

Design and implement a systematic framework for user privacy, managing consent banners, preference centers, and persistent privacy controls to balance legal compliance with user trust.

coastdigitalgroup/coastai-skills

Design and implement a systematic, highly accessible, and responsive visual layout framework for conversational chat widgets, live chat boxes, and chatbot panels that ensures clear message scannability, native focus flow, and seamless mobile keyboard adaptation.

coastdigitalgroup/coastai-skills

Design a systematic, accessible, and high-conversion framework for custom select dropdowns and comboboxes, defining anatomy, states, search-filtering, and responsive mobile-adaptive patterns.

coastdigitalgroup/coastai-skills

Design and specify a systematic dark theme framework, establishing rules for elevation-based surface colors, desaturated brand accents, text legibility, and media adaptation to ensure an accessible, low-fatigue experience.

coastdigitalgroup/coastai-skills

Design and implement a systematic color palette that ensures WCAG 2.2 accessibility compliance. Trigger this skill when asked to define brand colors, create UI themes, or establish a visual system for a website.

相关技能