| 1 | export type InfographicSlideLayout = |
| 2 | | "left" |
| 3 | | "right" |
| 4 | | "vertical" |
| 5 | | "background" |
| 6 | | "none"; |
| 7 | |
| 8 | export type InfographicOrientation = "horizontal" | "vertical" | "flexible"; |
| 9 | |
| 10 | export function getInfographicOrientationForSlideLayout( |
| 11 | slideLayoutType?: string, |
| 12 | ): InfographicOrientation { |
| 13 | if (slideLayoutType === "left" || slideLayoutType === "right") { |
| 14 | return "vertical"; |
| 15 | } |
| 16 | |
| 17 | if (slideLayoutType === "vertical") { |
| 18 | return "horizontal"; |
| 19 | } |
| 20 | |
| 21 | return "horizontal"; |
| 22 | } |
| 23 | |
| 24 | export function buildInfographicLayoutInstruction( |
| 25 | slideLayoutType?: string, |
| 26 | ): string { |
| 27 | const orientation = getInfographicOrientationForSlideLayout(slideLayoutType); |
| 28 | |
| 29 | if (orientation === "vertical") { |
| 30 | return [ |
| 31 | "Required infographic orientation: vertical.", |
| 32 | "Use a portrait/stacked composition that fits a narrow content column beside a side root image.", |
| 33 | "Choose top-to-bottom templates such as sequence-roadmap-vertical-*, relation-dagre-flow-tb-*, list-column-*, hierarchy-tree-* or compact stacked hierarchy/list templates.", |
| 34 | "Do not choose wide left-to-right templates such as compare-binary-horizontal-*, relation-dagre-flow-lr-*, list-row-*, or sequence-horizontal-*.", |
| 35 | ].join(" "); |
| 36 | } |
| 37 | |
| 38 | return [ |
| 39 | "Required infographic orientation: horizontal.", |
| 40 | "Use a landscape/wide composition for the full-width content area, especially when the slide uses a vertical/top root-image layout.", |
| 41 | "Choose left-to-right, row, grid, quadrant, or landscape templates such as relation-dagre-flow-lr-*, list-row-*, list-grid-*, compare-binary-horizontal-*, quadrant-*, sequence-horizontal-*, sequence-steps-*, sequence-timeline-* or horizontal snake/zigzag templates.", |
| 42 | "Do not choose tall vertical roadmap/list-column templates such as sequence-roadmap-vertical-* or list-column-*.", |
| 43 | ].join(" "); |
| 44 | } |
| 45 | |
| 46 | function isInfographicTemplateCompatibleWithOrientation( |
| 47 | templateName: string, |
| 48 | orientation: InfographicOrientation, |
| 49 | ): boolean { |
| 50 | if (orientation === "flexible") { |
| 51 | return true; |
| 52 | } |
| 53 | |
| 54 | if (orientation === "vertical") { |
| 55 | return ![ |
| 56 | "compare-binary-horizontal-", |
| 57 | "compare-hierarchy-left-right-", |
| 58 | "list-row-", |
| 59 | "relation-dagre-flow-lr-", |
| 60 | "sequence-horizontal-", |
| 61 | ].some((prefix) => templateName.startsWith(prefix)); |
| 62 | } |
| 63 | |
| 64 | return ![ |
| 65 | "list-column-", |
| 66 | "relation-dagre-flow-tb-", |
| 67 | "sequence-roadmap-vertical-", |
| 68 | ].some((prefix) => templateName.startsWith(prefix)); |
| 69 | } |
| 70 | |
| 71 | export function filterInfographicTemplatesForOrientation( |
| 72 | templateNames: string[], |
| 73 | orientation: InfographicOrientation, |
| 74 | ): string[] { |
| 75 | const compatibleTemplates = templateNames.filter((templateName) => |
| 76 | isInfographicTemplateCompatibleWithOrientation(templateName, orientation), |
| 77 | ); |
| 78 | |
| 79 | return compatibleTemplates.length > 0 ? compatibleTemplates : templateNames; |
| 80 | } |
| 81 |