К основному содержанию
скилл CX Codex

modal-drawer-system — скилл для Claude Code: обзор и установка

Скилл modal-drawer-system генерирует доступные модальные окна, боковые панели и нижние шторки на React с порталами, захватом фокуса и блокировкой прокрутки.

MIT 291 установок ★ 64 обновлён 2026-01-12

Установить в Claude Code · Через Skills CLI (Vercel) Все способы и платформы ↓
npx skills add patricio0312rev/skills --skill modal-drawer-system -a claude-code
Открыть на GitHub

Что делает modal-drawer-system

Скилл даёт ассистенту готовые шаблоны и правила для сборки всплывающих окон. Внутри предусмотрены рендеринг через createPortal прямо в корень document.body, отслеживание клавиши Escape, циклическая навигация по клавише Tab внутри окна и фиксация полосы прокрутки страницы при открытии оверлея.

Шаблоны компонентов написаны на TypeScript с директивой "use client" и используют иконки из библиотеки lucide-react. Для разметки сразу задаются атрибуты доступности: role="dialog", aria-modal="true", ссылки на заголовок и описание через aria-labelledby и aria-describedby.

Для корректного рендеринга иконок закрытия проект обязательно должен содержать установленный пакет lucide-react.

Какие задачи решает

  • настроить циклическую ловушку фокуса внутри диалогового окна
  • блокировать прокрутку страницы при открытом оверлее
  • собрать боковую панель или нижнюю шторку через портал React
  • сделать диалог подтверждения действия с правильной разметкой ARIA

Примеры запросов агенту

  • Создай модальное окно с формой редактирования профиля на базе modal-drawer-system
  • Сделай боковую панель Drawer справа с ловушкой фокуса и закрытием по Esc
  • Собери компонент ConfirmDialog с красной кнопкой удаления через Modal

Как установить modal-drawer-system

1Через Skills CLI (Vercel)

npx skills add patricio0312rev/skills --skill modal-drawer-system -a claude-code

2Вручную: положить файлы

~/.claude/skills/modal-drawer-system/SKILL.md

Папка скилла целиком; для одного проекта — .claude/skills/modal-drawer-system/

По шагам, с командами для каждой платформы: Как установить скилл в Claude Code: пять способов

Вопросы о modal-drawer-system

Как установить modal-drawer-system в Claude Code?

Выполните команду npx skills add patricio0312rev/skills --skill modal-drawer-system -a claude-code в терминале.

Что делает этот скилл?

Он обучает ИИ-ассистента генерировать доступные оверлеи: центральные модалки, боковые панели и подтверждающие диалоги с поддержкой клавиши Escape и ловушки фокуса.

Какие зависимости нужны для сгенерированного кода?

В компонентах используются React с хуками, createPortal из пакета react-dom и иконка закрытия из библиотеки lucide-react.

Исходный текст

SKILL.md · MIT
---
name: modal-drawer-system
description: Implements accessible modals and drawers with focus trap, ESC to close, scroll lock, portal rendering, and ARIA attributes. Includes sample implementations for common use cases like edit forms, confirmations, and detail views. Use when building "modals", "dialogs", "drawers", "sidebars", or "overlays".
---

# Modal & Drawer System Generator

Create accessible, polished modal dialogs and drawer components.

## Core Workflow

1. **Choose type**: Modal (center), Drawer (side), Bottom Sheet
2. **Setup portal**: Render outside DOM hierarchy
3. **Focus management**: Focus trap and restoration
4. **Accessibility**: ARIA attributes, keyboard shortcuts
5. **Animations**: Smooth enter/exit transitions
6. **Scroll lock**: Prevent body scroll when open
7. **Backdrop**: Click outside to close

## Base Modal Component

