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