Token导航 LogoToken导航TokenDH.com
前端设计操作浏览器github未标认证来源可访问许可证需确认审计通过

dialog-patternsdialog 模式

Agent Skill

dialog-patterns 用于处理 GitHub 仓库、Issue、Pull Request 和代码协作信息,适合在 Codex、Claude、Cursor、Gemini CLI 中需要围绕仓库状态、代码变更或协作事项进行整理时使用。可结合来源仓库、安装命令和原始 README 继续核验具体用法。安装前建议确认权限范围、维护状态,以及是否会触发联网、命令执行或文件读写。

总安装

840

周安装

35

GitHub Stars

37

下载量

280
CodexClaudeCursorGemini CLI

安装说明

本站只整理中文说明和来源信息,不托管安装包,也不代用户安装。

GitHub

来源数

2

许可证

unknown

最后核验

2026-05-01

来源状态

来源可访问

安装方式

通过对话安装

复制提示词发给支持本地命令或 Skills 的 AI 助手,先确认命令和权限,再让它执行。

请帮我安装这个 Agent Skill:dialog-patterns(dialog 模式)
来源仓库:https://github.com/majesticlabs-dev/majestic-marketplace
仓库路径:skills/dialog-patterns
安装命令:
npx skills add https://github.com/majesticlabs-dev/majestic-marketplace --skill dialog-patterns
安装前请先检查当前环境是否支持对应 CLI,并向我确认将要执行的命令、安装目录、联网范围和文件读写权限;确认后再执行。

命令行安装

复制命令到本机终端执行。该命令会通过 npx skills 从第三方来源获取 Skill;本站只展示命令,不托管安装包,也不自动执行。

skills.shnpx skills
npx skills add https://github.com/majesticlabs-dev/majestic-marketplace --skill dialog-patterns

简介

dialog-patterns 用于处理 GitHub 仓库、Issue、Pull Request 和代码协作信息,适合在 Codex、Claude、Cursor、Gemini CLI 中需要围绕仓库状态进行整理时使用。

  • 适用于前端开发中的模态对话框构建与用户交互界面设计场景。
  • 通过 npx skills add 命令从指定 GitHub 仓库安装,需确认权限与网络访问能力。
  • 使用前建议核实维护状态及是否涉及文件读写或外部依赖调用。
  • 适用宿主包括 Codex、Claude、Cursor、Gemini CLI,接入前应确认版本、权限和运行环境要求。

SKILL.md

Native Dialog Patterns for Rails

Build accessible, modern dialog UIs using the native HTML <dialog> element with Turbo Frames and Stimulus. No JavaScript frameworks or heavy libraries required.

When to Use This Skill

  • Building modal dialogs for forms, confirmations, or content
  • Creating toast/alert notifications
  • Implementing confirmation dialogs (delete, destructive actions)
  • Any overlay UI that needs focus management and accessibility

Why Native <dialog>?

FeatureNative <dialog>Custom Modal
Focus trappingBuilt-inManual implementation
ESC to closeBuilt-inManual implementation
BackdropBuilt-in (::backdrop)Manual overlay
AccessibilityNative role="dialog"Manual ARIA
Top layerAutomatic (above all content)z-index battles
Scroll lockAutomaticManual overflow: hidden

Zero-JavaScript Confirmation Dialogs (Recommended)

Modern browsers support the Invoker Commands API for declarative dialog control—no JavaScript required. See references/zero-js-patterns.md for complete examples.

Quick Reference

<%= button_tag "Delete", commandfor: "delete-#{post.id}", command: "show-modal" %>

<dialog id="delete-<%= post.id %>" closedby="any" role="alertdialog">
  <h3>Delete "<%= post.title %>"?</h3>
  <button commandfor="delete-<%= post.id %>" command="close">Cancel</button>
  <%= button_to "Delete", post, method: :delete %>
</dialog>

Key Attributes

AttributePurpose
commandfor="id"References the dialog to control
command="show-modal"Opens as modal (backdrop, focus trap)
command="close"Closes the dialog
closedby="any"Enables backdrop click and ESC to close

When to Use Zero-JS vs Stimulus

ScenarioApproach
Simple confirmationsZero-JS (Invoker Commands)
Modals with async contentStimulus + Turbo Frames
Complex multi-step dialogsStimulus controller
AnimationsCSS @starting-style

Additional Patterns (see references/)

  • CSS animations with @starting-style for enter/exit transitions
  • Turbo.config.forms.confirm to replace ugly browser dialogs
  • Progressive enhancement for cross-browser compatibility

Core Pattern: Async Modal with Turbo Frames

The recommended pattern for Rails modals combines three technologies:

  1. Turbo Frame - Async content loading without page reload
  2. Native <dialog> - Accessible modal presentation
  3. Stimulus controller - Lifecycle management

Step 1: Layout Container

Add a modal turbo-frame to your layout:

<%# app/views/layouts/application.html.erb %>
<body>
  <%= yield %>

  <%# Modal injection point %>
  <%= turbo_frame_tag :modal %>
</body>

Step 2: Trigger Links

Target the modal frame from any link:

<%# Any view %>
<%= link_to "New Post", new_post_path, data: { turbo_frame: :modal } %>
<%= link_to "Edit", edit_post_path(@post), data: { turbo_frame: :modal } %>
<%= link_to "Confirm Delete", confirm_delete_post_path(@post), data: { turbo_frame: :modal } %>

Step 3: Modal Content View

Wrap modal content in matching turbo-frame with nested inner frame:

