0
Fork 0
mirror of https://github.com/penpot/penpot-exporter-figma-plugin.git synced 2024-12-22 21:53:27 -05:00
penpot-exporter-figma-plugin/ui-src/parser/creators/createComponentLibrary.ts
Alex Sánchez 5d4ace337b
Components Library (#125)
* components library management

* components library management

* fixes

* fixes
2024-05-29 17:33:29 +02:00

32 lines
874 B
TypeScript

import { componentsLibrary } from '@plugin/ComponentLibrary';
import { PenpotFile } from '@ui/lib/types/penpotFile';
import { uiComponents } from '@ui/parser/libraries';
import { createItems } from '.';
export const createComponentLibrary = (file: PenpotFile) => {
uiComponents.all().forEach(uiComponent => {
const component = componentsLibrary.get(uiComponent.componentFigmaId);
if (!component) {
return;
}
const { children = [], ...rest } = component;
file.startComponent({
...rest,
id: uiComponent.componentId,
componentId: uiComponent.componentId,
mainInstancePage: uiComponent.mainInstancePage,
mainInstanceId: uiComponent.mainInstanceId,
componentRoot: true,
mainInstance: true,
componentFile: file.getId()
});
createItems(file, children);
file.finishComponent();
});
};