From b141d402d20f727ab1c21f48e380b23fe2870641 Mon Sep 17 00:00:00 2001 From: junghyeonsu Date: Tue, 31 Oct 2023 15:53:44 +0900 Subject: [PATCH] feat: detect Frame, Group node --- figma-plugin/plugin-src/service.ts | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/figma-plugin/plugin-src/service.ts b/figma-plugin/plugin-src/service.ts index 45f2d34..49b0d3c 100644 --- a/figma-plugin/plugin-src/service.ts +++ b/figma-plugin/plugin-src/service.ts @@ -1,6 +1,12 @@ import type { IconaIconData } from "@icona/types"; -type TargetNode = ComponentNode | InstanceNode | VectorNode | ComponentSetNode; +type TargetNode = + | ComponentNode + | InstanceNode + | VectorNode + | ComponentSetNode + | FrameNode + | GroupNode; type Extracted = { id: string; name: string; @@ -35,6 +41,8 @@ const findComponentInNode = ( setName?: string, ): Extracted | Extracted[] => { switch (node.type) { + case "FRAME": + case "GROUP": case "COMPONENT": case "INSTANCE": case "VECTOR": { @@ -54,8 +62,9 @@ const findComponentInNode = ( ); } - default: + default: { return []; + } } }; @@ -64,13 +73,19 @@ export async function getSvgInIconFrame( ): Promise> { const frame = figma.getNodeById(iconFrameId) as FrameNode; + console.log("frame", frame.children); + const targetNodes = frame.children.flatMap((child) => { if ( child.type === "COMPONENT" || child.type === "INSTANCE" || child.type === "VECTOR" || + child.type === "FRAME" || + child.type === "GROUP" || child.type === "COMPONENT_SET" ) { + console.log("child", child.type); + return findComponentInNode(child); } return [];