mirror of
https://github.com/penpot/penpot-exporter-figma-plugin.git
synced 2025-01-03 13:20:37 -05:00
d3c144e5e9
* color library * fixes * wip * wip * wip * wip * working * improvements * changeset * changeset * changeset & cleaning * changeset & cleaning * improvements * fixes * rebase
34 lines
895 B
TypeScript
34 lines
895 B
TypeScript
import { translateFill } from '@plugin/translators/fills/translateFills';
|
|
|
|
import { FillStyle } from '@ui/lib/types/utils/fill';
|
|
|
|
export const translatePaintStyle = (figmaStyle: PaintStyle): FillStyle => {
|
|
const fillStyle: FillStyle = {
|
|
name: figmaStyle.name,
|
|
fills: [],
|
|
colors: []
|
|
};
|
|
|
|
const colorName = (figmaStyle: PaintStyle, index: number): string => {
|
|
return figmaStyle.paints.length > 1 ? `Color ${index + 1}` : figmaStyle.name;
|
|
};
|
|
|
|
let index = 0;
|
|
const path =
|
|
(figmaStyle.remote ? 'Remote / ' : '') + (figmaStyle.paints.length > 1 ? figmaStyle.name : '');
|
|
|
|
for (const fill of figmaStyle.paints) {
|
|
const penpotFill = translateFill(fill);
|
|
|
|
if (penpotFill) {
|
|
fillStyle.fills.unshift(penpotFill);
|
|
fillStyle.colors.unshift({
|
|
path,
|
|
name: colorName(figmaStyle, index)
|
|
});
|
|
}
|
|
index++;
|
|
}
|
|
|
|
return fillStyle;
|
|
};
|