2024-05-29 12:52:21 +02:00
|
|
|
import { PenpotFile } from '@ui/lib/types/penpotFile';
|
|
|
|
import { FrameShape } from '@ui/lib/types/shapes/frameShape';
|
2024-05-30 17:54:37 +02:00
|
|
|
import { Uuid } from '@ui/lib/types/utils/uuid';
|
|
|
|
import { parseFigmaId } from '@ui/parser';
|
2024-06-03 17:29:33 +02:00
|
|
|
import { symbolBlendMode, symbolFills } from '@ui/parser/creators/symbols';
|
2024-05-29 12:52:21 +02:00
|
|
|
|
|
|
|
import { createItems } from '.';
|
|
|
|
|
|
|
|
export const createArtboard = (
|
|
|
|
file: PenpotFile,
|
2024-05-30 17:54:37 +02:00
|
|
|
{ type, fills, blendMode, children = [], figmaId, figmaRelatedId, shapeRef, ...rest }: FrameShape
|
|
|
|
): Uuid | undefined => {
|
|
|
|
const id = parseFigmaId(file, figmaId);
|
|
|
|
|
2024-05-29 12:52:21 +02:00
|
|
|
file.addArtboard({
|
2024-05-30 17:54:37 +02:00
|
|
|
id,
|
|
|
|
shapeRef: shapeRef ?? parseFigmaId(file, figmaRelatedId, true),
|
2024-06-03 17:29:33 +02:00
|
|
|
fills: symbolFills(fills),
|
2024-05-29 12:52:21 +02:00
|
|
|
blendMode: symbolBlendMode(blendMode),
|
|
|
|
...rest
|
|
|
|
});
|
|
|
|
|
|
|
|
createItems(file, children);
|
|
|
|
|
|
|
|
file.closeArtboard();
|
2024-05-30 17:54:37 +02:00
|
|
|
|
|
|
|
return id;
|
2024-05-29 12:52:21 +02:00
|
|
|
};
|