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-28 12:17:56 +02:00
|
|
|
import { symbolFills, symbolStrokes, symbolTouched } from '@ui/parser/creators/symbols';
|
2024-05-29 12:52:21 +02:00
|
|
|
|
|
|
|
import { createItems } from '.';
|
|
|
|
|
|
|
|
export const createArtboard = (
|
|
|
|
file: PenpotFile,
|
2024-06-18 11:20:51 +02:00
|
|
|
{ type, children = [], figmaId, figmaRelatedId, ...shape }: FrameShape
|
2024-05-30 17:54:37 +02:00
|
|
|
): Uuid | undefined => {
|
|
|
|
const id = parseFigmaId(file, figmaId);
|
|
|
|
|
2024-06-18 11:20:51 +02:00
|
|
|
shape.id = id;
|
|
|
|
shape.shapeRef ??= parseFigmaId(file, figmaRelatedId, true);
|
2024-06-19 15:58:13 +02:00
|
|
|
shape.fills = symbolFills(shape.fillStyleId, shape.fills);
|
2024-06-18 11:20:51 +02:00
|
|
|
shape.strokes = symbolStrokes(shape.strokes);
|
2024-06-28 12:17:56 +02:00
|
|
|
shape.touched = symbolTouched(
|
|
|
|
!shape.hidden,
|
|
|
|
undefined,
|
|
|
|
shape.touched,
|
|
|
|
shape.componentPropertyReferences
|
|
|
|
);
|
2024-06-18 11:20:51 +02:00
|
|
|
|
|
|
|
file.addArtboard(shape);
|
2024-05-29 12:52:21 +02:00
|
|
|
|
|
|
|
createItems(file, children);
|
|
|
|
|
|
|
|
file.closeArtboard();
|
2024-05-30 17:54:37 +02:00
|
|
|
|
|
|
|
return id;
|
2024-05-29 12:52:21 +02:00
|
|
|
};
|