```typescript
"use client";

import { useEffect, useRef } from "react";
import { createPortal } from "react-dom";
import { X } from "lucide-react";

interface ModalProps {
  isOpen: boolean;
  onClose: () => void;
  title?: string;
  description?: string;
  children: React.ReactNode;
  size?: "sm" | "md" | "lg" | "xl" | "full";
  closeOnEscape?: boolean;
  closeOnBackdrop?: boolean;
}

export function Modal({
  isOpen,
  onClose,
  title,
  description,
  children,
  size = "md",
  closeOnEscape = true,
  closeOnBackdrop = true,
}: ModalProps) {
  const modalRef = useRef<HTMLDivElement>(null);

  // ESC key handler
  useEffect(() => {
    if (!isOpen || !closeOnEscape) return;

    const handleEscape = (e: KeyboardEvent) => {
      if (e.key === "Escape") onClose();
    };

    document.addEventListener("keydown", handleEscape);
    return () => document.removeEventListener("keydown", handleEscape);
  }, [isOpen, closeOnEscape, onClose]);

  // Focus trap
  useEffect(() => {
    if (!isOpen) return;

    const focusableElements = modalRef.current?.querySelectorAll(
      'button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])'
    );
    const firstElement = focusableElements?.[0] as HTMLElement;
    const lastElement = focusableElements?.[
      focusableElements.length - 1
    ] as HTMLElement;

    const handleTab = (e: KeyboardEvent) => {
      if (e.key !== "Tab") return;

      if (e.shiftKey && document.activeElement === firstElement) {
        e.preventDefault();
        lastElement?.focus();
      } else if (!e.shiftKey && document.activeElement === lastElement) {
        e.preventDefault();
        firstElement?.focus();
      }
    };

    firstElement?.focus();
    document.addEventListener("keydown", handleTab);
    return () => document.removeEventListener("keydown", handleTab);
  }, [isOpen]);

  // Body scroll lock
  useEffect(() => {
    if (isOpen) {
      document.body.style.overflow = "hidden";
    } else {
      document.body.style.overflow = "";
    }
    return () => {
      document.body.style.overflow = "";
    };
  }, [isOpen]);

  if (!isOpen) return null;

  const sizeClasses = {
    sm: "max-w-sm",
    md: "max-w-md",
    lg: "max-w-lg",
    xl: "max-w-xl",
    full: "max-w-full mx-4",
  };

  return createPortal(
    <div
      className="fixed inset-0 z-50 flex items-center justify-center"
      role="dialog"
      aria-modal="true"
      aria-labelledby={title ? "modal-title" : undefined}
      aria-describedby={description ? "modal-description" : undefined}
    >
      {/* Backdrop */}
      <div
        className="absolute inset-0 bg-black/50 backdrop-blur-sm animate-in fade-in"
        onClick={closeOnBackdrop ? onClose : undefined}
      />

      {/* Modal */}
      <div
        ref={modalRef}
        className={`relative z-10 w-full ${sizeClasses[size]} animate-in zoom-in-95 slide-in-from-bottom-4 duration-200`}
      >
        <div className="rounded-lg bg-white shadow-xl">
          {/* Header */}
          {(title || description) && (
            <div className="border-b px-6 py-4">
              {title && (
                <h2 id="modal-title" className="text-xl font-semibold">
                  {title}
                </h2>
              )}
              {description && (
                <p
                  id="modal-description"
                  className="mt-1 text-sm text-gray-600"
                >
                  {description}
                </p>
              )}
            </div>
          )}

          {/* Close button */}
          <button
            onClick={onClose}
            className="absolute right-4 top-4 rounded-lg p-1 hover:bg-gray-100"
            aria-label="Close modal"
          >
            <X className="h-5 w-5" />
          </button>

          {/* Content */}
          <div className="p-6">{children}</div>
        </div>
      </div>
    </div>,
    document.body
  );
}
```

## Drawer Component

