0
Fork 0
mirror of https://github.com/penpot/penpot-exporter-figma-plugin.git synced 2024-12-22 13:43:03 -05:00

component set (#128)

This commit is contained in:
Alex Sánchez 2024-05-31 13:32:59 +02:00 committed by GitHub
parent 79f6ce80d2
commit f8e6b6ecd9
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
7 changed files with 14 additions and 11 deletions

View file

@ -0,0 +1,5 @@
---
"penpot-exporter": minor
---
Component set

View file

@ -22,7 +22,7 @@ export const transformComponentNode = async (
componentsLibrary.register(node.id, {
type: 'component',
name: node.name,
path: '',
path: node.parent?.type === 'COMPONENT_SET' ? node.parent.name : '',
...transformFigmaIds(node),
...(await transformFills(node)),
...transformEffects(node),

View file

@ -13,12 +13,12 @@ import {
import { FrameShape } from '@ui/lib/types/shapes/frameShape';
const isSectionNode = (node: FrameNode | SectionNode): node is SectionNode => {
const isSectionNode = (node: FrameNode | SectionNode | ComponentSetNode): node is SectionNode => {
return node.type === 'SECTION';
};
export const transformFrameNode = async (
node: FrameNode | SectionNode,
node: FrameNode | SectionNode | ComponentSetNode,
baseX: number,
baseY: number
): Promise<FrameShape> => {

View file

@ -25,18 +25,14 @@ export const transformInstanceNode = async (
*
* 1. If the component does not have a main component.
* 2. If the component does not have parent (it comes from an external design system).
* 3. If the component is inside a component set, (it is a variant component).
*/
if (
!mainComponent ||
mainComponent.parent === null ||
mainComponent.parent.type === 'COMPONENT_SET'
) {
if (!mainComponent || mainComponent.parent === null) {
return;
}
return {
type: 'instance',
name: node.name,
mainComponentFigmaId: mainComponent.id,
isComponentRoot: isComponentRoot(node),
...transformFigmaIds(node),

View file

@ -34,6 +34,7 @@ export const transformSceneNode = async (
break;
case 'SECTION':
case 'FRAME':
case 'COMPONENT_SET':
penpotNode = await transformFrameNode(node, baseX, baseY);
break;
case 'GROUP':

View file

@ -18,7 +18,7 @@ export type ComponentShape = ShapeBaseAttributes &
export type ComponentAttributes = {
type?: 'component';
name: string;
path: '';
path: string;
mainInstanceId?: Uuid;
mainInstancePage?: Uuid;
};

View file

@ -1,5 +1,5 @@
import { LayoutAttributes, LayoutChildAttributes } from '@ui/lib/types/shapes/layout';
import { ShapeGeomAttributes } from '@ui/lib/types/shapes/shape';
import { ShapeAttributes, ShapeGeomAttributes } from '@ui/lib/types/shapes/shape';
import { Children } from '@ui/lib/types/utils/children';
export type ComponentRoot = {
@ -8,6 +8,7 @@ export type ComponentRoot = {
};
export type ComponentInstance = ShapeGeomAttributes &
ShapeAttributes &
LayoutAttributes &
LayoutChildAttributes &
Children & {