Communitygithub.com

YepAPI/skills

Radix/shadcn Dialog, confirmation dialogs, sheets for mobile, focus trapping, scroll lock, and nested dialog support.

skills 是什麼?

skills is a Claude Code agent skill that radix/shadcn Dialog, confirmation dialogs, sheets for mobile, focus trapping, scroll lock, and nested dialog support.

相容平台~Claude Code~Codex CLI~Cursor
npx skills add https://github.com/YepAPI/skills/tree/HEAD/skills/modals-dialogs

在你喜歡的 AI 中提問

開啟一個已預先載入此 Agent Skill 的新對話。

說明文件

Modals & Dialogs

Rules

  • Use Radix Dialog or shadcn <Dialog> — accessible, focus-trapped, scroll-locked by default
  • Confirmation dialogs for destructive actions: "Delete this project?" with Cancel (secondary) and Delete (destructive) buttons
  • Sheets/drawers for mobile: <Sheet> from shadcn — slides from bottom or side, better touch target than centered modals
  • Focus trap: Radix handles automatically — first focusable element receives focus on open, returns on close
  • Scroll lock: prevent body scroll when modal is open — Radix handles this with <Dialog.Overlay>
  • Close triggers: Escape key, click outside overlay, explicit close button — all provided by Radix
  • Controlled state: open + onOpenChange props — don't rely on internal state for modals triggered by external events
  • Forms in dialogs: submit on Enter, close on success, show errors inline — don't close on validation failure
  • Mobile: use <Sheet> (bottom drawer) instead of centered <Dialog> for actions on small screens

Patterns

// Confirmation dialog with shadcn
import {
  AlertDialog, AlertDialogAction, AlertDialogCancel, AlertDialogContent,
  AlertDialogDescription, AlertDialogFooter, AlertDialogHeader,
  AlertDialogTitle, AlertDialogTrigger,
} from "@/components/ui/alert-dialog";

function DeleteButton({ onDelete }: { onDelete: () => Promise<void> }) {
  const [loading, setLoading] = useState(false);
  return (
    <AlertDialog>
      <AlertDialogTrigger asChild>
        <Button variant="destructive">Delete project</Button>
      </AlertDialogTrigger>
      <AlertDialogContent>
        <AlertDialogHeader>
          <AlertDialogTitle>Delete this project?</AlertDialogTitle>
          <AlertDialogDescription>
            This will permanently delete the project and all its data. This action cannot be undone.
          </AlertDialogDescription>
        </AlertDialogHeader>
        <AlertDialogFooter>
          <AlertDialogCancel>Cancel</AlertDialogCancel>
          <AlertDialogAction
            onClick={async () => { setLoading(true); await onDelete(); setLoading(false); }}
            disabled={loading}
          >
            {loading ? "Deleting..." : "Delete"}
          </AlertDialogAction>
        </AlertDialogFooter>
      </AlertDialogContent>
    </AlertDialog>
  );
}

// Sheet for mobile-friendly actions
import { Sheet, SheetContent, SheetHeader, SheetTitle, SheetTrigger } from "@/components/ui/sheet";

function MobileMenu() {
  return (
    <Sheet>
      <SheetTrigger asChild><Button variant="ghost" size="icon"><MenuIcon /></Button></SheetTrigger>
      <SheetContent side="bottom">
        <SheetHeader><SheetTitle>Actions</SheetTitle></SheetHeader>
        <nav className="flex flex-col gap-2 py-4">
          <Button variant="ghost">Edit</Button>
          <Button variant="ghost">Share</Button>
          <Button variant="destructive">Delete</Button>
        </nav>
      </SheetContent>
    </Sheet>
  );
}

Avoid

  • Building custom modals with position: fixed and manual focus management — use Radix/shadcn Dialog
  • Missing Escape key and click-outside-to-close — Radix handles both, don't override them
  • Centered modals on mobile for action menus — use bottom Sheet/Drawer for better thumb reach
  • Closing dialog on form validation failure — keep open, show inline errors, let user fix and resubmit
  • Nested dialogs without proper stacking context — if needed, use Radix's nested Dialog support with proper z-index

Individual skills in this repo

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

YepAPI/skills

WCAG 2.1 AA — semantic HTML, keyboard navigation, screen readers.

YepAPI/skills

CRUD generators, data tables, user management, role-based access, and bulk operations.

YepAPI/skills

Tool-use patterns, multi-step reasoning, agent orchestration, and structured outputs.

YepAPI/skills

Chat UI components, streaming responses with AI SDK, context window management, and RAG patterns.

YepAPI/skills

Monitor what ChatGPT and Gemini say about your brand using YepAPI.

YepAPI/skills

Web analytics integration — event tracking, custom dashboards, privacy-first.

YepAPI/skills

Framer Motion — transitions, scroll animations, layout animations.

YepAPI/skills

OpenAPI 3.1 from Zod schemas, interactive docs with Swagger/Scalar, versioning, and example requests for every endpoint.

YepAPI/skills

Authentication security — bcrypt/argon2 hashing, brute force protection, secure password resets.

YepAPI/skills

Session auth, social providers, CSRF protection, and secure cookie patterns.

YepAPI/skills

Queue workers with BullMQ/Inngest/Trigger.dev, job retries, dead letter queues, concurrency.

YepAPI/skills

Link building research and backlink audit using YepAPI.

YepAPI/skills

MDX blog setup, RSS feed generation, sitemap.xml, structured data/JSON-LD, and related posts.

YepAPI/skills

Redis caching, CDN cache headers, stale-while-revalidate, cache invalidation, React Query.

YepAPI/skills

Recharts/Chart.js data visualization — bar, line, area, pie charts.

YepAPI/skills

Commander.js, interactive prompts with Clack, spinners, colors, config files, exit codes, and npm publishing.

YepAPI/skills

cmdk integration, Cmd+K trigger, fuzzy search, grouped actions, keyboard navigation, and dynamic action registration.

YepAPI/skills

Threaded comments, @mentions, reactions, moderation queue, optimistic UI, and cursor pagination.

YepAPI/skills

Competitive analysis between domains using YepAPI.

YepAPI/skills

Experiment setup, variant splitting, statistical significance, and feature flag integration.

相關技能