Skip to content

Commit

Permalink
feat: detect Frame, Group node
Browse files Browse the repository at this point in the history
  • Loading branch information
junghyeonsu committed Oct 31, 2023
1 parent e9ae332 commit b141d40
Showing 1 changed file with 17 additions and 2 deletions.
19 changes: 17 additions & 2 deletions figma-plugin/plugin-src/service.ts
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -35,6 +41,8 @@ const findComponentInNode = (
setName?: string,
): Extracted | Extracted[] => {
switch (node.type) {
case "FRAME":
case "GROUP":
case "COMPONENT":
case "INSTANCE":
case "VECTOR": {
Expand All @@ -54,8 +62,9 @@ const findComponentInNode = (
);
}

default:
default: {
return [];
}
}
};

Expand All @@ -64,13 +73,19 @@ export async function getSvgInIconFrame(
): Promise<Record<string, IconaIconData>> {
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 [];
Expand Down

0 comments on commit b141d40

Please sign in to comment.