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

28 lines
626 B
TypeScript
Raw Normal View History

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();