{"summary":"Sicherheitsdreieck und drei Verzögerungen für Kaskadenmenüs, damit das Untermenü auf dem schrägen Weg dorthin nicht versehentlich wechselt oder plötzlich schließt.","notes":"<p>Bewegt sich der Zeiger schräg vom übergeordneten Menü zum Untermenü, streift er zwangsläufig die Zeilen darunter. Ein gewöhnliches Menü wechselt zu jeder Zeile, über die der Zeiger fährt, das Untermenü verschwindet, und man muss zurück und es neu öffnen. Vier Regeln lösen das:</p>\n        <ol>\n        <li><strong>Sicherheitsdreieck</strong>: Gilt, wenn das Untermenü offen ist und sich der Zeiger darauf zubewegt. Die vorherige Zeigerposition bildet die Spitze, verbunden mit der oberen und unteren Ecke der zugewandten Seite des Untermenüs entsteht ein Dreieck. Solange der Zeiger im Dreieck bleibt, werden überfahrene Zeilen nicht hervorgehoben und öffnen kein eigenes Untermenü; erst wenn er das Dreieck verlässt, wechselt das Menü zur aktuellen Zeile.</li>\n        <li><strong>Wechselverzögerung</strong>: Bleibt der Zeiger innerhalb des Dreiecks auf einer Zeile stehen, will man diese Zeile. Nach mehr als 1.2 Sekunden wechselt das Menü zu ihr, damit das Untermenü nicht ewig unverändert bleibt.</li>\n        <li><strong>Öffnungsverzögerung</strong>: Für den Fall, dass der Zeiger schnell über eine Menüspalte streicht. Das Untermenü öffnet sich erst nach 220ms Hover, verlässt der Zeiger die Zeile früher, wird das Öffnen abgebrochen; so öffnet sich keine Reihe von Untermenüs nacheinander. Auf Touchscreens wirkt ein Tippen sofort.</li>\n        <li><strong>Schließverzögerung</strong>: Für den Fall, dass der Zeiger knapp über den Menürand hinausrutscht. Das Menü schließt sich erst 360ms nach dem Verlassen, kehrt der Zeiger rechtzeitig zurück, bleibt alles, wie es ist; ein Klick außerhalb des Menüs schließt es sofort.</li>\n        </ol>\n        <p>Außerdem wird die Hervorhebung der Zeilen über den Komponentenzustand gesteuert, nicht über <code>:hover</code> in CSS; sonst leuchten die Zeilen im Dreieck auf, obwohl das Menü nicht wechselt.</p>\n        <p>Der zugehörige Prompt baut diese Regeln in die bestehende Menükomponente des Projekts ein und behält ihre Schnittstelle und Tastaturbedienung bei; nur wenn es keine Menükomponente gibt, legt er eine neue an.</p>","prompt":"Define a cascading (nested) menu component that keeps its submenus steady:\na safe zone plus three delays, so submenus open on purpose, survive diagonal\nmoves toward them, and do not vanish on a brief slip out of the menu.\nIf the project already has a menu or dropdown component, build this into\nits existing submenu logic and keep its API, keyboard support and\naccessibility as they are. Otherwise create one reusable CascadeMenu:\n- Props: an anchor (the trigger button that opens it on click) and a tree\n  of items, each { label, icon?, href?, children? }. An item with children\n  is a folder row; one without is a plain row that navigates on click.\n- Each level shows its folder's name as a small title above its rows.\n- Keyboard: arrow keys move through rows, Right/Enter opens a folder,\n  Left goes back a level, Escape closes everything and returns focus to\n  the anchor. Use menu / menuitem roles and aria-expanded on folder rows.\n\nBehavior, with the values to use:\n1. Open delay: hovering a row schedules it to take effect after 220ms: a\n   folder row opens its submenu, a plain row closes any deeper submenu.\n   Leaving the row before then cancels it. Touch input acts at once.\n2. Safe zone: while a submenu is open, build a triangle from the pointer's\n   previous position to the two corners of the submenu's near edge (the\n   left edge's top and bottom for a submenu on the right). Track the last\n   two pointermove positions and use the older one as the apex, so the\n   triangle never collapses onto the current point. If the pointer is\n   inside that triangle and within the parent's last\n   min(90px, max(56px, 43% of the parent width)) toward the submenu, it is\n   on its way there: rows it crosses must not highlight or open their own\n   submenus.\n3. Safe window: a row hovered inside the safe zone does not switch the\n   submenu right away. Recheck every 80ms; switch once the pointer leaves\n   the zone, or when 1200ms have passed since the hover began, so a\n   pointer that simply stops there still gets its new submenu.\n4. Close delay: when the pointer leaves the anchor, every open level and\n   the safe zone, close the whole menu after 360ms. Coming back in time\n   cancels the close. Clicking outside closes at once.\n5. Dragging an item over a folder row opens it after 420ms instead of 220ms.\n6. The pointer inside an open submenu ends all protection.\nDrive row highlight from component state (hovered, active, skipped), not\nfrom CSS :hover, or rows crossed inside the safe zone will still light up.\n\nGeometry and motion:\n- Submenus open to the right, overlap their parent by 8px and align their\n  first row with the parent row. Flip to the left when there is no room;\n  the safe zone then uses the submenu's right edge.\n- Levels: 210-260px wide, sized to content, max height\n  min(420px, 100vh - 24px) with their own scroll, 6px padding, 12px radius,\n  1px border, backdrop-filter blur(18px) saturate(135%).\n- Rows: 32px tall, 8px radius, 4px apart, 0 8px padding, 8px gap; 18px\n  icon, 14px weight-500 label, a 16px chevron on folder rows. Level title:\n  11px, weight 600, quiet ink, padding 4px 8px 2px.\n- A submenu opens from its parent's edge: from translateX(-8px)\n  scale(0.88, 0.98) and opacity 0, with opacity over 170ms and transform\n  over 360ms on cubic-bezier(0.2, 1.45, 0.35, 1).\n- The root level opens the same way from its anchor: from translateY(-6px)\n  scale(0.96, 0.86), top-left origin. Keep the overshoot curve: the slight\n  spring is part of the feel.\n- A folder row's icon turns from a closed folder into an open one while its\n  submenu is open, and back when it closes, over 460ms on\n  cubic-bezier(0.22, 1, 0.36, 1). Morph the paths if the two glyphs share\n  their structure; otherwise cross-fade them with a slight lift of the\n  front panel.\n\nLight and dark themes come from tokens, not separate components:\n- Light: surface rgba(255,255,255,.96), border rgba(0,0,0,.14), row ink\n  #263140, row hover rgba(15,23,42,.07), quiet ink #7A8491, chevron\n  #94A3B8, shadow 0 18px 34px rgba(15,23,42,.12),\n  0 2px 4px rgba(15,23,42,.05), inset 0 1px 0 rgba(255,255,255,.74).\n- Dark, neutral grays with no blue cast: surface rgba(34,34,34,.96),\n  border rgba(255,255,255,.12), row ink #E4E4E4, row hover\n  rgba(255,255,255,.08), quiet ink #9A9A9A, chevron #8A8A8A, shadow\n  0 18px 34px rgba(0,0,0,.42), 0 2px 4px rgba(0,0,0,.2),\n  inset 0 1px 0 rgba(255,255,255,.06).\n- Monochrome brand icons invert in dark. Switching themes cross-fades\n  colors, borders and shadows over about 500ms.\n\nKeep every timing value as a named constant in one place, and keep the\nsafe-zone math in a pure, unit-tested helper (point-in-triangle by the\nsign of the three edge cross products). Add an optional debug overlay that\ndraws the zone (blue fill at 16%, dashed blue outline) and the running\ntimer, off by default.","skill":"/skills/kubai-cascade-menu/SKILL.md","skillText":"# 级联菜单的安全区域与延时\n\n《999 个小技巧，让你 Vibe 的产品更有质感》第 002 期 · @kubai087\n\n在用户的项目里按下面的要求改造。要求以用户的口吻写成：文中的 I、me、my 指用户；写着要先问的地方，先停下来问用户再继续。\n\n## 改造要求\n\nDefine a cascading (nested) menu component that keeps its submenus steady:\na safe zone plus three delays, so submenus open on purpose, survive diagonal\nmoves toward them, and do not vanish on a brief slip out of the menu.\nIf the project already has a menu or dropdown component, build this into\nits existing submenu logic and keep its API, keyboard support and\naccessibility as they are. Otherwise create one reusable CascadeMenu:\n- Props: an anchor (the trigger button that opens it on click) and a tree\n  of items, each { label, icon?, href?, children? }. An item with children\n  is a folder row; one without is a plain row that navigates on click.\n- Each level shows its folder's name as a small title above its rows.\n- Keyboard: arrow keys move through rows, Right/Enter opens a folder,\n  Left goes back a level, Escape closes everything and returns focus to\n  the anchor. Use menu / menuitem roles and aria-expanded on folder rows.\n\nBehavior, with the values to use:\n1. Open delay: hovering a row schedules it to take effect after 220ms: a\n   folder row opens its submenu, a plain row closes any deeper submenu.\n   Leaving the row before then cancels it. Touch input acts at once.\n2. Safe zone: while a submenu is open, build a triangle from the pointer's\n   previous position to the two corners of the submenu's near edge (the\n   left edge's top and bottom for a submenu on the right). Track the last\n   two pointermove positions and use the older one as the apex, so the\n   triangle never collapses onto the current point. If the pointer is\n   inside that triangle and within the parent's last\n   min(90px, max(56px, 43% of the parent width)) toward the submenu, it is\n   on its way there: rows it crosses must not highlight or open their own\n   submenus.\n3. Safe window: a row hovered inside the safe zone does not switch the\n   submenu right away. Recheck every 80ms; switch once the pointer leaves\n   the zone, or when 1200ms have passed since the hover began, so a\n   pointer that simply stops there still gets its new submenu.\n4. Close delay: when the pointer leaves the anchor, every open level and\n   the safe zone, close the whole menu after 360ms. Coming back in time\n   cancels the close. Clicking outside closes at once.\n5. Dragging an item over a folder row opens it after 420ms instead of 220ms.\n6. The pointer inside an open submenu ends all protection.\nDrive row highlight from component state (hovered, active, skipped), not\nfrom CSS :hover, or rows crossed inside the safe zone will still light up.\n\nGeometry and motion:\n- Submenus open to the right, overlap their parent by 8px and align their\n  first row with the parent row. Flip to the left when there is no room;\n  the safe zone then uses the submenu's right edge.\n- Levels: 210-260px wide, sized to content, max height\n  min(420px, 100vh - 24px) with their own scroll, 6px padding, 12px radius,\n  1px border, backdrop-filter blur(18px) saturate(135%).\n- Rows: 32px tall, 8px radius, 4px apart, 0 8px padding, 8px gap; 18px\n  icon, 14px weight-500 label, a 16px chevron on folder rows. Level title:\n  11px, weight 600, quiet ink, padding 4px 8px 2px.\n- A submenu opens from its parent's edge: from translateX(-8px)\n  scale(0.88, 0.98) and opacity 0, with opacity over 170ms and transform\n  over 360ms on cubic-bezier(0.2, 1.45, 0.35, 1).\n- The root level opens the same way from its anchor: from translateY(-6px)\n  scale(0.96, 0.86), top-left origin. Keep the overshoot curve: the slight\n  spring is part of the feel.\n- A folder row's icon turns from a closed folder into an open one while its\n  submenu is open, and back when it closes, over 460ms on\n  cubic-bezier(0.22, 1, 0.36, 1). Morph the paths if the two glyphs share\n  their structure; otherwise cross-fade them with a slight lift of the\n  front panel.\n\nLight and dark themes come from tokens, not separate components:\n- Light: surface rgba(255,255,255,.96), border rgba(0,0,0,.14), row ink\n  #263140, row hover rgba(15,23,42,.07), quiet ink #7A8491, chevron\n  #94A3B8, shadow 0 18px 34px rgba(15,23,42,.12),\n  0 2px 4px rgba(15,23,42,.05), inset 0 1px 0 rgba(255,255,255,.74).\n- Dark, neutral grays with no blue cast: surface rgba(34,34,34,.96),\n  border rgba(255,255,255,.12), row ink #E4E4E4, row hover\n  rgba(255,255,255,.08), quiet ink #9A9A9A, chevron #8A8A8A, shadow\n  0 18px 34px rgba(0,0,0,.42), 0 2px 4px rgba(0,0,0,.2),\n  inset 0 1px 0 rgba(255,255,255,.06).\n- Monochrome brand icons invert in dark. Switching themes cross-fades\n  colors, borders and shadows over about 500ms.\n\nKeep every timing value as a named constant in one place, and keep the\nsafe-zone math in a pure, unit-tested helper (point-in-triangle by the\nsign of the three edge cross products). Add an optional debug overlay that\ndraws the zone (blue fill at 16%, dashed blue outline) and the running\ntimer, off by default.\n"}