```typescript
interface DrawerProps {
  isOpen: boolean;
  onClose: () => void;
  position?: "left" | "right" | "bottom";
  title?: string;
  children: React.ReactNode;
}

export function Drawer({
  isOpen,
  onClose,
  position = "right",
  title,
  children,
}: DrawerProps) {
  // Similar hooks as Modal (ESC, focus trap, scroll lock)

  const positionClasses = {
    left: "left-0 top-0 h-full w-80 animate-in slide-in-from-left",
    right: "right-0 top-0 h-full w-80 animate-in slide-in-from-right",
    bottom: "bottom-0 left-0 right-0 h-96 animate-in slide-in-from-bottom",
  };

  if (!isOpen) return null;

  return createPortal(
    <div className="fixed inset-0 z-50" role="dialog" aria-modal="true">
      <div
        className="absolute inset-0 bg-black/50 backdrop-blur-sm"
        onClick={onClose}
      />
      <div
        className={`absolute ${positionClasses[position]} bg-white shadow-xl`}
      >
        <div className="flex h-full flex-col">
          <div className="flex items-center justify-between border-b px-6 py-4">
            <h2 className="text-xl font-semibold">{title}</h2>
            <button onClick={onClose} aria-label="Close drawer">
              <X className="h-5 w-5" />
            </button>
          </div>
          <div className="flex-1 overflow-y-auto p-6">{children}</div>
        </div>
      </div>
    </div>,
    document.body
  );
}
```

## Common Use Cases

### Confirmation Dialog

```typescript
interface ConfirmDialogProps {
  isOpen: boolean;
  onClose: () => void;
  onConfirm: () => void;
  title: string;
  description: string;
  confirmText?: string;
  cancelText?: string;
  variant?: "danger" | "default";
}

export function ConfirmDialog({
  isOpen,
  onClose,
  onConfirm,
  title,
  description,
  confirmText = "Confirm",
  cancelText = "Cancel",
  variant = "default",
}: ConfirmDialogProps) {
  return (
    <Modal isOpen={isOpen} onClose={onClose} size="sm">
      <div className="space-y-4">
        <div>
          <h3 className="text-lg font-semibold">{title}</h3>
          <p className="mt-2 text-sm text-gray-600">{description}</p>
        </div>
        <div className="flex justify-end gap-3">
          <Button variant="outline" onClick={onClose}>
            {cancelText}
          </Button>
          <Button
            variant={variant === "danger" ? "destructive" : "default"}
            onClick={() => {
              onConfirm();
              onClose();
            }}
          >
            {confirmText}
          </Button>
        </div>
      </div>
    </Modal>
  );
}
```

### Edit Form Modal

```typescript
export function EditUserModal({ user, isOpen, onClose }: EditUserModalProps) {
  const [isSaving, setIsSaving] = useState(false);

  const handleSubmit = async (e: React.FormEvent) => {
    e.preventDefault();
    setIsSaving(true);
    // Save logic
    onClose();
  };

  return (
    <Modal isOpen={isOpen} onClose={onClose} title="Edit User" size="md">
      <form onSubmit={handleSubmit} className="space-y-4">
        <div>
          <Label htmlFor="name">Name</Label>
          <Input id="name" defaultValue={user.name} />
        </div>
        <div>
          <Label htmlFor="email">Email</Label>
          <Input id="email" type="email" defaultValue={user.email} />
        </div>
        <div className="flex justify-end gap-3">
          <Button type="button" variant="outline" onClick={onClose}>
            Cancel
          </Button>
          <Button type="submit" isLoading={isSaving}>
            Save Changes
          </Button>
        </div>
      </form>
    </Modal>
  );
}
```

### Detail View Drawer

```typescript
export function UserDetailDrawer({
  user,
  isOpen,
  onClose,
}: UserDetailDrawerProps) {
  return (
    <Drawer isOpen={isOpen} onClose={onClose} title={user.name}>
      <div className="space-y-6">
        <div className="flex items-center gap-4">
          <Avatar src={user.avatar} size="lg" />
          <div>
            <h3 className="font-semibold">{user.name}</h3>
            <p className="text-sm text-gray-600">{user.email}</p>
          </div>
        </div>
        <div className="space-y-4">
          <div>
            <h4 className="text-sm font-medium text-gray-700">Role</h4>
            <p className="mt-1">{user.role}</p>
          </div>
          <div>
            <h4 className="text-sm font-medium text-gray-700">Department</h4>
            <p className="mt-1">{user.department}</p>
          </div>
          <div>
            <h4 className="text-sm font-medium text-gray-700">Joined</h4>
            <p className="mt-1">{formatDate(user.joinedAt)}</p>
          </div>
        </div>
      </div>
    </Drawer>
  );
}
```

## Best Practices

