{"summary":"Un triangle de sécurité et trois délais pour les menus en cascade : le sous-menu ne change pas et ne se ferme pas quand le pointeur s’y rend en diagonale.","notes":"<p>En allant en diagonale du menu parent vers le sous-menu, le pointeur passe forcément sur les lignes situées en dessous. Un menu ordinaire bascule sur chaque ligne survolée, le sous-menu disparaît et l’utilisateur doit revenir en arrière pour le rouvrir. Voici les quatre règles qui résolvent ce problème :</p>\n        <ol>\n        <li><strong>Triangle de sécurité</strong> : s’applique quand le sous-menu est ouvert et que le pointeur se dirige vers lui. On trace un triangle dont le sommet est la position précédente du pointeur et dont les deux autres points sont les coins haut et bas du côté proche du sous-menu. Tant que le pointeur reste dans le triangle, les lignes survolées ne se mettent pas en surbrillance et n’ouvrent pas leur sous-menu ; le menu ne passe à la ligne courante qu’une fois le pointeur sorti du triangle.</li>\n        <li><strong>Délai de changement</strong> : si le pointeur s’arrête sur une ligne à l’intérieur du triangle, c’est que l’utilisateur veut cette ligne. Au-delà de 1.2 seconde, le menu passe à cette ligne, et le sous-menu ne reste pas indéfiniment inchangé.</li>\n        <li><strong>Délai d’ouverture</strong> : pour le pointeur qui balaie rapidement une colonne du menu. Le sous-menu ne s’ouvre qu’après 220ms de survol, et l’ouverture est annulée si le pointeur part avant, ce qui évite d’ouvrir une série de sous-menus ; sur écran tactile, le toucher agit immédiatement.</li>\n        <li><strong>Délai de fermeture</strong> : pour le pointeur qui sort légèrement du bord du menu. Le menu ne se ferme que 360ms après la sortie et reste tel quel si le pointeur revient à temps ; un clic en dehors du menu le ferme immédiatement.</li>\n        </ol>\n        <p>Par ailleurs, la surbrillance des lignes est pilotée par l’état du composant et non par <code>:hover</code> en CSS ; sinon, même sans changement de menu, les lignes traversées dans le triangle s’allumeraient.</p>\n        <p>Le prompt associé ajoute ces règles au composant de menu existant du projet, en conservant son interface et sa navigation au clavier ; il n’en crée un nouveau que si le projet n’en a pas.</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"}