0
Fork 0
mirror of https://github.com/penpot/penpot-exporter-figma-plugin.git synced 2024-12-22 13:43:03 -05:00
penpot-exporter-figma-plugin/plugin-src/StyleLibrary.ts
Alex Sánchez 672567614b
Use Fill Styles to generate fills more efficiently (#180)
* first commit

* change esbuild

* changeset
2024-06-19 15:58:13 +02:00

27 lines
626 B
TypeScript

import { Fill } from '@ui/lib/types/utils/fill';
class StyleLibrary {
private styles: Map<string, Fill[]> = new Map();
public register(id: string, styles: Fill[]) {
this.styles.set(id, styles);
}
public get(id: string): Fill[] | undefined {
return this.styles.get(id);
}
public has(id: string): boolean {
return this.styles.has(id);
}
public all(): Record<string, Fill[]> {
return Object.fromEntries(this.styles.entries());
}
public init(styles: Record<string, Fill[]>): void {
this.styles = new Map(Object.entries(styles));
}
}
export const styleLibrary = new StyleLibrary();