1. **Portal rendering**: Render outside parent DOM
2. **Focus management**: Trap focus, restore on close
3. **Keyboard support**: ESC to close, Tab navigation
4. **ARIA attributes**: role, aria-modal, aria-labelledby
5. **Scroll lock**: Prevent body scroll when open
6. **Backdrop**: Click outside to close (optional)
7. **Animations**: Smooth enter/exit transitions
8. **Mobile responsive**: Full screen on small devices

## Output Checklist

- [ ] Modal component with portal
- [ ] Drawer component (left/right/bottom)
- [ ] Focus trap implementation
- [ ] ESC key handler
- [ ] Scroll lock on body
- [ ] Backdrop with click-to-close
- [ ] ARIA attributes
- [ ] Smooth animations
- [ ] Close button
- [ ] Sample use cases (confirm, edit, detail)

© patricio0312rev · MIT · patricio0312rev/skills

Похожие скиллы

Все скиллы по теме «Фронтенд и UI» →
modal-and-overlay-patterns dembrandt Скилл modal-and-overlay-patterns для Claude Code задаёт правила выбора и вёрстки всплывающих окон — от подсказок и шторок до блокирующих диалогов. CX Codex +1 862установок generic-react-design-system travisjneuman Скилл generic-react-design-system для Claude Code собирает правила и сниппеты дизайн-системы для React с Tailwind CSS, Framer Motion и WCAG AA. CX Codex +1 191установок ui-design-system platform-team Скилл ui-design-system задаёт единые правила для UI в React/TypeScript: токены, отступы, типографику и доступность. Нужен при создании и ревью компонентов. CX Codex +1 124установок gui-create-launch-modal dominikmartn Скилл gui-create-launch-modal для Claude Code создаёт одноразовое модальное окно запуска в GUI Warp. Окно показывается один раз на пользователя и включается feature flag. CX Codex +1 ★ 720звёзд репо color-system Owl-Listener Скилл color-system для Claude Code собирает палитру продукта: тональные шкалы, семантические роли и проверку контраста по WCAG. Помогает при создании или переделке цветовой системы с нуля. CX Codex +1 3 000установок tailwind-design-system sickn33 Скилл tailwind-design-system для Claude Code задаёт агенту рамки работы с Tailwind: токены, варианты компонентов, адаптивные паттерны и доступность. Помогает привести UI проекта к единому стилю. CX Codex +1 1 600установок

Из того же набора148

Весь набор →
table-builder Скилл table-builder генерирует таблицы данных на React с пагинацией, фильтрами, сортировкой и поддержкой серверного или клиентского рендеринга. CX Codex +1 293установок event-driven-architect Скилл event-driven-architect для Claude Code помогает проектировать событийную архитектуру: определять события, описывать их схемы и связывать публикацию с обработчиками. Также рассматривает CQRS и event sourcing. CX Codex +1 292установок input-validation-sanitization-auditor Скилл input-validation-sanitization-auditor находит и устраняет уязвимости XSS, SQL-инъекций и инъекций команд с помощью схем валидации и безопасных шаблонов кода. CX Codex +1 292установок prompt-template-builder Скилл prompt-template-builder для Claude Code собирает промпт из переиспользуемых частей: системной роли, переменных, формата ответа и примеров. Повторяющиеся запросы получают ответы в одном формате. CX Codex +1 291установок env-secrets-manager Скилл env-secrets-manager помогает разложить ключи и переменные окружения по местам: что коммитить в .env.example, что держать в AWS Secrets Manager, как проверить конфиг при старте. CX Codex +1 289установок api-security-hardener Скилл api-security-hardener добавляет в Express API проверку входа по схемам Zod, лимиты запросов на Redis и JWT-аутентификацию с ролями. CX Codex +1 289установок observability-setup Скилл observability-setup разворачивает в проекте трейсы OpenTelemetry, метрики Prometheus и структурные логи, добавляя к ним дашборд Grafana и черновики алертов. CX Codex +1 289установок agent-orchestration-planner Скилл agent-orchestration-planner для проектирования многошаговых агентов: цикл с инструментами, повторные попытки, память и лимит расходов в виде готовых схем на Python. CX Codex +1 288установок

Спонсоры проекта

Компании, которые помогают держать аналитику открытой