Advertisement
Guest User

Untitled

a guest
May 24th, 2018
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import type {
  2.   SearchMatch,
  3.   SearchResults,
  4.   GlobalSearchResults,
  5.   SearchItemLayout,
  6.   SearchItemLayoutTypes,
  7. } from 'utils/search/search-types';
  8.  
  9. const SEARCH_SIDEBAR_WIDTH = 576;
  10. const SEARCH_ITEM_COVER_HEIGHT = 60;
  11. const SEARCH_ITEM_HEIGHT = 68;
  12.  
  13. const SEARCH_ITEM_LAYOUT_TYPES: SearchItemLayoutTypes = {
  14.   Cover: 'cover',
  15.   Match: 'match',
  16. };
  17. ...
  18.  
  19. const LayoutProviderFactory = results => {
  20.   return new LayoutProvider(
  21.     index => {
  22.       const searchItem = results[index];
  23.       if (!searchItem) {
  24.         //TODO: how is that possible?
  25.         return 'unknown';
  26.       }
  27.       return searchItem.layoutType;
  28.     },
  29.     (type: SearchItemLayout, dim) => {
  30.       switch (type) {
  31.         case SEARCH_ITEM_LAYOUT_TYPES.Cover: // HERE
  32.           dim.width = SEARCH_SIDEBAR_WIDTH;
  33.           dim.height = SEARCH_ITEM_COVER_HEIGHT;
  34.           break;
  35.         case SEARCH_ITEM_LAYOUT_TYPES.Match:
  36.           dim.width = SEARCH_SIDEBAR_WIDTH;
  37.           dim.height = SEARCH_ITEM_HEIGHT;
  38.           break;
  39.         default: // for 'unknown'
  40.           dim.width = 0;
  41.           dim.height = 0;
  42.       }
  43.     }
  44.   );
  45. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement