mirror of
https://github.com/penpot/penpot-exporter-figma-plugin.git
synced 2024-12-22 13:43:03 -05:00
fixes
This commit is contained in:
parent
73f6ea5fb7
commit
c4c0ad362c
5 changed files with 10 additions and 20 deletions
|
@ -9,16 +9,13 @@ const nodeActsAsMask = (node: SceneNode): boolean => {
|
|||
export const transformChildren = async (
|
||||
node: ChildrenMixin,
|
||||
baseX: number = 0,
|
||||
baseY: number = 0,
|
||||
reverseChildrenOrder: boolean = false
|
||||
baseY: number = 0
|
||||
): Promise<Children> => {
|
||||
const maskIndex = node.children.findIndex(nodeActsAsMask);
|
||||
const containsMask = maskIndex !== -1;
|
||||
const children = reverseChildrenOrder ? node.children.slice().reverse() : node.children;
|
||||
|
||||
return {
|
||||
children: containsMask
|
||||
? await translateMaskChildren(children, maskIndex, baseX, baseY)
|
||||
: await translateChildren(children, baseX, baseY)
|
||||
? await translateMaskChildren(node.children, maskIndex, baseX, baseY)
|
||||
: await translateChildren(node.children, baseX, baseY)
|
||||
};
|
||||
};
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
import { componentsLibrary } from '@plugin/ComponentLibrary';
|
||||
import {
|
||||
transformAutoLayout,
|
||||
transformAutoLayoutPosition,
|
||||
transformBlend,
|
||||
transformChildren,
|
||||
|
@ -39,7 +40,8 @@ export const transformComponentNode = async (
|
|||
...transformCornerRadius(node),
|
||||
...(await transformChildren(node, baseX + node.x, baseY + node.y)),
|
||||
...transformDimensionAndPosition(node, baseX, baseY),
|
||||
...transformConstraints(node)
|
||||
...transformConstraints(node),
|
||||
...transformAutoLayout(node)
|
||||
});
|
||||
|
||||
return {
|
||||
|
|
|
@ -27,12 +27,8 @@ export const transformFrameNode = async (
|
|||
baseY: number
|
||||
): Promise<FrameShape> => {
|
||||
let frameSpecificAttributes: Partial<FrameShape> = {};
|
||||
let reverseChildrenOrder = false;
|
||||
|
||||
if (!isSectionNode(node)) {
|
||||
if (node.layoutMode !== 'NONE') {
|
||||
reverseChildrenOrder = true;
|
||||
}
|
||||
// Figma API does not expose strokes, blend modes, corner radius, or constraint proportions for sections,
|
||||
// they plan to add it in the future. Refactor this when available.
|
||||
frameSpecificAttributes = {
|
||||
|
@ -57,7 +53,7 @@ export const transformFrameNode = async (
|
|||
...transformFigmaIds(node),
|
||||
...transformFills(node),
|
||||
...frameSpecificAttributes,
|
||||
...(await transformChildren(node, baseX + node.x, baseY + node.y, reverseChildrenOrder)),
|
||||
...(await transformChildren(node, baseX + node.x, baseY + node.y)),
|
||||
...transformDimensionAndPosition(node, baseX, baseY),
|
||||
...transformSceneNode(node)
|
||||
};
|
||||
|
|
|
@ -33,11 +33,6 @@ export const transformInstanceNode = async (
|
|||
await registerExternalComponents(mainComponent);
|
||||
}
|
||||
|
||||
let reverseChildrenOrder = false;
|
||||
if (node.layoutMode !== 'NONE') {
|
||||
reverseChildrenOrder = true;
|
||||
}
|
||||
|
||||
return {
|
||||
type: 'instance',
|
||||
name: node.name,
|
||||
|
@ -57,7 +52,7 @@ export const transformInstanceNode = async (
|
|||
...transformDimensionAndPosition(node, baseX, baseY),
|
||||
...transformConstraints(node),
|
||||
...transformAutoLayout(node),
|
||||
...(await transformChildren(node, baseX + node.x, baseY + node.y, reverseChildrenOrder))
|
||||
...(await transformChildren(node, baseX + node.x, baseY + node.y))
|
||||
};
|
||||
};
|
||||
|
||||
|
|
|
@ -17,9 +17,9 @@ type FigmaLayoutSizing = 'FIXED' | 'HUG' | 'FILL';
|
|||
export const translateLayoutFlexDir = (layoutMode: FigmaLayoutMode): LayoutFlexDir | undefined => {
|
||||
switch (layoutMode) {
|
||||
case 'HORIZONTAL':
|
||||
return 'row';
|
||||
return 'row-reverse';
|
||||
case 'VERTICAL':
|
||||
return 'column';
|
||||
return 'column-reverse';
|
||||
default:
|
||||
return;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue