mirror of
https://github.com/penpot/penpot-exporter-figma-plugin.git
synced 2025-01-03 05:10:13 -05:00
Merge branch 'feature/rect-shape' of github.com:Runroom/penpot-exporter-figma-plugin into feature/rect-shape
This commit is contained in:
commit
ce6c4f798a
5 changed files with 21 additions and 13 deletions
|
@ -1 +1,2 @@
|
||||||
|
export * from './transformChildren';
|
||||||
export * from './transformDimensionAndPosition';
|
export * from './transformDimensionAndPosition';
|
||||||
|
|
13
plugin-src/transformers/partials/transformChildren.ts
Normal file
13
plugin-src/transformers/partials/transformChildren.ts
Normal file
|
@ -0,0 +1,13 @@
|
||||||
|
import { Children } from '@ui/lib/types/utils/children';
|
||||||
|
|
||||||
|
import { transformSceneNode } from '../transformSceneNode';
|
||||||
|
|
||||||
|
export const transformChildren = async (
|
||||||
|
node: ChildrenMixin,
|
||||||
|
baseX: number = 0,
|
||||||
|
baseY: number = 0
|
||||||
|
): Promise<Children> => {
|
||||||
|
return {
|
||||||
|
children: await Promise.all(node.children.map(child => transformSceneNode(child, baseX, baseY)))
|
||||||
|
};
|
||||||
|
};
|
|
@ -1,10 +1,9 @@
|
||||||
import { transformDimensionAndPosition } from '@plugin/transformers/partials';
|
import { transformDimensionAndPosition } from '@plugin/transformers/partials';
|
||||||
|
import { transformChildren } from '@plugin/transformers/partials';
|
||||||
import { translateFills } from '@plugin/translators';
|
import { translateFills } from '@plugin/translators';
|
||||||
|
|
||||||
import { FrameShape } from '@ui/lib/types/frame/frameShape';
|
import { FrameShape } from '@ui/lib/types/frame/frameShape';
|
||||||
|
|
||||||
import { transformSceneNode } from '.';
|
|
||||||
|
|
||||||
export const transformFrameNode = async (
|
export const transformFrameNode = async (
|
||||||
node: FrameNode,
|
node: FrameNode,
|
||||||
baseX: number,
|
baseX: number,
|
||||||
|
@ -14,9 +13,7 @@ export const transformFrameNode = async (
|
||||||
type: 'frame',
|
type: 'frame',
|
||||||
name: node.name,
|
name: node.name,
|
||||||
fills: translateFills(node.fills, node.width, node.height),
|
fills: translateFills(node.fills, node.width, node.height),
|
||||||
children: await Promise.all(
|
...(await transformChildren(node, baseX, baseY)),
|
||||||
node.children.map(child => transformSceneNode(child, baseX + node.x, baseY + node.y))
|
|
||||||
),
|
|
||||||
...transformDimensionAndPosition(node, baseX, baseY)
|
...transformDimensionAndPosition(node, baseX, baseY)
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
|
@ -1,9 +1,8 @@
|
||||||
import { transformDimensionAndPosition } from '@plugin/transformers/partials';
|
import { transformDimensionAndPosition } from '@plugin/transformers/partials';
|
||||||
|
import { transformChildren } from '@plugin/transformers/partials';
|
||||||
|
|
||||||
import { GroupShape } from '@ui/lib/types/group/groupShape';
|
import { GroupShape } from '@ui/lib/types/group/groupShape';
|
||||||
|
|
||||||
import { transformSceneNode } from '.';
|
|
||||||
|
|
||||||
export const transformGroupNode = async (
|
export const transformGroupNode = async (
|
||||||
node: GroupNode,
|
node: GroupNode,
|
||||||
baseX: number,
|
baseX: number,
|
||||||
|
@ -12,9 +11,7 @@ export const transformGroupNode = async (
|
||||||
return {
|
return {
|
||||||
type: 'group',
|
type: 'group',
|
||||||
name: node.name,
|
name: node.name,
|
||||||
children: await Promise.all(
|
...(await transformChildren(node, baseX, baseY)),
|
||||||
node.children.map(child => transformSceneNode(child, baseX, baseY))
|
|
||||||
),
|
|
||||||
...transformDimensionAndPosition(node, baseX, baseY)
|
...transformDimensionAndPosition(node, baseX, baseY)
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
import { PenpotPage } from '@ui/lib/types/penpotPage';
|
import { transformChildren } from '@plugin/transformers/partials';
|
||||||
|
|
||||||
import { transformSceneNode } from '.';
|
import { PenpotPage } from '@ui/lib/types/penpotPage';
|
||||||
|
|
||||||
export const transformPageNode = async (node: PageNode): Promise<PenpotPage> => {
|
export const transformPageNode = async (node: PageNode): Promise<PenpotPage> => {
|
||||||
return {
|
return {
|
||||||
name: node.name,
|
name: node.name,
|
||||||
children: await Promise.all(node.children.map(child => transformSceneNode(child)))
|
...(await transformChildren(node))
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in a new issue