From 1e4f66b6405dffc7bd8ccbee09917f6ac1f8872a Mon Sep 17 00:00:00 2001 From: sina_sajjadi Date: Wed, 2 Sep 2026 20:38:33 +0330 Subject: [PATCH] feat: add VoiceAgentSection, Footer, and dev-click-to-component utility to landing page components --- components/dev-click-to-component.tsx | 462 +++++++--------------- components/sections/Footer.tsx | 4 +- components/sections/VoiceAgentSection.tsx | 12 +- 3 files changed, 153 insertions(+), 325 deletions(-) diff --git a/components/dev-click-to-component.tsx b/components/dev-click-to-component.tsx index 96124ae..b5f97f1 100644 --- a/components/dev-click-to-component.tsx +++ b/components/dev-click-to-component.tsx @@ -65,76 +65,55 @@ function getHierarchy(startEl: Element | null): Element[] { return list; // [0: innermost leaf, ..., N-1: outermost container] } -export type HierarchyMode = "OUTER" | "PARENT" | "INNER" | "LEVEL"; - -interface HierarchyTarget { - element: Element; - index: number; - total: number; - mode: HierarchyMode; -} - -function selectTargetFromHierarchy( +function selectTargetElement( hierarchy: Element[], - baseMode: "OUTER" | "PARENT" | "INNER", - customIndex: number | null -): HierarchyTarget | null { + isInnerMode: boolean +): Element | null { if (hierarchy.length === 0) return null; - const total = hierarchy.length; - - if (customIndex !== null && customIndex >= 0 && customIndex < total) { - let mode: HierarchyMode = "LEVEL"; - if (customIndex === 0) mode = "INNER"; - else if (customIndex === total - 1) mode = "OUTER"; - else if (customIndex === 1) mode = "PARENT"; - - return { - element: hierarchy[customIndex], - index: customIndex, - total, - mode, - }; - } + if (hierarchy.length === 1) return hierarchy[0]; - if (baseMode === "INNER" || total === 1) { - return { - element: hierarchy[0], - index: 0, - total, - mode: "INNER", - }; + if (isInnerMode) { + // Inner Mode (Alt + Ctrl): absolute innermost leaf element (, ,

, etc.) + return hierarchy[0]; } - if (baseMode === "PARENT") { - const parentIdx = Math.min(1, total - 1); - return { - element: hierarchy[parentIdx], - index: parentIdx, - total, - mode: "PARENT", - }; + // Outer Mode (Alt): Intermediate component wrapper / button (pushed one level inside) + const leafTag = hierarchy[0].tagName.toLowerCase(); + const isSvgLeaf = [ + "path", + "circle", + "g", + "rect", + "line", + "polyline", + "polygon", + "ellipse", + "defs", + ].includes(leafTag); + + if (isSvgLeaf) { + // If leaf is inside an SVG, select the immediate element enclosing (e.g.

) + const outsideSvgIndex = hierarchy.findIndex( + (el, idx) => idx > 0 && el.tagName.toLowerCase() !== "svg" + ); + if (outsideSvgIndex !== -1) { + return hierarchy[outsideSvgIndex]; + } + return hierarchy[1] || hierarchy[0]; } - // Outer Mode: find outermost component container, filtering out root page/layout if deeper elements exist - const nonRootIndices: number[] = []; - hierarchy.forEach((el, idx) => { + // For standard elements (e.g. inside