0
Fork 0
mirror of https://github.com/penpot/penpot-exporter-figma-plugin.git synced 2024-12-22 13:43:03 -05:00
penpot-exporter-figma-plugin/plugin-src/transformers/transformFrameNode.ts

39 lines
1.3 KiB
TypeScript
Raw Normal View History

import {
transformBlend,
transformChildren,
transformDimensionAndPosition,
transformFills,
transformSceneNode,
transformStrokes
} from '@plugin/transformers/partials';
import { FrameShape } from '@ui/lib/types/frame/frameShape';
const isSectionNode = (node: FrameNode | SectionNode): node is SectionNode => {
return node.type === 'SECTION';
};
export const transformFrameNode = async (
node: FrameNode | SectionNode,
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,
...transformFills(node),
// 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),
// 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-15 11:30:51 -05:00
...transformSceneNode(node)
};
};