rspace-online/modules/swag/products.ts

75 lines
2.0 KiB
TypeScript

export interface ProductTemplate {
id: string;
name: string;
description: string;
// Print area dimensions in mm
printArea: { widthMm: number; heightMm: number };
// Output DPI
dpi: number;
// Bleed in mm
bleedMm: number;
// What artifact spec fields to use
productType: string;
substrates: string[];
requiredCapabilities: string[];
finish: string;
// Computed pixel dimensions (at DPI)
get widthPx(): number;
get heightPx(): number;
}
function makeTemplate(opts: Omit<ProductTemplate, "widthPx" | "heightPx">): ProductTemplate {
return {
...opts,
get widthPx() {
return Math.round(((this.printArea.widthMm + this.bleedMm * 2) / 25.4) * this.dpi);
},
get heightPx() {
return Math.round(((this.printArea.heightMm + this.bleedMm * 2) / 25.4) * this.dpi);
},
};
}
export const PRODUCTS: Record<string, ProductTemplate> = {
sticker: makeTemplate({
id: "sticker",
name: "Sticker Sheet",
description: "A4 sheet of die-cut vinyl stickers",
printArea: { widthMm: 210, heightMm: 297 },
dpi: 300,
bleedMm: 2,
productType: "sticker-sheet",
substrates: ["vinyl-matte", "vinyl-gloss", "sticker-paper-matte"],
requiredCapabilities: ["vinyl-cut"],
finish: "matte",
}),
poster: makeTemplate({
id: "poster",
name: "Poster (A3)",
description: "A3 art print / poster",
printArea: { widthMm: 297, heightMm: 420 },
dpi: 300,
bleedMm: 3,
productType: "poster",
substrates: ["paper-160gsm-cover", "paper-100gsm"],
requiredCapabilities: ["inkjet-print"],
finish: "matte",
}),
tee: makeTemplate({
id: "tee",
name: "T-Shirt",
description: "Front print on cotton tee (12x16 inch print area)",
printArea: { widthMm: 305, heightMm: 406 },
dpi: 300,
bleedMm: 0,
productType: "tee",
substrates: ["cotton-standard", "cotton-organic"],
requiredCapabilities: ["dtg-print"],
finish: "none",
}),
};
export function getProduct(id: string): ProductTemplate | undefined {
return PRODUCTS[id];
}