import * as z from "zod"; const ComparisonRowSchema = z.object({ feature: z.string().min(4).max(17).meta({ description: "Feature label shown in the first column.", }), column1: z.string().max(10).meta({ description: "Column 1 cell value.", }), column2: z.string().max(10).meta({ description: "Column 2 cell value.", }), column3: z.string().max(10).meta({ description: "Column 3 cell value.", }), }); export const slideLayoutId = "table-slide"; export const slideLayoutName = "Table Slide"; export const slideLayoutDescription = "A slide with title and a table."; export const Schema = z.object({ title: z.string().min(6).max(18).default("Comparison").meta({ description: "Slide title shown above the table.", }), tableColumns: z.array(z.string().max(4)).meta({ description: "Table columns shown in the first row.", }).default(["Feature", "Column 1", "Column 2", "Column 3"]), rows: z .array(ComparisonRowSchema) .min(1) .max(6) .default([ { feature: "Component-based", column1: "check", column2: "check", column3: "check" }, { feature: "TypeScript Support", column1: "check", column2: "check", column3: "check" }, { feature: "Learning Curve", column1: "Medium", column2: "Easy", column3: "Steep" }, { feature: "Bundle Size", column1: "40KB", column2: "34KB", column3: "167KB" }, { feature: "Performance", column1: "Excellent", column2: "Excellent", column3: "Good" }, { feature: "Community Size", column1: "Huge", column2: "Large", column3: "Large" }, ]) .meta({ description: "Six comparison rows shown in the table.", }), pageLabel: z.string().min(3).max(8).optional().default("5 / 11").meta({ description: "Bottom pagination label.", }), }); export type SchemaType = z.infer; function renderCell(value: string) { if (value && value.toLowerCase() === "check") { return ; } return {value}; } const CodeSlide05ComparisonTable = ({ data }: { data: Partial }) => { return ( <>

{data.title}

{data?.tableColumns?.map((column) => (

{column}

))}
{data?.rows?.map((row) => (

{row.feature}

{renderCell(row.column1)}
{renderCell(row.column2)}
{renderCell(row.column3)}
))}
{data.pageLabel}
); }; export default CodeSlide05ComparisonTable;