UNPKG

@pagamio/frontend-commons-lib

Version:

Pagamio library for Frontend reusable components like the form engine and table container

33 lines (32 loc) 870 B
/** * Determines the span and offset for Grid.Col based on the number of visuals in a row. * * @param numVisuals - Number of visuals in the current row. * @returns An object containing `span` and `offset` values. */ export const getGridColProps = (numVisuals, visualIdx) => { let span; let offset = 0; switch (numVisuals) { case 1: span = 12; // 100% offset = 0; break; case 2: span = 6; // Each 50% break; case 3: span = 4; // Each ~33.33% break; case 4: span = 3; // Each 25% break; default: span = 3; // Default to 25% for rows with >4 visuals break; } if (numVisuals === 1 && visualIdx === 0) { return { span, offset }; } return { span, offset: 0 }; };