<%# app/views/posts/new.html.erb %>
<%= turbo_frame_tag :modal do %>
  <%# Inner frame prevents flash during form validation %>
  <%= turbo_frame_tag :modal_content do %>
    <dialog data-controller="dialog" data-action="click->dialog#clickOutside" open>
      <article>
        <header>
          <h2>New Post</h2>
          <button data-action="dialog#close" aria-label="Close">&times;</button>
        </header>

        <%= render "form", post: @post %>
      </article>
    </dialog>
  <% end %>
<% end %>

Step 4: Stimulus Controller

Key behaviors: showModal() on connect, replaceChildren() on disconnect (prevents stale content), clickOutside for backdrop close.

See references/dialog-examples.md for full Stimulus controller, CSS styling, and Tailwind variant.

Why Nested Turbo Frames?

The nested frame pattern (modal > modal_content) prevents content flashing:

<%= turbo_frame_tag :modal do %>
  <%= turbo_frame_tag :modal_content do %>
    <dialog>...</dialog>
  <% end %>
<% end %>

Problem without nested frame: When a form inside the modal has validation errors and re-renders, the outer frame briefly shows the old content before replacing it.

Solution with nested frame: The inner frame handles form re-renders independently, keeping the modal structure stable.

Form Handling in Modals

Successful Submission

Redirect with Turbo to close modal and update page:

# app/controllers/posts_controller.rb
def create
  @post = Post.new(post_params)

  if @post.save
    redirect_to posts_path, notice: "Post created!"
  else
    render :new, status: :unprocessable_entity
  end
end

The redirect navigates _top (full page), effectively closing the modal.

Validation Errors

Re-render the form with 422 status to keep modal open:

render :new, status: :unprocessable_entity

Turbo Stream Response (Stay in Modal)

Use turbo_stream.update("modal", "") to clear modal without full redirect. See references/dialog-examples.md for full example.

Confirmation Dialog Pattern

For destructive actions: add a confirm_delete member route, render a dialog in a turbo frame, trigger via link_to with data: {turbo_frame::modal}.

See references/dialog-examples.md for full confirmation dialog view, route, and trigger.

Alert/Toast Pattern

For flash messages and notifications. Use show() instead of showModal() for non-modal presentation. See references/toast-slideover-patterns.md for complete implementation.

<dialog class="toast" data-controller="toast" data-toast-duration-value="5000">
  <p><%= message %></p>
</dialog>

Key difference: show() opens without backdrop or focus trap (toasts), showModal() centers with backdrop (modals).

Slideover Panel Pattern

For side panels (settings, filters, details). See references/toast-slideover-patterns.md for styling and animations.

<dialog class="slideover" data-controller="dialog" data-action="click->dialog#clickOutside">
  <aside>
    <header><h2>Filters</h2></header>
    <%= render "filters" %>
  </aside>
</dialog>

Accessibility

Native <dialog> provides focus trapping, ESC close, background inert, and top layer automatically. Additionally ensure:

  • Visible close button (not just ESC)
  • aria-labelledby / aria-describedby for descriptive context
  • Focus return to trigger element on close (store document.activeElement in connect())

See references/dialog-examples.md for enhanced accessibility and focus return examples.

Common Patterns Summary

PatternContainerStimulusshow method
Modal formturbo_frame_tag:modaldialogshowModal()
Confirmationturbo_frame_tag:modaldialogshowModal()
Toast/AlertFixed positiontoastshow()
Slideoverturbo_frame_tag:modaldialogshowModal()

Anti-Patterns to Avoid

Anti-PatternProblemSolution
Custom modal without <dialog>No native accessibilityUse native <dialog>
Missing nested turbo-frameContent flash on validationAdd inner frame
Not clearing frame on closeStale content on reopenClear with replaceChildren() in disconnect()
z-index for stackingBattles with other elements<dialog> uses top layer
Manual focus trapComplex, error-proneshowModal() handles it
Inline backdrop divExtra markupUse ::backdrop pseudo-element

Testing Dialogs

# System test - use `within "dialog"` to scope assertions
within "dialog" do
  fill_in "Title", with: "My Post"
  click_button "Create"
end
expect(page).not_to have_selector("dialog[open]")  # Modal closed

Browser Support

PatternChromeFirefoxSafari
Native <dialog>37+98+15.4+
Invoker Commands135+144+26.2+
@starting-style117+129+17.5+

For older browsers: dialog polyfill, invokers polyfill. See references/zero-js-patterns.md for progressive enhancement strategies.

适合场景

01

用户想查找某类 Agent Skill 时

02

需要根据任务场景推荐可安装能力包时

03

需要对比不同来源的安装命令和来源信息时

能力概览

能力 1

按任务关键词查找相关 Skills

能力 2

展示可复制的安装命令

能力 3

保留来源站点、仓库和原始说明,方便继续核验

能力 4

展示第三方安全扫描或审计结果

安装后应在对应宿主中按原始 README 的触发条件使用;具体调用方式请以来源页面和 README 为准。

平台分布

Codex

36.73%
按下载量换算103

Claude

29.33%
按下载量换算82

Cursor

19.91%
按下载量换算56

Gemini CLI

9.99%
按下载量换算28

安全审计

Gen Agent Trust Hub

通过

Socket

通过

Snyk

通过

权限和风险

操作浏览器

该 Skill 可能涉及浏览器控制能力,使用时可能读取或操作网页内容,需要在受控环境中确认权限边界。

安装前确认

本站仅展示第三方公开信息,不托管安装包,不提供自动安装或运行环境。安装前应自行审查源码、依赖和命令行为。当前只有一个来源,正式发布前建议补源仓库或其他目录站核验。

来源信息

继续浏览同类 Skills