mirror of
https://github.com/penpot/penpot-exporter-figma-plugin.git
synced 2024-12-22 05:33:02 -05:00
refactor blend
This commit is contained in:
parent
27b453b4d7
commit
b8058dc0ee
6 changed files with 27 additions and 16 deletions
|
@ -1,2 +1,3 @@
|
|||
export * from './transformBlend';
|
||||
export * from './transformChildren';
|
||||
export * from './transformDimensionAndPosition';
|
||||
|
|
12
plugin-src/transformers/partials/transformBlend.ts
Normal file
12
plugin-src/transformers/partials/transformBlend.ts
Normal 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
|
||||
};
|
||||
};
|
|
@ -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)
|
||||
};
|
||||
};
|
||||
|
|
|
@ -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)
|
||||
};
|
||||
};
|
||||
|
|
|
@ -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)
|
||||
};
|
||||
};
|
||||
|
|
|
@ -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)
|
||||
};
|
||||
};
|
||||
|
|
Loading…
Reference in a new issue