mirror of
https://github.com/penpot/penpot-exporter-figma-plugin.git
synced 2024-12-22 05:33:02 -05:00
parent
b00370410c
commit
1ebdf3e59d
5 changed files with 24 additions and 15 deletions
|
@ -5,3 +5,13 @@ export const toObject = <T>(map: Map<string, T>): Record<string, T> => {
|
||||||
export const toArray = <T>(map: Map<string, T>): [string, T][] => {
|
export const toArray = <T>(map: Map<string, T>): [string, T][] => {
|
||||||
return Array.from(map.entries());
|
return Array.from(map.entries());
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export const init = <T>(map: Map<string, T>, records: Record<string, T>) => {
|
||||||
|
map.clear();
|
||||||
|
|
||||||
|
const entries = Object.entries(records);
|
||||||
|
|
||||||
|
for (const [key, value] of entries) {
|
||||||
|
map.set(key, value);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
|
@ -3,8 +3,9 @@ import { sleep } from '@common/sleep';
|
||||||
|
|
||||||
import { sendMessage } from '@ui/context';
|
import { sendMessage } from '@ui/context';
|
||||||
import { PenpotFile } from '@ui/lib/types/penpotFile';
|
import { PenpotFile } from '@ui/lib/types/penpotFile';
|
||||||
import { UiComponent, componentShapes, components as uiComponents } from '@ui/parser';
|
import { componentShapes, components as uiComponents } from '@ui/parser';
|
||||||
import { symbolFills, symbolStrokes } from '@ui/parser/creators/symbols';
|
import { symbolFills, symbolStrokes } from '@ui/parser/creators/symbols';
|
||||||
|
import { UiComponent } from '@ui/types';
|
||||||
|
|
||||||
import { createItems } from '.';
|
import { createItems } from '.';
|
||||||
|
|
||||||
|
|
|
@ -3,18 +3,7 @@ import { TypographyStyle } from '@ui/lib/types/shapes/textShape';
|
||||||
import { FillStyle } from '@ui/lib/types/utils/fill';
|
import { FillStyle } from '@ui/lib/types/utils/fill';
|
||||||
import { ImageColor } from '@ui/lib/types/utils/imageColor';
|
import { ImageColor } from '@ui/lib/types/utils/imageColor';
|
||||||
import { Uuid } from '@ui/lib/types/utils/uuid';
|
import { Uuid } from '@ui/lib/types/utils/uuid';
|
||||||
|
import { UiComponent } from '@ui/types';
|
||||||
export type UiComponent = {
|
|
||||||
componentId: Uuid;
|
|
||||||
mainInstancePage?: Uuid;
|
|
||||||
mainInstanceId: Uuid;
|
|
||||||
componentFigmaId: string;
|
|
||||||
};
|
|
||||||
|
|
||||||
export const init = <T>(records: Record<string, T>, map: Map<string, T>) => {
|
|
||||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
||||||
map = new Map(Object.entries(records));
|
|
||||||
};
|
|
||||||
|
|
||||||
export const typographies: Map<string, TypographyStyle> = new Map();
|
export const typographies: Map<string, TypographyStyle> = new Map();
|
||||||
export const images: Map<string, ImageColor> = new Map();
|
export const images: Map<string, ImageColor> = new Map();
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
import { init } from '@common/map';
|
||||||
import { sleep } from '@common/sleep';
|
import { sleep } from '@common/sleep';
|
||||||
|
|
||||||
import { sendMessage } from '@ui/context';
|
import { sendMessage } from '@ui/context';
|
||||||
|
@ -5,7 +6,7 @@ import { createFile } from '@ui/lib/penpot';
|
||||||
import { PenpotFile } from '@ui/lib/types/penpotFile';
|
import { PenpotFile } from '@ui/lib/types/penpotFile';
|
||||||
import { TypographyStyle } from '@ui/lib/types/shapes/textShape';
|
import { TypographyStyle } from '@ui/lib/types/shapes/textShape';
|
||||||
import { FillStyle } from '@ui/lib/types/utils/fill';
|
import { FillStyle } from '@ui/lib/types/utils/fill';
|
||||||
import { colors, componentShapes, images, init, typographies } from '@ui/parser';
|
import { colors, componentShapes, images, typographies } from '@ui/parser';
|
||||||
import { buildFile } from '@ui/parser/creators';
|
import { buildFile } from '@ui/parser/creators';
|
||||||
import { PenpotDocument } from '@ui/types';
|
import { PenpotDocument } from '@ui/types';
|
||||||
|
|
||||||
|
@ -124,7 +125,7 @@ export const parse = async ({
|
||||||
paintStyles,
|
paintStyles,
|
||||||
textStyles
|
textStyles
|
||||||
}: PenpotDocument) => {
|
}: PenpotDocument) => {
|
||||||
init(components, componentShapes);
|
init(componentShapes, components);
|
||||||
|
|
||||||
const file = createFile(name);
|
const file = createFile(name);
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
import { LayoutAttributes, LayoutChildAttributes } from '@ui/lib/types/shapes/layout';
|
import { LayoutAttributes, LayoutChildAttributes } from '@ui/lib/types/shapes/layout';
|
||||||
import { ShapeAttributes, ShapeGeomAttributes } from '@ui/lib/types/shapes/shape';
|
import { ShapeAttributes, ShapeGeomAttributes } from '@ui/lib/types/shapes/shape';
|
||||||
import { Children } from '@ui/lib/types/utils/children';
|
import { Children } from '@ui/lib/types/utils/children';
|
||||||
|
import { Uuid } from '@ui/lib/types/utils/uuid';
|
||||||
|
|
||||||
export type ComponentRoot = {
|
export type ComponentRoot = {
|
||||||
figmaId: string;
|
figmaId: string;
|
||||||
|
@ -27,3 +28,10 @@ export type ComponentInstance = ShapeGeomAttributes &
|
||||||
showContent?: boolean;
|
showContent?: boolean;
|
||||||
type: 'instance';
|
type: 'instance';
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export type UiComponent = {
|
||||||
|
componentId: Uuid;
|
||||||
|
mainInstancePage?: Uuid;
|
||||||
|
mainInstanceId: Uuid;
|
||||||
|
componentFigmaId: string;
|
||||||
|
};
|
||||||
|
|
Loading…
Reference in a new issue