2024-04-17 03:53:38 -05:00
|
|
|
import {
|
2024-04-17 04:38:13 -05:00
|
|
|
transformBlend,
|
2024-04-17 08:27:53 -05:00
|
|
|
transformChildren,
|
2024-04-22 05:50:38 -05:00
|
|
|
transformCornerRadius,
|
2024-04-17 03:53:38 -05:00
|
|
|
transformDimensionAndPosition,
|
2024-04-17 08:27:53 -05:00
|
|
|
transformFills,
|
2024-04-19 05:18:12 -05:00
|
|
|
transformProportion,
|
2024-04-17 03:53:38 -05:00
|
|
|
transformSceneNode,
|
|
|
|
transformStrokes
|
|
|
|
} from '@plugin/transformers/partials';
|
2024-04-12 09:52:36 -05:00
|
|
|
|
|
|
|
import { FrameShape } from '@ui/lib/types/frame/frameShape';
|
|
|
|
|
2024-04-17 04:38:13 -05:00
|
|
|
const isSectionNode = (node: FrameNode | SectionNode): node is SectionNode => {
|
|
|
|
return node.type === 'SECTION';
|
|
|
|
};
|
|
|
|
|
2024-04-12 06:55:42 -05:00
|
|
|
export const transformFrameNode = async (
|
2024-04-17 04:38:13 -05:00
|
|
|
node: FrameNode | SectionNode,
|
2024-04-12 06:55:42 -05:00
|
|
|
baseX: number,
|
|
|
|
baseY: number
|
|
|
|
): Promise<FrameShape> => {
|
|
|
|
return {
|
|
|
|
type: 'frame',
|
|
|
|
name: node.name,
|
2024-04-19 04:40:50 -05:00
|
|
|
showContent: isSectionNode(node) ? true : !node.clipsContent,
|
2024-04-17 08:27:53 -05:00
|
|
|
...transformFills(node),
|
2024-04-17 04:38:13 -05:00
|
|
|
// Figma API does not expose strokes for sections,
|
|
|
|
// they plan to add it in the future. Refactor this when available.
|
|
|
|
// @see: https://forum.figma.com/t/why-are-strokes-not-available-on-section-nodes/41658
|
|
|
|
...(isSectionNode(node) ? [] : transformStrokes(node)),
|
|
|
|
...(await transformChildren(node, baseX + node.x, baseY + node.y)),
|
2024-04-15 11:30:51 -05:00
|
|
|
...transformDimensionAndPosition(node, baseX, baseY),
|
2024-04-17 04:38:13 -05:00
|
|
|
// Figma API does not expose blend modes for sections,
|
|
|
|
// they plan to add it in the future. Refactor this when available.
|
|
|
|
// @see: https://forum.figma.com/t/add-a-blendmode-property-for-sectionnode/58560
|
|
|
|
...(isSectionNode(node) ? [] : transformBlend(node)),
|
2024-04-19 05:18:12 -05:00
|
|
|
...transformSceneNode(node),
|
|
|
|
// Figma API does not expose constraints proportions for sections
|
2024-04-22 05:50:38 -05:00
|
|
|
...(isSectionNode(node) ? [] : transformProportion(node)),
|
|
|
|
// Figma API does not expose corner radius for sections
|
|
|
|
...(isSectionNode(node) ? [] : transformCornerRadius(node))
|
2024-04-12 06:55:42 -05:00
|
|
|
};
|
|
|
|
};
|