0
Fork 0
mirror of https://github.com/penpot/penpot-exporter-figma-plugin.git synced 2025-02-25 16:26:23 -05:00

add group

This commit is contained in:
Jordi Sala Morales 2024-04-10 11:14:12 +00:00
parent 93ba8eec4f
commit 7383d87125
No known key found for this signature in database
GPG key ID: C5127140107F55FD
4 changed files with 19 additions and 3 deletions

View file

@ -7,9 +7,14 @@ export const createPenpotGroup = (
baseX: number,
baseY: number
) => {
file.penpotFile.addGroup({ name: node.name });
file.penpotFile.addGroup({
type: Symbol.for('group'),
name: node.name
});
for (const child of node.children) {
createPenpotItem(file, child, baseX, baseY);
}
file.penpotFile.closeGroup();
};

View file

@ -1,4 +1,5 @@
import { CircleShape } from './types/circle/circleShape';
import { GroupShape } from './types/group/groupShape';
import { ImageShape } from './types/image/imageShape';
import { RectShape } from './types/rect/rectShape';
import { TextShape } from './types/text/textShape';
@ -12,8 +13,7 @@ export interface PenpotFile {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
addArtboard(artboard: any): void;
closeArtboard(): void;
// eslint-disable-next-line @typescript-eslint/no-explicit-any
addGroup(group: any): void;
addGroup(group: GroupShape): void;
closeGroup(): void;
createRect(rect: RectShape): void;
createCircle(circle: CircleShape): void;

View file

@ -0,0 +1,7 @@
export type GroupAttributes = {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
id?: any;
type: symbol;
// eslint-disable-next-line @typescript-eslint/no-explicit-any
shapes?: any[];
};

View file

@ -0,0 +1,4 @@
import { Shape } from '../shape';
import { GroupAttributes } from './groupAttributes';
export type GroupShape = Shape & GroupAttributes;