0
Fork 0
mirror of https://github.com/penpot/penpot-exporter-figma-plugin.git synced 2025-01-03 05:10:13 -05:00

Remove symbols when possible (#173)

* remove symbols for blend mode

* remove symbol for gradients

* optimize symbols for path contents

* optimize code

* remove symbols
This commit is contained in:
Jordi Sala Morales 2024-06-18 11:20:51 +02:00 committed by GitHub
parent 8697902e08
commit 738ebfeffe
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
21 changed files with 122 additions and 313 deletions

View file

@ -8,7 +8,7 @@ export type PenpotPage = {
} & Children; } & Children;
export type PenpotPageOptions = { export type PenpotPageOptions = {
background?: string; // hex color background?: string;
savedGrids?: SavedGrids; savedGrids?: SavedGrids;
flows?: Flow[]; flows?: Flow[];
guides?: { [uuid: Uuid]: Guide }; guides?: { [uuid: Uuid]: Guide };

View file

@ -1,29 +1,9 @@
import { Uuid } from '@ui/lib/types/utils/uuid'; import { Uuid } from '@ui/lib/types/utils/uuid';
export const ITEM_MARGIN_SIMPLE_TYPE: unique symbol = Symbol.for('simple'); export type LayoutSizing = 'fill' | 'fix' | 'auto';
export const ITEM_MARGIN_MULTIPLE_TYPE: unique symbol = Symbol.for('multiple');
export const ITEM_SIZING_FILL: unique symbol = Symbol.for('fill');
export const ITEM_SIZING_FIX: unique symbol = Symbol.for('fix');
export const ITEM_SIZING_AUTO: unique symbol = Symbol.for('auto');
export const ITEM_ALIGN_SELF_START: unique symbol = Symbol.for('start');
export const ITEM_ALIGN_SELF_END: unique symbol = Symbol.for('end');
export const ITEM_ALIGN_SELF_CENTER: unique symbol = Symbol.for('center');
export const ITEM_ALIGN_SELF_STRETCH: unique symbol = Symbol.for('stretch');
export type LayoutSizing =
| 'fill'
| 'fix'
| 'auto'
| typeof ITEM_SIZING_FILL
| typeof ITEM_SIZING_FIX
| typeof ITEM_SIZING_AUTO;
export type LayoutChildAttributes = { export type LayoutChildAttributes = {
'layoutItemMarginType'?: 'layoutItemMarginType'?: 'simple' | 'multiple';
| 'simple'
| 'multiple'
| typeof ITEM_MARGIN_SIMPLE_TYPE
| typeof ITEM_MARGIN_MULTIPLE_TYPE;
'layoutItemMargin'?: { 'layoutItemMargin'?: {
m1?: number; m1?: number;
m2?: number; m2?: number;
@ -36,15 +16,7 @@ export type LayoutChildAttributes = {
'layoutItemMinW'?: number; 'layoutItemMinW'?: number;
'layoutItemH-Sizing'?: LayoutSizing; 'layoutItemH-Sizing'?: LayoutSizing;
'layoutItemV-Sizing'?: LayoutSizing; 'layoutItemV-Sizing'?: LayoutSizing;
'layoutItemAlignSelf'?: 'layoutItemAlignSelf'?: 'start' | 'end' | 'center' | 'stretch';
| 'start'
| 'end'
| 'center'
| 'stretch'
| typeof ITEM_ALIGN_SELF_START
| typeof ITEM_ALIGN_SELF_END
| typeof ITEM_ALIGN_SELF_CENTER
| typeof ITEM_ALIGN_SELF_STRETCH;
'layoutItemAbsolute'?: boolean; 'layoutItemAbsolute'?: boolean;
'layoutItemZIndex'?: number; 'layoutItemZIndex'?: number;
}; };

View file

@ -1,20 +1,3 @@
export const BLEND_MODE_NORMAL: unique symbol = Symbol.for('normal');
export const BLEND_MODE_DARKEN: unique symbol = Symbol.for('darken');
export const BLEND_MODE_MULTIPLY: unique symbol = Symbol.for('multiply');
export const BLEND_MODE_COLOR_BURN: unique symbol = Symbol.for('color-burn');
export const BLEND_MODE_LIGHTEN: unique symbol = Symbol.for('lighten');
export const BLEND_MODE_SCREEN: unique symbol = Symbol.for('screen');
export const BLEND_MODE_COLOR_DODGE: unique symbol = Symbol.for('color-dodge');
export const BLEND_MODE_OVERLAY: unique symbol = Symbol.for('overlay');
export const BLEND_MODE_SOFT_LIGHT: unique symbol = Symbol.for('soft-light');
export const BLEND_MODE_HARD_LIGHT: unique symbol = Symbol.for('hard-light');
export const BLEND_MODE_DIFFERENCE: unique symbol = Symbol.for('difference');
export const BLEND_MODE_EXCLUSION: unique symbol = Symbol.for('exclusion');
export const BLEND_MODE_HUE: unique symbol = Symbol.for('hue');
export const BLEND_MODE_SATURATION: unique symbol = Symbol.for('saturation');
export const BLEND_MODE_COLOR: unique symbol = Symbol.for('color');
export const BLEND_MODE_LUMINOSITY: unique symbol = Symbol.for('luminosity');
export type BlendMode = export type BlendMode =
| 'normal' | 'normal'
| 'darken' | 'darken'
@ -31,20 +14,4 @@ export type BlendMode =
| 'hue' | 'hue'
| 'saturation' | 'saturation'
| 'color' | 'color'
| 'luminosity' | 'luminosity';
| typeof BLEND_MODE_NORMAL
| typeof BLEND_MODE_DARKEN
| typeof BLEND_MODE_MULTIPLY
| typeof BLEND_MODE_COLOR_BURN
| typeof BLEND_MODE_LIGHTEN
| typeof BLEND_MODE_SCREEN
| typeof BLEND_MODE_COLOR_DODGE
| typeof BLEND_MODE_OVERLAY
| typeof BLEND_MODE_SOFT_LIGHT
| typeof BLEND_MODE_HARD_LIGHT
| typeof BLEND_MODE_DIFFERENCE
| typeof BLEND_MODE_EXCLUSION
| typeof BLEND_MODE_HUE
| typeof BLEND_MODE_SATURATION
| typeof BLEND_MODE_COLOR
| typeof BLEND_MODE_LUMINOSITY;

View file

@ -7,9 +7,9 @@ export type Color = {
name?: string; name?: string;
path?: string; path?: string;
value?: string; value?: string;
color?: string; // hex color color?: string;
opacity?: number; opacity?: number;
modifiedAt?: string; //@TODO: check this attribute in penpot modifiedAt?: string;
refId?: Uuid; refId?: Uuid;
refFile?: Uuid; refFile?: Uuid;
gradient?: Gradient; gradient?: Gradient;

View file

@ -1,6 +1,4 @@
export type Export = { export type Export = {
// @TODO: in Penpot this is of type :keyword
// check if it makes sense
type: string; type: string;
scale: number; scale: number;
suffix: string; suffix: string;

View file

@ -1,8 +1,5 @@
export const LINEAR_TYPE: unique symbol = Symbol.for('linear');
export const RADIAL_TYPE: unique symbol = Symbol.for('radial');
export type Gradient = { export type Gradient = {
type: 'linear' | 'radial' | typeof LINEAR_TYPE | typeof RADIAL_TYPE; // symbol type: 'linear' | 'radial';
startX: number; startX: number;
startY: number; startY: number;
endX: number; endX: number;

View file

@ -39,6 +39,6 @@ type SquareParams = {
}; };
type GridColor = { type GridColor = {
color: string; // hex color color: string;
opacity: number; opacity: number;
}; };

View file

@ -2,34 +2,22 @@ import { PenpotFile } from '@ui/lib/types/penpotFile';
import { FrameShape } from '@ui/lib/types/shapes/frameShape'; import { FrameShape } from '@ui/lib/types/shapes/frameShape';
import { Uuid } from '@ui/lib/types/utils/uuid'; import { Uuid } from '@ui/lib/types/utils/uuid';
import { parseFigmaId } from '@ui/parser'; import { parseFigmaId } from '@ui/parser';
import { symbolBlendMode, symbolFills, symbolStrokes } from '@ui/parser/creators/symbols'; import { symbolFills, symbolStrokes } from '@ui/parser/creators/symbols';
import { createItems } from '.'; import { createItems } from '.';
export const createArtboard = ( export const createArtboard = (
file: PenpotFile, file: PenpotFile,
{ { type, children = [], figmaId, figmaRelatedId, ...shape }: FrameShape
type,
fills,
strokes,
blendMode,
children = [],
figmaId,
figmaRelatedId,
shapeRef,
...rest
}: FrameShape
): Uuid | undefined => { ): Uuid | undefined => {
const id = parseFigmaId(file, figmaId); const id = parseFigmaId(file, figmaId);
file.addArtboard({ shape.id = id;
id, shape.shapeRef ??= parseFigmaId(file, figmaRelatedId, true);
shapeRef: shapeRef ?? parseFigmaId(file, figmaRelatedId, true), shape.fills = symbolFills(shape.fills);
fills: symbolFills(fills), shape.strokes = symbolStrokes(shape.strokes);
strokes: symbolStrokes(strokes),
blendMode: symbolBlendMode(blendMode), file.addArtboard(shape);
...rest
});
createItems(file, children); createItems(file, children);

View file

@ -1,38 +1,21 @@
import { PenpotFile } from '@ui/lib/types/penpotFile'; import { PenpotFile } from '@ui/lib/types/penpotFile';
import { BoolShape } from '@ui/lib/types/shapes/boolShape'; import { BoolShape } from '@ui/lib/types/shapes/boolShape';
import { parseFigmaId } from '@ui/parser'; import { parseFigmaId } from '@ui/parser';
import { import { symbolBoolType, symbolFills, symbolStrokes } from '@ui/parser/creators/symbols';
symbolBlendMode,
symbolBoolType,
symbolFills,
symbolStrokes
} from '@ui/parser/creators/symbols';
import { createItems } from '.'; import { createItems } from '.';
export const createBool = ( export const createBool = (
file: PenpotFile, file: PenpotFile,
{ { type, figmaId, figmaRelatedId, children = [], ...shape }: BoolShape
type,
fills,
strokes,
boolType,
blendMode,
figmaId,
figmaRelatedId,
children = [],
...rest
}: BoolShape
) => { ) => {
file.addBool({ shape.id = parseFigmaId(file, figmaId);
id: parseFigmaId(file, figmaId), shape.shapeRef = parseFigmaId(file, figmaRelatedId, true);
shapeRef: parseFigmaId(file, figmaRelatedId, true), shape.fills = symbolFills(shape.fills);
fills: symbolFills(fills), shape.strokes = symbolStrokes(shape.strokes);
strokes: symbolStrokes(strokes), shape.boolType = symbolBoolType(shape.boolType);
blendMode: symbolBlendMode(blendMode),
boolType: symbolBoolType(boolType), file.addBool(shape);
...rest
});
createItems(file, children); createItems(file, children);

View file

@ -1,18 +1,16 @@
import { PenpotFile } from '@ui/lib/types/penpotFile'; import { PenpotFile } from '@ui/lib/types/penpotFile';
import { CircleShape } from '@ui/lib/types/shapes/circleShape'; import { CircleShape } from '@ui/lib/types/shapes/circleShape';
import { parseFigmaId } from '@ui/parser'; import { parseFigmaId } from '@ui/parser';
import { symbolBlendMode, symbolFills, symbolStrokes } from '@ui/parser/creators/symbols'; import { symbolFills, symbolStrokes } from '@ui/parser/creators/symbols';
export const createCircle = ( export const createCircle = (
file: PenpotFile, file: PenpotFile,
{ type, fills, strokes, blendMode, figmaId, figmaRelatedId, ...rest }: CircleShape { type, figmaId, figmaRelatedId, ...shape }: CircleShape
) => { ) => {
file.createCircle({ shape.id = parseFigmaId(file, figmaId);
id: parseFigmaId(file, figmaId), shape.shapeRef = parseFigmaId(file, figmaRelatedId, true);
shapeRef: parseFigmaId(file, figmaRelatedId, true), shape.fills = symbolFills(shape.fills);
fills: symbolFills(fills), shape.strokes = symbolStrokes(shape.strokes);
strokes: symbolStrokes(strokes),
blendMode: symbolBlendMode(blendMode), file.createCircle(shape);
...rest
});
}; };

View file

@ -8,21 +8,20 @@ import { createArtboard } from '.';
export const createComponent = (file: PenpotFile, { figmaId }: ComponentRoot) => { export const createComponent = (file: PenpotFile, { figmaId }: ComponentRoot) => {
const component = componentsLibrary.get(figmaId); const component = componentsLibrary.get(figmaId);
if (!component) { if (!component) {
return; return;
} }
const uiComponent = uiComponents.get(figmaId); const componentId = getComponentId(file, figmaId);
const componentId = uiComponent?.componentId ?? file.newId(); const { type, ...shape } = component;
const frameId = createArtboard(file, { shape.componentFile = file.getId();
...component, shape.componentId = componentId;
componentFile: file.getId(), shape.componentRoot = true;
componentId, shape.mainInstance = true;
componentRoot: true,
mainInstance: true, const frameId = createArtboard(file, shape);
type: 'frame'
});
if (!frameId) { if (!frameId) {
return; return;
@ -35,3 +34,9 @@ export const createComponent = (file: PenpotFile, { figmaId }: ComponentRoot) =>
mainInstanceId: frameId mainInstanceId: frameId
}); });
}; };
const getComponentId = (file: PenpotFile, figmaId: string) => {
const uiComponent = uiComponents.get(figmaId);
return uiComponent?.componentId ?? file.newId();
};

View file

@ -13,31 +13,37 @@ export const createComponentInstance = (
figmaId, figmaId,
figmaRelatedId, figmaRelatedId,
isComponentRoot, isComponentRoot,
...rest ...shape
}: ComponentInstance }: ComponentInstance
) => { ) => {
let uiComponent = uiComponents.get(mainComponentFigmaId); const uiComponent =
uiComponents.get(mainComponentFigmaId) ?? createUiComponent(file, mainComponentFigmaId);
if (!uiComponent) { if (!uiComponent) {
return;
}
shape.shapeRef = uiComponent.mainInstanceId;
shape.componentFile = file.getId();
shape.componentRoot = isComponentRoot;
shape.componentId = uiComponent.componentId;
createArtboard(file, shape);
};
const createUiComponent = (file: PenpotFile, mainComponentFigmaId: string) => {
const mainInstanceId = parseFigmaId(file, mainComponentFigmaId); const mainInstanceId = parseFigmaId(file, mainComponentFigmaId);
if (!mainInstanceId) { if (!mainInstanceId) {
return; return;
} }
uiComponent = { const uiComponent = {
componentId: file.newId(), componentId: file.newId(),
componentFigmaId: mainComponentFigmaId, componentFigmaId: mainComponentFigmaId,
mainInstanceId mainInstanceId
}; };
uiComponents.register(mainComponentFigmaId, uiComponent);
}
createArtboard(file, { uiComponents.register(mainComponentFigmaId, uiComponent);
...rest,
shapeRef: uiComponent.mainInstanceId, return uiComponent;
componentFile: file.getId(),
componentRoot: isComponentRoot,
componentId: uiComponent.componentId,
type: 'frame'
});
}; };

View file

@ -3,7 +3,7 @@ import { sleep } from '@plugin/utils/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 { symbolBlendMode, symbolFills, symbolStrokes } from '@ui/parser/creators/symbols'; import { symbolFills, symbolStrokes } from '@ui/parser/creators/symbols';
import { UiComponent, uiComponents } from '@ui/parser/libraries'; import { UiComponent, uiComponents } from '@ui/parser/libraries';
import { createItems } from '.'; import { createItems } from '.';
@ -41,21 +41,19 @@ const createComponentLibrary = async (file: PenpotFile, uiComponent: UiComponent
return; return;
} }
const { children = [], fills, strokes, blendMode, ...rest } = component; const { children = [], ...shape } = component;
file.startComponent({ shape.fills = symbolFills(shape.fills);
...rest, shape.strokes = symbolStrokes(shape.strokes);
fills: symbolFills(fills), shape.id = uiComponent.componentId;
strokes: symbolStrokes(strokes), shape.componentId = uiComponent.componentId;
blendMode: symbolBlendMode(blendMode), shape.mainInstancePage = uiComponent.mainInstancePage;
id: uiComponent.componentId, shape.mainInstanceId = uiComponent.mainInstanceId;
componentId: uiComponent.componentId, shape.componentRoot = true;
mainInstancePage: uiComponent.mainInstancePage, shape.mainInstance = true;
mainInstanceId: uiComponent.mainInstanceId, shape.componentFile = file.getId();
componentRoot: true,
mainInstance: true, file.startComponent(shape);
componentFile: file.getId()
});
createItems(file, children); createItems(file, children);

View file

@ -1,20 +1,17 @@
import { PenpotFile } from '@ui/lib/types/penpotFile'; import { PenpotFile } from '@ui/lib/types/penpotFile';
import { GroupShape } from '@ui/lib/types/shapes/groupShape'; import { GroupShape } from '@ui/lib/types/shapes/groupShape';
import { parseFigmaId } from '@ui/parser'; import { parseFigmaId } from '@ui/parser';
import { symbolBlendMode } from '@ui/parser/creators/symbols';
import { createItems } from '.'; import { createItems } from '.';
export const createGroup = ( export const createGroup = (
file: PenpotFile, file: PenpotFile,
{ type, blendMode, children = [], figmaId, figmaRelatedId, ...rest }: GroupShape { type, children = [], figmaId, figmaRelatedId, ...shape }: GroupShape
) => { ) => {
file.addGroup({ shape.id = parseFigmaId(file, figmaId);
id: parseFigmaId(file, figmaId), shape.shapeRef = parseFigmaId(file, figmaRelatedId, true);
shapeRef: parseFigmaId(file, figmaRelatedId, true),
blendMode: symbolBlendMode(blendMode), file.addGroup(shape);
...rest
});
createItems(file, children); createItems(file, children);

View file

@ -1,24 +1,17 @@
import { PenpotFile } from '@ui/lib/types/penpotFile'; import { PenpotFile } from '@ui/lib/types/penpotFile';
import { PathShape } from '@ui/lib/types/shapes/pathShape'; import { PathShape } from '@ui/lib/types/shapes/pathShape';
import { parseFigmaId } from '@ui/parser'; import { parseFigmaId } from '@ui/parser';
import { import { symbolFills, symbolPathContent, symbolStrokes } from '@ui/parser/creators/symbols';
symbolBlendMode,
symbolFills,
symbolPathContent,
symbolStrokes
} from '@ui/parser/creators/symbols';
export const createPath = ( export const createPath = (
file: PenpotFile, file: PenpotFile,
{ type, fills, strokes, blendMode, content, figmaId, figmaRelatedId, ...rest }: PathShape { type, figmaId, figmaRelatedId, ...shape }: PathShape
) => { ) => {
file.createPath({ shape.id = parseFigmaId(file, figmaId);
id: parseFigmaId(file, figmaId), shape.shapeRef = parseFigmaId(file, figmaRelatedId, true);
shapeRef: parseFigmaId(file, figmaRelatedId, true), shape.fills = symbolFills(shape.fills);
fills: symbolFills(fills), shape.strokes = symbolStrokes(shape.strokes);
strokes: symbolStrokes(strokes), shape.content = symbolPathContent(shape.content);
blendMode: symbolBlendMode(blendMode),
content: symbolPathContent(content), file.createPath(shape);
...rest
});
}; };

View file

@ -1,18 +1,16 @@
import { PenpotFile } from '@ui/lib/types/penpotFile'; import { PenpotFile } from '@ui/lib/types/penpotFile';
import { RectShape } from '@ui/lib/types/shapes/rectShape'; import { RectShape } from '@ui/lib/types/shapes/rectShape';
import { parseFigmaId } from '@ui/parser'; import { parseFigmaId } from '@ui/parser';
import { symbolBlendMode, symbolFills, symbolStrokes } from '@ui/parser/creators/symbols'; import { symbolFills, symbolStrokes } from '@ui/parser/creators/symbols';
export const createRectangle = ( export const createRectangle = (
file: PenpotFile, file: PenpotFile,
{ type, fills, strokes, blendMode, figmaId, figmaRelatedId, ...rest }: RectShape { type, figmaId, figmaRelatedId, ...shape }: RectShape
) => { ) => {
file.createRect({ shape.id = parseFigmaId(file, figmaId);
id: parseFigmaId(file, figmaId), shape.shapeRef = parseFigmaId(file, figmaRelatedId, true);
shapeRef: parseFigmaId(file, figmaRelatedId, true), shape.fills = symbolFills(shape.fills);
fills: symbolFills(fills), shape.strokes = symbolStrokes(shape.strokes);
strokes: symbolStrokes(strokes),
blendMode: symbolBlendMode(blendMode), file.createRect(shape);
...rest
});
}; };

View file

@ -1,20 +1,18 @@
import { PenpotFile } from '@ui/lib/types/penpotFile'; import { PenpotFile } from '@ui/lib/types/penpotFile';
import { TextContent, TextShape } from '@ui/lib/types/shapes/textShape'; import { TextContent, TextShape } from '@ui/lib/types/shapes/textShape';
import { parseFigmaId } from '@ui/parser'; import { parseFigmaId } from '@ui/parser';
import { symbolBlendMode, symbolFills, symbolStrokes } from '@ui/parser/creators/symbols'; import { symbolFills, symbolStrokes } from '@ui/parser/creators/symbols';
export const createText = ( export const createText = (
file: PenpotFile, file: PenpotFile,
{ type, blendMode, strokes, figmaId, content, figmaRelatedId, ...rest }: TextShape { type, figmaId, figmaRelatedId, ...shape }: TextShape
) => { ) => {
file.createText({ shape.id = parseFigmaId(file, figmaId);
id: parseFigmaId(file, figmaId), shape.shapeRef = parseFigmaId(file, figmaRelatedId, true);
shapeRef: parseFigmaId(file, figmaRelatedId, true), shape.content = parseContent(shape.content);
content: parseContent(content), shape.strokes = symbolStrokes(shape.strokes);
blendMode: symbolBlendMode(blendMode),
strokes: symbolStrokes(strokes), file.createText(shape);
...rest
});
}; };
const parseContent = (content: TextContent | undefined): TextContent | undefined => { const parseContent = (content: TextContent | undefined): TextContent | undefined => {

View file

@ -1,4 +1,3 @@
export * from './symbolBlendMode';
export * from './symbolBoolType'; export * from './symbolBoolType';
export * from './symbolFills'; export * from './symbolFills';
export * from './symbolPathContent'; export * from './symbolPathContent';

View file

@ -1,60 +0,0 @@
import {
BLEND_MODE_COLOR,
BLEND_MODE_COLOR_BURN,
BLEND_MODE_COLOR_DODGE,
BLEND_MODE_DARKEN,
BLEND_MODE_DIFFERENCE,
BLEND_MODE_EXCLUSION,
BLEND_MODE_HARD_LIGHT,
BLEND_MODE_HUE,
BLEND_MODE_LIGHTEN,
BLEND_MODE_LUMINOSITY,
BLEND_MODE_MULTIPLY,
BLEND_MODE_NORMAL,
BLEND_MODE_OVERLAY,
BLEND_MODE_SATURATION,
BLEND_MODE_SCREEN,
BLEND_MODE_SOFT_LIGHT,
BlendMode
} from '@ui/lib/types/utils/blendModes';
export const symbolBlendMode = (blendMode?: BlendMode): BlendMode | undefined => {
if (!blendMode) return;
if (typeof blendMode !== 'string') return blendMode;
switch (blendMode) {
case 'normal':
return BLEND_MODE_NORMAL;
case 'darken':
return BLEND_MODE_DARKEN;
case 'multiply':
return BLEND_MODE_MULTIPLY;
case 'color-burn':
return BLEND_MODE_COLOR_BURN;
case 'lighten':
return BLEND_MODE_LIGHTEN;
case 'screen':
return BLEND_MODE_SCREEN;
case 'color-dodge':
return BLEND_MODE_COLOR_DODGE;
case 'overlay':
return BLEND_MODE_OVERLAY;
case 'soft-light':
return BLEND_MODE_SOFT_LIGHT;
case 'hard-light':
return BLEND_MODE_HARD_LIGHT;
case 'difference':
return BLEND_MODE_DIFFERENCE;
case 'exclusion':
return BLEND_MODE_EXCLUSION;
case 'hue':
return BLEND_MODE_HUE;
case 'saturation':
return BLEND_MODE_SATURATION;
case 'color':
return BLEND_MODE_COLOR;
case 'luminosity':
return BLEND_MODE_LUMINOSITY;
}
};

View file

@ -1,5 +1,4 @@
import { Fill } from '@ui/lib/types/utils/fill'; import { Fill } from '@ui/lib/types/utils/fill';
import { Gradient, LINEAR_TYPE, RADIAL_TYPE } from '@ui/lib/types/utils/gradient';
import { ImageColor, PartialImageColor } from '@ui/lib/types/utils/imageColor'; import { ImageColor, PartialImageColor } from '@ui/lib/types/utils/imageColor';
import { uiImages } from '@ui/parser/libraries'; import { uiImages } from '@ui/parser/libraries';
@ -7,10 +6,6 @@ export const symbolFills = (fills?: Fill[]): Fill[] | undefined => {
if (!fills) return; if (!fills) return;
return fills.map(fill => { return fills.map(fill => {
if (fill.fillColorGradient) {
fill.fillColorGradient = symbolFillGradient(fill.fillColorGradient);
}
if (fill.fillImage) { if (fill.fillImage) {
fill.fillImage = symbolFillImage(fill.fillImage); fill.fillImage = symbolFillImage(fill.fillImage);
} }
@ -19,25 +14,6 @@ export const symbolFills = (fills?: Fill[]): Fill[] | undefined => {
}); });
}; };
const symbolFillGradient = (fillGradient: Gradient): Gradient => {
if (typeof fillGradient.type !== 'string') return fillGradient;
const { type, ...rest } = fillGradient;
switch (type) {
case 'linear':
return {
type: LINEAR_TYPE,
...rest
};
case 'radial':
return {
type: RADIAL_TYPE,
...rest
};
}
};
export const symbolFillImage = ( export const symbolFillImage = (
fillImage: ImageColor | PartialImageColor fillImage: ImageColor | PartialImageColor
): ImageColor | undefined => { ): ImageColor | undefined => {

View file

@ -1,7 +1,6 @@
import { import {
Command, Command,
PathContent, PathContent,
Segment,
VECTOR_CLOSE_PATH, VECTOR_CLOSE_PATH,
VECTOR_CURVE_TO, VECTOR_CURVE_TO,
VECTOR_LINE_TO, VECTOR_LINE_TO,
@ -9,13 +8,10 @@ import {
} from '@ui/lib/types/shapes/pathShape'; } from '@ui/lib/types/shapes/pathShape';
export const symbolPathContent = (content: PathContent): PathContent => export const symbolPathContent = (content: PathContent): PathContent =>
content.map(({ command: stringCommand, ...rest }) => { content.map(segment => {
const command = symbolPathCommand(stringCommand); segment.command = symbolPathCommand(segment.command);
return { return segment;
command,
...rest
} as Segment;
}); });
const symbolPathCommand = (command: Command): Command => { const symbolPathCommand = (command: Command): Command => {