getMaxVisibleItems.ts
1 // eslint-disable-next-line import/no-extraneous-dependencies 2 import { ShelfConfig } from '@amp/web-app-components/config/components/shelf'; 3 import type { GridType } from '@amp/web-app-components/src/components/Shelf/types'; 4 5 /** 6 * Find the max amount of rendered items for a grid type. 7 */ 8 // eslint-disable-next-line import/prefer-default-export 9 export const getMaxVisibleItems = (type: GridType): number => { 10 const { GRID_VALUES } = ShelfConfig.get(); 11 12 const gridValues = GRID_VALUES[type]; 13 14 const arrayOfgridValues = [...Object.values(gridValues)].filter( 15 (item) => typeof item === 'number', 16 ); 17 18 return Math.max(...arrayOfgridValues); 19 };