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

refactor blend

This commit is contained in:
Jordi Sala Morales 2024-04-15 16:18:58 +00:00
parent 27b453b4d7
commit b8058dc0ee
No known key found for this signature in database
GPG key ID: C5127140107F55FD
6 changed files with 27 additions and 16 deletions

View file

@ -1,2 +1,3 @@
export * from './transformBlend';
export * from './transformChildren';
export * from './transformDimensionAndPosition';

View file

@ -0,0 +1,12 @@
import { translateBlendMode } from '@plugin/translators';
import { ShapeAttributes } from '@ui/lib/types/shape/shapeAttributes';
export const transformBlend = (
node: SceneNodeMixin & MinimalBlendMixin
): Partial<ShapeAttributes> => {
return {
blendMode: translateBlendMode(node.blendMode),
opacity: !node.visible ? 0 : node.opacity // @TODO: check this. If we use the property hidden and it's hidden, it won't export
};
};

View file

@ -1,5 +1,5 @@
import { transformDimensionAndPosition } from '@plugin/transformers/partials';
import { translateBlendMode, translateFills } from '@plugin/translators';
import { transformBlend, transformDimensionAndPosition } from '@plugin/transformers/partials';
import { translateFills } from '@plugin/translators';
import { CircleShape } from '@ui/lib/types/circle/circleShape';
@ -12,8 +12,7 @@ export const transformEllipseNode = (
type: 'circle',
name: node.name,
fills: translateFills(node.fills, node.width, node.height),
blendMode: translateBlendMode(node.blendMode),
opacity: !node.visible ? 0 : node.opacity, //@TODO: check this. If we use the property hidden and it's hidden, it won't export
...transformDimensionAndPosition(node, baseX, baseY)
...transformDimensionAndPosition(node, baseX, baseY),
...transformBlend(node)
};
};

View file

@ -1,4 +1,4 @@
import { transformDimensionAndPosition } from '@plugin/transformers/partials';
import { transformBlend, transformDimensionAndPosition } from '@plugin/transformers/partials';
import { transformChildren } from '@plugin/transformers/partials';
import { GroupShape } from '@ui/lib/types/group/groupShape';
@ -11,7 +11,8 @@ export const transformGroupNode = async (
return {
type: 'group',
name: node.name,
...transformDimensionAndPosition(node, baseX, baseY),
...(await transformChildren(node, baseX, baseY)),
...transformDimensionAndPosition(node, baseX, baseY)
...transformBlend(node)
};
};

View file

@ -1,5 +1,5 @@
import { transformDimensionAndPosition } from '@plugin/transformers/partials';
import { translateBlendMode, translateFills } from '@plugin/translators';
import { transformBlend, transformDimensionAndPosition } from '@plugin/transformers/partials';
import { translateFills } from '@plugin/translators';
import { RectShape } from '@ui/lib/types/rect/rectShape';
@ -12,8 +12,7 @@ export const transformRectangleNode = (
type: 'rect',
name: node.name,
fills: translateFills(node.fills, node.width, node.height),
blendMode: translateBlendMode(node.blendMode),
opacity: !node.visible ? 0 : node.opacity, //@TODO: check this. If we use the property hidden and it's hidden, it won't export
...transformBlend(node),
...transformDimensionAndPosition(node, baseX, baseY)
};
};

View file

@ -1,3 +1,4 @@
import { transformBlend, transformDimensionAndPosition } from '@plugin/transformers/partials';
import {
translateFills,
translateTextDecoration,
@ -37,10 +38,6 @@ export const transformTextNode = (node: TextNode, baseX: number, baseY: number):
return {
type: 'text',
name: node.name,
x: node.x + baseX,
y: node.y + baseY,
width: node.width,
height: node.height,
content: {
type: 'root',
children: [
@ -61,6 +58,8 @@ export const transformTextNode = (node: TextNode, baseX: number, baseY: number):
]
}
]
}
},
...transformBlend(node),
...transformDimensionAndPosition(node, baseX, baseY)
};
};