mirror of
https://github.com/penpot/penpot-exporter-figma-plugin.git
synced 2024-12-22 21:53:27 -05:00
be5ff3be8e
* remote components processing * changeset * fixes * fixes * fixes * fixes * fix everything * revert for now * fixes * change delete nodes flag --------- Co-authored-by: Jordi Sala Morales <jordism91@gmail.com>
37 lines
923 B
TypeScript
37 lines
923 B
TypeScript
import { componentsLibrary } from '@plugin/ComponentLibrary';
|
|
|
|
import { PenpotFile } from '@ui/lib/types/penpotFile';
|
|
import { uiComponents } from '@ui/parser/libraries';
|
|
import { ComponentRoot } from '@ui/types';
|
|
|
|
import { createArtboard } from '.';
|
|
|
|
export const createComponent = (file: PenpotFile, { figmaId }: ComponentRoot) => {
|
|
const component = componentsLibrary.get(figmaId);
|
|
if (!component) {
|
|
return;
|
|
}
|
|
|
|
const uiComponent = uiComponents.get(figmaId);
|
|
const componentId = uiComponent?.componentId ?? file.newId();
|
|
|
|
const frameId = createArtboard(file, {
|
|
...component,
|
|
componentFile: file.getId(),
|
|
componentId,
|
|
componentRoot: true,
|
|
mainInstance: true,
|
|
type: 'frame'
|
|
});
|
|
|
|
if (!frameId) {
|
|
return;
|
|
}
|
|
|
|
uiComponents.register(figmaId, {
|
|
componentId,
|
|
mainInstancePage: file.getCurrentPageId(),
|
|
componentFigmaId: figmaId,
|
|
mainInstanceId: frameId
|
|
});
|
|
};
|