mirror of
https://github.com/penpot/penpot-exporter-figma-plugin.git
synced 2025-01-06 23:00:55 -05:00
d3c144e5e9
* color library * fixes * wip * wip * wip * wip * working * improvements * changeset * changeset * changeset & cleaning * changeset & cleaning * improvements * fixes * rebase
42 lines
1.1 KiB
TypeScript
42 lines
1.1 KiB
TypeScript
import { sleep } from '@plugin/utils/sleep';
|
|
|
|
import { sendMessage } from '@ui/context';
|
|
import { PenpotFile } from '@ui/lib/types/penpotFile';
|
|
import { uiTextLibraries } from '@ui/parser/libraries/UiTextLibraries';
|
|
|
|
export const createTextLibrary = async (file: PenpotFile) => {
|
|
let librariesBuilt = 1;
|
|
const libraries = uiTextLibraries.all();
|
|
|
|
sendMessage({
|
|
type: 'PROGRESS_TOTAL_ITEMS',
|
|
data: libraries.length
|
|
});
|
|
|
|
sendMessage({
|
|
type: 'PROGRESS_STEP',
|
|
data: 'typoLibraries'
|
|
});
|
|
|
|
for (const library of libraries) {
|
|
file.addLibraryTypography({
|
|
...library.typography,
|
|
fontId: library.textStyle.fontId,
|
|
fontVariantId: library.textStyle.fontVariantId,
|
|
letterSpacing: library.textStyle.letterSpacing,
|
|
fontWeight: library.textStyle.fontWeight,
|
|
fontStyle: library.textStyle.fontStyle,
|
|
fontFamily: library.textStyle.fontFamily,
|
|
fontSize: library.textStyle.fontSize,
|
|
textTransform: library.textStyle.textTransform,
|
|
lineHeight: library.textStyle.lineHeight
|
|
});
|
|
|
|
sendMessage({
|
|
type: 'PROGRESS_PROCESSED_ITEMS',
|
|
data: librariesBuilt++
|
|
});
|
|
|
|
await sleep(0);
|
|
}
|
|
};
|