Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix masks in components #129

Merged
merged 3 commits into from
Jun 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/friendly-cycles-heal.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"penpot-exporter": patch
---

Fix masks not working in components
10 changes: 10 additions & 0 deletions plugin-src/transformers/partials/transformFigmaIds.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,16 @@ export const transformFigmaIds = (
};
};

export const transformMaskFigmaIds = (
node: SceneNode
): Pick<ShapeBaseAttributes, 'figmaId' | 'figmaRelatedId'> => {
const transformedIds = transformFigmaIds(node);
return {
figmaId: `M${transformedIds.figmaId}`,
figmaRelatedId: transformedIds.figmaRelatedId ? `M${transformedIds.figmaRelatedId}` : undefined
};
};

const getRelatedNodeId = (nodeId: string): string | undefined => {
const ids = nodeId.split(';');

Expand Down
2 changes: 2 additions & 0 deletions plugin-src/translators/translateChildren.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { transformGroupNodeLike, transformSceneNode } from '@plugin/transformers';
import { transformMaskFigmaIds } from '@plugin/transformers/partials';
import { sleep } from '@plugin/utils';

import { PenpotNode } from '@ui/types';
Expand All @@ -23,6 +24,7 @@ export const translateMaskChildren = async (
const maskedChildren = await translateChildren(children.slice(maskIndex), baseX, baseY);

const maskGroup = {
...transformMaskFigmaIds(maskChild),
...transformGroupNodeLike(maskChild, baseX, baseY),
children: maskedChildren,
maskedGroup: true
Expand Down